Fixed sample rate processing

Hi all.

I am working on a plug-in where the DSP algorithm has to run at 48k at all times.
I’d need to resample the incoming audio in real-time if it is at a different rate than 48k.
Does anyone know of a third-party library that could handle this task?


I used the resampler code of the speex library in a project that had the same requirement. It’s easy to integrate, linear-phase and quite fast. I had to do some additional fifo buffering for realtime use as the number of output samples can fluctuate per fixed size input buffer.

1 Like

Wouldn’t something like the LagrangeInterpolator class do the job ?

1 Like

Only if you don’t care about noise at ~ -30dB.

1 Like

The problem with using a pair of asynchronous sample rate converters is that they are not guaranteed to keep in sync, it might well happen that after some seconds you don’t get the exact number of samples out as you supplied. It is possible to have a solution where up- and downsampler are synced to each other, once did that for a commercial emulation that required a fixed sample rate.

1 Like

Thanks I didn’t know that
@rabbitalgorithms I found this pdf by CCRMA that lists a few librairies, might be useful :

1 Like

There’s also this great tool to compare various resamplers:

1 Like

Is your DSP a neural network? If so there’s a new method that may enable training models that can handle arbitrary sample rates.

Hi Adi, thanks for the response.

This is exactly what I’ll need to do. I’ve chosen to work with libsamplerate as it seems very high quality and is pretty simple to get set up.

Do you know of any good examples out there of the fifo buffering that is needed for real-time usage? This part of the implementation has me stuck.

Thanks again.

r8brain is another nice interpolation library. Quality wise it’s just as good as libsamplerate, but a couple years ago it was substantially faster. Mind you for line rate interpolation, i.e. process 1 second of audio every second, libsamplerate was plenty fast too.

In my case using the speex resampler I ended up using a 16 sample circular buffer after resampling to the target rate, doing the processing and resampling back. I did that using arrays of floats + an integer index & 0xf. That was enough to make sure I never run out of samples. It depends on how the samples are fed into your library of choice and how the internal buffering of the resampler works.