How to change sampling rate?
See original GitHub issueHello, awesome package! I’ve tried using Lasp.AudioLevelTracker.audioDataSlice to read raw audio data and from it construct a precise size buffer. My use case is a neural network, it has to have a precise length max input, therefore this package seems like a perfect candidate for fast data acquisition. All I’m doing is looping through audioDataSlice[i] and writing values to my buffer until it’s full. Then run inference with it.
Problem: NN Input also requires sample rate of exactly 16000, not more not less. Seems like in this package default is 48 000.
Question: How to change sampling rate from 48000 to 16000? Cannot a way how I’m meant to do it. AudioLevelTracker does not give access to it’s device. I cannot just Lasp.AudioSystem.GetInputDevice(_input.deviceID).SampleRate = 16000;` because there is no setter in SampleRate constructor.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
I think you can modify the sample rate here: https://github.com/keijiro/Lasp/blob/v2/Packages/jp.keijiro.lasp/Runtime/Internal/InputDeviceHandle.cs#L196
For future reference, to anyone who might be interested in this problem, I went on not to change the sampling rate of the device. It proved simpler and a more universal approach (to adapt to various rates of many devices out there) to just resample everyting every few frames. I used NWaves.Operations for that purpose, because most other solutions did not work or did not even load.