Oversampled AudioBuffer


the logic way is to create a oversampledAudioBuffer as a member of AudioProcessor, and then allocate it in prepareToPlay(fs, samplesPerBlock), but some DAWs hasn’t constant samplesPerBlock, so will change in every getNextAudioBuffer/processBlock.

any suggestions?


the samples per block in prepareToPlay is supposed to be a maximum, but you are right, there are hints in the docs, that in rare cases it will be more samples.
You have two choices,

a) allocate a little more and start each time from sample 0 in the buffer.
Pro: no problems with wrapping around, con: for oversampling you need to store extra the last few samples of the previous buffer.

Or b) create the buffer as fifo where you keep attaching new samples and read afterwards from the same position resampled.
Pro: you can look back in time to create the “over”-samples, Con: you need to properly implement the wrapping around. Is not hard in a loop, but if you want to use the FloatVectorOperations I found it tricky and easy to make mistakes…

I would still go with b…

BTW: I don’t know what the purpose is to oversample in your case, but if it’s for resampling, maybe it’s worth looking at the different resampler classes, e.g. LagrangeInterpolator.


Thanks Daniel,
I think I will use the option a).