dsp::FilterDesign: no high order highpass, bandpass, bandstop?

I’ve been reading up on the dsp::FilterDesign and dsp::IIR:Filter classes. Lots of yummy stuff in there, but I feel like I’m missing something. The high order design methods are all low pass (excepting designIIRHighpassHighOrderButterworthMethod()). Are there some transformation methods hidden away somewhere?

You can cascade filters in serie to get higher orders.

I cannot find a good way to cascade 2nd order Butterworth bandpass/notch to achieve high-order Butterworth bandpass/notch. Instead, I cascade 2nd order filters so that the magnitude response at the cutoff freq is -3dB. However, the response within the bandwidth is not flat enough.

BTW, when you cascade filters, you will need some filters at some extreme Q values. You may want to decramp the filter to get some reasonable results at >5kHz.

You can cascade filters in serie to get higher orders.

That’s exactly what these filter design methods do; they return the coefficients for each second order filter in the series required to meet the design spec.

The problem is that we only really have designs for LPFs. We don’t appear to have any transformations for high pass, band pass etc. Not unless I missed something!

To convert the LPF kernel to HPF, change the sign of every coefficient and add 1 to the center coefficient.

To create a bandpass filter, you can create a new kernel by convolving an LPF kernel with an HPF kernel. (Or simply have these two filters in cascade.)

To create a band-reject filter, you can add up the LPF and HPF filter kernels. (Or simply have these two filters in parallel.)

It would be nice if JUCE had code for this but it’s also not that hard to write this yourself.

2 Likes

To convert the LPF kernel to HPF, change the sign of every coefficient and add 1 to the center coefficient.

That doesn’t seem to work, are you sure you’re remembering it right? Seems like a simple mirror transformation without transforming the frequency. I suspect your suggestions can result in filters of the right type, but they won’t match the design specs of the original filter.

EDIT: doh, I just realised you’re probably talking about FIRs, whereas I’m looking at the IIRs…

You may refer to the info here: Cascading filters | EarLevel Engineering

Here is the code using the above method. Not accurate for high-order pass filter with Q not equals to 0.707, but good enough for me.

Thanks Liu, I’m aware of Nigel’s excellent blog and I also know and use another library which performs these transformations. What I was asking in my original post was whether there was support for these transformations in JUCE (i.e. without having to do it myself or import other libraries).

BTW, your ZL Equalizer looks gorgeous - nice work!

Got it. No, JUCE does not provide such method natively. And if you allow users to modulate the parameters, I would suggest writing your own implementation because the original designIIRLowpassHalfBandPolyphaseAllpassMethod allocates memory as far as I can tell.

Oh my bad, I thought you were talking about FIRs indeed.

It would have helped if I mentioned that first up :squinting_face_with_tongue:

Thanks for responding though - that little nugget will probably come in handy for someone at some stage!