How to cascade a series of IIR filters?

Relatively new juce user here, trying to figure out the best way to do this

From my understanding, the IIR Allpass Filter has a 6/db slope by default, and to make the slope steeper you have to cascade filters in a series.

On a section of this project im working on, I want to have a series of 10-20 allpass filters and have parameters that control all of them at the same time. If I put 10 duplicates of the same filter in the processor, I get the exact effect I want, but I want all of the filters to be controllable by 3 parameters and can’t figure out how to set it up. I’ve tried setting it up with the processor chain, and was able to achieve the same effect I wanted, but again am lost when it comes to mapping the parameters how I want to (below).

I want to be able to control the total number of IIR allpass filters active with a slider
(e.g. if slider is set to 0, 0 allpass filters are active. if slider is set to 20, 20 allpass filters are active)

control the Q value of all the filters with a slider
(simultaneously change the Q of every filter that is in the cascade)

control the frequency value of all filters with a slider
(simultaneously change the frequency of every filter that is in the cascade)

If that makes any sense, what’s the easiest way to set this up?

Also I was looking through all the juce documentation for a while last night, I’m not sure if this is an option or if this is just me not having strong enough knowledge of how audio is processed yet

In my head the perfect way to do this would be to run the input into 1 allpass filter, and have the frequency and Q parameters set up (which is super simple), and then somehow tell the processor to run the input into this filter, out of the filter, and back into the filter x number of times, and have x as the parameter that controls the total # of filters active

Filters are stateful, so you need a separate object instance per filter needed, so your trick with just 1 filter instance wouldn’t work.

1 Like

The ProcessorChain doesn’t support varying the number of stages processed, so you can really forget about using that for your purpose. Just have your filter instances in an array/vector and for loop over them in your processBlock code.

Conceptually something like (not code that would work, you need to adapt to whatever filter and parameters changing code you have) :

for (int i=0;i<filterStagesToProcess;++i)

That makes sense,

and if Im reading your second respond correctly, there is no way to be able to control how many of the filters are active through a parameter?

I understand what you’re saying with the array/vector and ive been able to do that now, so I guess my only issue I have left is trying to figure out how to make the total # of filters a controllable parameter

I edited my reply above to include a conceptual code example

thank you, gonna work with this and see if I can get it figured out