Variable filter with steep cutoff

I want a high order Papoulis filter whose frequency can be moved in real time. Can I somehow generate Papoulis IIR coefficients and use them inside a bunch of juce::IIRFilters?

Background: I’m trying to design an effect, and as part of the algorithm I believe I need to chop off all the information above a certain frequency. This frequency needs to be able to move up and down with automation during the song. I could just use the built-in IIRCoefficients::makeLowPass(sampleRate, frequency) (that’s just a Butterworth filter, right?), but I love the sound of the 20th order Papoulis filter in the free “ToolChain” VST effect by RS-MET. It seems a little steeper and has a sharper transition at the filter frequency. I’m trying to recreate that in JUCE. I’m no DSP expert, but I’ve read that the best way to get variable higher-order filters is to stack second-order filters. Is that all a Papoulis filter is, a basic second-order IIR filter? I just need to get my hands on the algorithm to calculate those coefficients, right?

1 Like

just put a few iirfilters in series to get a higher order, you’ll discover quickly enough how to set it. you can vary those in realtime: the change of coefficients will not create a click.

Well, they are swapped without interrupting the flow. But a big change of the coefficients can cause clicks. If the parameters changes in bigger jumps, you might need to interpolate between the coefficients…

Also note, there is the old class IIRFilter and IIRCoefficients, and there is also the new dsp module with dsp::IIR::Filter and dsp::IIR::Coefficients, and there is the dsp::FilterDesign for higher order filters

The documentation for dsp::FilterDesign seems to indicate that it isn’t meant to be used in scenarios where fast modulation is desired.

Per JUCE: dsp::IIR::Filter< SampleType > Class Template Reference

If you need a lowpass, bandpass or highpass filter with fast modulation of its cutoff frequency, you might use the class StateVariableFilter instead, which is designed to prevent artefacts at parameter changes, instead of the class Filter.

That is also correct, just wanted to point out, that a sudden change in the coefficients can and will in some situations create a sudden change in the signal, hence the need for a parameter smoothing.

The advantage of a modulation is, that the parameter change is predictable and in limits you have under your control, versus a user playing with knobs or even worse, drawing weird automation curves…

Disclaimer: I am not a filter guru, I just use them

1 Like

Is that all a Papoulis filter is, a basic second-order IIR filter?

No, it’s the filter with the fastest roll-off for a given order and no ripple (or rather, a monotonic frequency response), which is said to be “optimal.” You compute the poles using Legendre polynomials, which is why you’ll find more info googling “Optimal-L” filter or “Legendre” filter. This thread has some more info.

If you get an Nth order polynomial (for the denominator) with the coefficients (in the s domain, so continuous time) you can factor that into 2nd order stages of the form

s^2 + a1 s + a2

(where a1/a2 are the coefficients of the nth stage)

Then use this trick:

Fc = sqrt (a2) / 2pi 
Q  = sqrt(a2) / a1

And use those as the cutoff frequency/Q factor parameters of one instance of a StateVariableFilter. Use the lowpass configuration for each stage, feed it into the next. You may need to scale each stage.

My gut feeling is that the Q parameter for any given stage will be the same for any cutoff frequency so you’ll only need to have a lookup table of Q factors for a given order. You may want to verify that.