Variable resampling ratio during playback

I’m working on an application which uses the ResamplingAudioSource class. This works as expected but when I change the resampling ratio (ResamplingAudioSource:: setResamplingRatio) I experience audio glitches. As a workaround I divide the audio buffer into small blocks and change the resampling ratio with small steps. However, this leads to a huge CPU increase.

What would be a good solution to fix this issue? Is the LagrangeInterpolator helpful in this case? Or is it recommended that I use an external library for this resampling issue?

Lagrange will give a little better accuracy than ResamplingAudioSource, but won’t help for the glitches.

Sudden change of the frequency is indeed not advisable, better to use the SmoothedValue class.

I used that technique for a tape delay simulation (like EchoPlex) which worked nicely. I also used it for a simple 2D simulation of animated sound sources, so the approach is not the problem. In both cases I used the LagrangeInterpolator from JUCE.

What about just crossfading between 2 ResamplingAudioSource’s when the resampling ratio changes?

@mashu: Thanks for the suggestion, that’s a good approach in some cases, but not possible for the application I’m working on (think about tremolo effects and so on).

@daniel: I could use the SmoothedValue class for this, but that doesn’t really change anything. Now I have a smoothed value myself by dividing the audio block into small parts and process it in small blocks.