How to set/change bufferToFill.numSamples

#1

I’m new on JUCE. I’m wondering how to set the number of samples to a different number of (512).
I need to change bufferToFill.numSamples to 576.

0 Likes

#2

When you get the buffer as an argument of the audio callback (AudioProcessor::processBlock or AudioSource::getNextAudioBlock) method, you are not allowed to change the size of it. You need to process exactly as many samples as are in that buffer.

You may be able to influence the size with your DAW software’s or audio driver’s settings. However, your DSP code should be implemented so that the buffer size doesn’t really matter.

0 Likes

#3

Thanks for your reply!
In that case it’s posible to get 576 values of the
auto* audioData = bufferToFill.buffer->getReadPointer (0, bufferToFill.startSample);
in one cycle of the getNextAudioBlock method?

0 Likes

#4

With the buffer passed to AudioSource::getNextAudioBlock, you will additionally need to respect the startSample and numSamples of the AudioSourceChannelInfo. (You must not access samples outside the bounds of startSample to startSample+numSamples.)

Why the need for that exact 576 samples? If your algorithm really needs to access that exact amount, you will need to do some additional buffering yourself. It’s not likely that in a real life scenario you can force the system to ask for that exact amount of samples…

0 Likes