Help Implementing IIRFilter with Db/Ocatve Requirements


#1

Hey all,

Been using Juce for a month and it’s great. Awesome community (been lurking).

I’m trying to implement a LPF using the IIR filter class that has a slope of 24Db/Oct.

I’ve tried computing the raw coefficients but I’m having a lot of trouble given that I’m unclear on how a Q factor is related to BW in octaves. If anyone can shed some light on my issue, that would be much appreciated.

Also, what is the default slop on the IIRCoefficients::makeLowPass(sampleRate, freq)?

Thanks.


#2

Hello !

For more information about what the JUCE code does, you can always have a look into the JUCE function. You’ll see for example that the IIRCoefficients::makeLowPass(sampleRate, freq) uses a Q factor = 1 / sqrt(2), which is the limit before the LowPass displays a resonance.

For the relationship between Q and the BW in octaves, JUCE IIRFilter is working the same way than the RBJ EQ Audio Cookbook, so you can have that information here : https://shepazu.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.html

Since the JUCE IIRFilter implements a biquad IIR filter, you can expect a slope of 12 dB/oct. If you need 24 dB or more, you can use in series several IIRFilter objects.


#3

Ahh. I’m familiar with those equations. I can’t believe I didn’t think of using two in series! Thanks a bunch.

This may be a silly question, but don’t two filters operating in series produce some phase issues? Sorry if that’s vague.

Ps - I loved your updated IIRFilter files. You rock.


#4

It’s not a silly question. In general, in DSP, we tend to avoid like the plague the use of any IIR filter with an order higher than 2, for preventing some potential stability and accuracy issues. So, most of higher order IIR filter designs are implemented using parallel or serie first/second order filter sections. In my knowledge, that’s how several commercial EQ plug-ins implement their high slope filter designs.

Of course, having two filters operating in serie will display a change in the phase response, but I’m not sure you will get any specific issue by doing so. The only problem that you will have to solve is how to set the Q factor in your serie filter designs. What is the definition of a 24 dB lowpass filter with a Q = a specific value ? Do we need to use that same Q for the two serie filters ? Do we need to use two different ones ? I’m not sure there is a consensus on that. For example, I think I have seen somewhere that the curve isn’t the same on FabFilter Pro-Q and Pro-Q² for a given lowpass filter with a slope of 24 dB and the same frequency+Q. However, the maximum magnitude of the resonance has to be the same everywhere and whatever the slope.

Thanks for your nice comments :wink:


#5

Thanks for the thorough reply. It’s an interesting problem. I experimented around with some values and got something that works for this purpose but you’re right that there doesn’t seem to be any consensus on this.


#6

Info on calculating Q for cascaded filters, and specific formulae for butterworths at least: