Proposal for new functions in IIRCoefficients


#1

Hello guys !

I have tried to use the IIRCoefficients class for a thing I’m working on recently, instead of my usual own filter classes, since they are here, but I have not been able to do exactly what I needed… So, instead of going to my own classes again, I decided to rewrite sections of the JUCE IIRCoefficients class :slight_smile:

Indeed, I was expecting to see functions to get a band pass filter, and low pass / high pass filters with variable Q, but they weren’t there. So I wrote them, and they are available here :


I have tested the new code already, it should be working fine. The new band pass filter coefficients are calculated using the same principles than the other ones, following the standard calculus methods (with frequency pre warping, identical to the RBJ Cookbook EQ method)

Would it be possible to include my changes in the base code ? Thanks in advance !


#2

Thank you so much for this. I’ve added it to the develop branch.


#3

Perfect, thanks !


#4

It’s me again @fabian !

I’d like to submit a new version for the IIRFilter class again, this time with functions for making notch filters and all-pass filters, and added jasserts in a few places to send an exception when the requested frequency is higher than sampleRate / 2.0.

It’s here :


The all-pass filter is more useful that you might expect. It doesn’t change the amplitude of the signal indeed but it modifies the phase, so its behaviour can be heard when its output is mixed with its input. It is a key component in phasers and trees of linkwitz-riley filters (for band separation) for example.


#5

This is very cool. Thank you for contributing.

Before I ask, I should say that I know next to nothing about filter theory…but…

What does the Q do in the all pass filter? I thought the idea of an all pass was that it’s flat and only changes phase.

Thanks again.


#6

Hello ! I hope you’ve made a good use of my tube drive code :slight_smile:

About the Q factor, the thing is all the changes made on amplitude in standard filter topologies, thanks to the Q factor, have also an impact on phase, even if they are less important and understandable.

So for the all-pass filter specifically, the more important the Q is, the faster the phase response goes from 0° to -360° as we increase the frequency around the cutoff frequency. It’s difficult to describe the result without listening to it… Try to mix the output of an all-pass filter with its input, you’ll see that the cutoff frequency and Q factor have very significant impact on the sound. I would say that the higher the Q is, the less significant the “phasing effect” will be in this particular case.


#7

Thanks @IvanC really useful stuff :slight_smile:


#8

So, would it be possible to update JUCE IIRFilter class with my additions ? Thanks in advance @fabian @jules @timur :slight_smile:


#9

Hi IvanC,

Sorry for the delay. I was travelling. This looks great! I’ve cleaned it up a bit and pushed it to develop.

Fabian


#10

Thanks Fabian :wink: