How do you handle the wide range of possible sample rates with FFTs and FIR filters?

The possible range for sample rates for VST plugins could be anywhere from 22.05kHz (or even lower) to 192kHz and any “odd ball” rates in between.

How do you folks accommodate such a wide range when working with code that requires fixed block sizes - like FFTs and such? For example, an FFT at 96kHz has different bin locations and resolution than an FFT at 44.1kHz.

Likewise, FIR filters can’t simply be scaled to sample rate like a delay array - their cutoff characteristics change with filter length (N taps).

So, how do you deal with things like this so your plugin sounds the same regardless of sample rate?

It’s pretty unlikely you’ll get “odd ball” rates in a plugin. You can generally count on 44.1k, 48, and 96 for the vast majority of your users. You may get some folks working at 88.2 or 192. It’s not that difficult to handle with a switch statement.

I’d also add that 90% of the time your goal isn’t to match frequency resolution or filter specs across those different sample rates, but to find what’s sufficient for the worst case scenario, and use trial and error in between. Design tools like MATLAB/Octave are your friends for where you really need to care about every possible case.

If you really, truly need to have everything exact for any possible sample rate then you just settle on using a polyphase resampling algorithm to resample to a single sample rate in all cases.