I have a little problem using ofSoundBuffer.
I’m streaming sound from a MS WASAPI microphone device through ofSoundStream.
Everything works fine except the final sample in the ofSoundBuffer is nonsense. (e.g. -8.10599937e+36).
This only occurs with a sample-rate of 44100 - so my first guess is there’s some sloppy re-sampling somewhere upstream. Anyone ever encountered something like this?
Hi @2666hz there is a bug in the resampling algorithm. So if your sound card is setup to a different sample rate than what you set the ofSoundStream with it will resample and this bug will show up.
OK. Thanks.
Now my question is - why is it resampling?
I am only ever using samplerates from ofSoundDevice.sampleRates - do these not mean that the device supports these rates “natively”? or is the device capable of these samplerates, but actually setting the native samplerate done somehow elsewhere?
MM
The issues is that the sound device sample rate is set via the OS or some hardware specific software/control panel. As far as I can recall, OF is not capable of setting the hardware’s sample rate. Thus, when you setup OF to use a sample rate different than the one that is set to the hardware, it will need to resample. Thus, the easy way is to set up your computer’s sample rate and then use that same samplerate in openFrameworks.
Thank you!
I will give it a go.
My software currently lets the user open a device using any of the available sound APIs - so ideally I would need the same code for all API. I would imagine that for the re-sampling to take place, it must first detect if re-sampling is needed at all. Am I right in understanding each incoming buffer comes with a sample-rate?