• Welcome to ASR. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

IIR Filter design

caustik

Member
Audio Company
Forum Donor
Joined
Feb 4, 2025
Messages
23
Likes
41
I've been working on filter design quite a bit lately. Didn't come from an audio engineering background but pivoted from a ~25 year mostly-video software career a few years ago

I'm working on IIR filter design right now and trying to find a highly precise IIR filter design workflow. Unlike FIR, minimization techniques can really struggle with IIR as it's a vast space of many local minima so it's difficult for the algorithms to jiggle their way out and find something close to ideal. I have very strict tolerances, and the last mile is the hardest. Fortunately some IIR filters have known solutions in official specification papers, and if you're lucky it's for arbitrary sample rates. Others, like ECMA-418, only specify one sample rate (48khz) and the solution doesn't easily carry over to others. Something phon-dependent like ISO 226, well good luck.

The past few days, I've been messing around with REW. I was able to get a great "initial guess" for my scipy minimization filter design script by loading a blank filter, setting it as measurement, then loading ECMA-418 frequency response data and having it fit a parametric EQ. With low/high shelves enabled, it gets a really good approximation. From there, the scipy minimization algorithm with some churning has actually put the resulting filter within tolerance. The objective function is given the parametric EQ bands which seems to generally work better than optimizing biquads.

That's exciting, but it isn't scalable. I have many more filters to design and the process is tedious and non-deterministic (AFAIK, REW has no scripting language or other way to automate).

Anyway, maybe someone with experience in this realm will read this and chime in if you have an approach which works or might work. Figured I'd think out loud in the form of a mini-blog thread.


1750540016602.png
 
Last edited:
Just checked and the CLI contains maxTime, minChangeRate, and minStd variables which you can configure to meet your tolerances.
 
Do you have both magnitude and phase for your target frequency response? If you have both, then: https://elec3004.uqcloud.net/2014/lectures/Precise Filter Design (chapter).pdf

Matlab or C code available from me. I think I even have a Python version around here somewhere.

That's awesome! thanks for sharing.

I have only frequency and magnitude pairs right now, but maybe I can extract phase from the FIR filters which are already designed and fit the tolerances tightly.

That'd be great if you happen to have a Python version around! That or C would work since I could just create a little wrapper around the C or something.
 
Last edited:
Jeez, this forum is incredible. Thanks, I'll have to check this out as well. Going to be a busy week for me lol
I don't know what you want to do.

Here's a tip that might work for you.

Under "octave" there's a library ("signal")that contains a lot of tools for creating filters.

You won't get the same results as with REW in real time,
but it works pretty well on *.wav files played by Octave.


IIR_octave.png
 
I have been using DSP software "EKIO" which uses IIR filters.
The processing is done using a cascade of second order transposed direct form II biquad sections.
Every calculation is done using 64-bit floating point numbers.

If you would be interested, you can find my latest system setup here #931 on my project thread.
My recent post #1,009 would be also of your interest and reference, I assume.
 
I have only frequency and magnitude pairs right now, but maybe I can extract phase from the FIR filters which are already designed and fit the tolerances tightly.
if you design minimum phase filters then you only need the magnitude response.
 
both IIR and FIR filters can be non minimum phase. both can also be minimum phase. So we cannot deduct from the fact that the target is FIR.
 
both IIR and FIR filters can be non minimum phase. both can also be minimum phase.
Of course. But there is a tendency to design FIR filters to be linear phase, simply because it's possible. So the fact that the prototypes are FIR leads one to at least suspect that they might also be linear phase.
 
Target curve mag and phase, needs to be defined before either IIR or FIR filter strategies have meaning, imo.
(And max acceptable latency must be specified.)

Will add, personally I'll no longer fool with any arguments about resource constraints, in terms of what's optimal under the constraints. Seems silly today....

Last comment. IIR is a bitch !!!
 
IIR are more complex and powerful than FIR (FIR is a subset of IIR).
 
a long FIR kan approximate an IIR. with several 100k tap FIR you can do almost anything except filters with very low frequency features, eg a 1Hz high pass. However, that is also difficult for IIR due to quantisation noise issues. There are pros and cons…
 
Of course. But there is a tendency to design FIR filters to be linear phase, simply because it's possible. So the fact that the prototypes are FIR leads one to at least suspect that they might also be linear phase.
maybe but in that case good luck doing a phase linear IIR filter. Phase linear requires a symmetric impulse response. IIR has a pole and a zero part and the pole part give asymmetric impulse responses. Hence, phase linear is a pure FIR thing
 
Back
Top Bottom