DSPRelated.com
Forums

Fit biquad to 5 frequency response points?

Started by Unknown December 2, 2016
On Sun, 4 Dec 2016 03:18:01 -0800 (PST), thejohnflynn@gmail.com wrote:

>I have an audio EQ filter that deviates from some ideal. > >This deviation is gentle but arbitrary. I have an mag/phase expression for the deviation (so I can take 'match point' measurements anywhere I want). > >I'm looking to correct this deviation, yielding a filter that matches the ideal. > >If I go down the FIR route, what options do I have for matching arbitrary responses? Both magnitude and phase?
If the deviation is minimum phase, then you can compute an inverse transfer function that is stable. Of course, you have to have the transfer function (poles and zeroes) before you can invert it. Note that in general this will not be a FIR filter. If the deviation is nonminimum phase, then you can use a FIR filter to approximate the inverse, but you will introduce delay in the process. That delay may or may not be a problem for you. Another possibility is the aforementioned FDLS (Frequency Domain Least Squares) approximation technique. There are no FDLS constraints upon stability, but if the "deviation inverse" frequency response turns out to be unstable, then the approximation will be unstable, too. Oh, for FDLS the "deviation inverse" must also be causal. Send me a PM if you want FDLS info and sample Matlab or C program. Change "chatter" to "charter" and remove "invalid". Others are welcome to do the same.
Greg, it's very reassuring to leave this forum, study the literature and experiment, come back to a post like this and see that I've been working along the right lines. Thank you.

> Of course, you have to have the > transfer function you can invert it.
Apologies, I don't have the transfer function of the error curve. The ideal filter is in the S domain.
> Another possibility is the aforementioned FDLS (Frequency Domain Least > Squares) approximation technique.
Now this is really helping. Using FDLS with 8 measurements to give a 7 zero correction filter I get _extremely_ good results. (-60dB magnitude error. And very useable results with lower settings). Are there any other FIR methods I should be looking into? For low-zero correction FDLS seems to have it covered. But also, for example if I wanted to do an 'total overkill' match. 64, 128, 256 zeros and higher. Is there a method where I could 'pin down' the response exactly at 64, evenly spaced points? (That also behaves pretty well between the points). Thanks, John.
On Sunday, December 4, 2016 at 12:50:28 PM UTC-6, thejoh...@gmail.com wrote:

> Using FDLS with 8 measurements to give a 7 zero correction filter I get _extremely_ good results. (-60dB magnitude error. And very useable results with lower settings).
Understand that FDLS is more typically, and more preferably, used with hundreds or thousands of frequency response measurements. In addition to MA (FIR) models, it can create AR (all pole) models or ARMA (IIR) models. In fact, ARMA is the most commonly used configuration.
> Are there any other FIR methods I should be looking into? > > For low-zero correction FDLS seems to have it covered. But also, for example if I wanted to do an 'total overkill' match. 64, 128, 256 zeros and higher. > > Is there a method where I could 'pin down' the response exactly at 64, evenly spaced points?
Yeah; the inverse DFT.
On Sunday, December 4, 2016 at 6:18:09 AM UTC-5, thejoh...@gmail.com wrote:
> > I have an audio EQ filter that deviates from some ideal.
what is the ideal? do you have a prototype EQ or target response defined? ...
> If I go down the FIR route, what options do I have for matching arbitrary responses? Both magnitude and phase?
if causality isn't needed, you can do whatever magnitude and phase you want. Eric Jacobsen suggested a quick and dirty idea in the previous millennium. http://dspguru.com/dsp/tricks/using-parks-mcclellan-to-design-non-linear-phase-fir-filter to make it causal, add delay. r b-j
On Sun, 04 Dec 2016 03:18:01 -0800, thejohnflynn wrote:

>> there's no guarantee that Really Bad Things wouldn't happen > > Indeed this is what I've discovered! > >> I think the OP needs to step back a bit and ask what he _really_ wants >> to accomplish > > I have an audio EQ filter that deviates from some ideal. > > This deviation is gentle but arbitrary. I have an mag/phase expression > for the deviation (so I can take 'match point' measurements anywhere I > want). > > I'm looking to correct this deviation, yielding a filter that matches > the ideal. > > If I go down the FIR route, what options do I have for matching > arbitrary responses? Both magnitude and phase? > > Ultimately this will be realtime parameter controlled C++ software. > > Thanks all, for the enlightening discussion! > John.
Assuming that you can add arbitrary amounts of delay to your signal, the brute force way to do this is to do an inverse DFT (which ends up being an inverse FFT in most reasonable systems -- an FFT is just a fast DFT). It may not be the shortest-time way to do the job, but it'll always take the same amount of time, which is desirable in a real-time system. The algorithm becomes: (1) determine your desired frequency response, (2) window it, symmetrically around f = 0, to limit the extent of the time response, (3) do an IFFT, (4) shift the IFFT so that your filter is causal, (5) use the result as the set of taps in an FIR filter. The hardest part will be automagically figuring out the proper amount of shift, and making sure you have enough taps so that the impulse response has mostly died off before the end of the FIR (if you don't do this, then the tail end of the filter response will bleed into the beginning, because of the nature of the DFT). -- Tim Wescott Wescott Design Services http://www.wescottdesign.com I'm looking for work -- see my website!