Convert IIR to linear phase FIR

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi,

I want to convert a IIR Filter into a linear phase FIR with the same magnitude response.

One method is, to just take a impulse response (filter 1 sample impulse) and then reverse it, and filter it with the same IIR again.

But then the magnitude is squared, because the filter is applied two times (forward/backward)

How can I square root the magnitude?

Maybe :

ForwardFFT -> transform magnitude (square root)* -> InverseFFT

*But how i exactly do this?

Post

No need to do that. Just sample the impulse response, take an FFT, zero the phase term, iFFT and swap halves of the FFT window.

Post

Thanks, sounds reasonable.
zero the phase term
Do you mean, zero the imaginary part, or how i do it?

Post

No, zeroing the phase means setting the real part to the magnitude value (Sqrt(Re^2 + Im^2)). That'll zero the phase term while maintaining magnitude.

You can also make every odd bin value negative before doing the iFFT, that way you don't have to swap the frame halves afterwards.

Post

>No, zeroing the phase means setting the real part to the magnitude value (Sqrt(Re^2 + Im^2)).
Thank you very much for taking the time to answer me :-)


Does the imaginary part remain, or do I have to replace it with zeros?



Also, before i do the first FFT, i think i have to put a window on impulse response (because its infinite)

So is it okay, to fill the input array of the FFT with the full IR (from the beginning on, zero padded) and multiply it with the second half of a window function (because it already begins with silence)

or

Put the IR in the middle of the input array (begins from the center) and multiply with a full window, for best precision.

Post

Read this, it covers all your questions http://www.dspguide.com/ch17.htm
~stratum~

Post

Hi Stratum,

thanks for your advice, i know this book, i know how to make a custom filters, which is basically the second part of the answer of my first question (using the magnitude as real) but it not covers my all *very specific* questions, from my last post. Maybe I'm just too stupid, so basically i want to go sure.

I want to convert a IR of an IIR into a linear phase FIR.

I put the IR (which i made from the IIR) into a buffer (the longer the buffer is, the better result).

One question was, whats the effective way of doing it? For best speediness and accuracy.
I have to fade-out the IR somewhere, if not, i have a high frequency peak.

Than after the FFT, i use the magnitude as real and zero as imaginary part(i guess), and use the same method (custom filters) as mentioned in the book (or make every odd bin value negative, to save the swap)

Post

chipnix wrote: Than after the FFT, i use the magnitude as real and zero as imaginary part(i guess), and use the same method (custom filters) as mentioned in the book (or make every odd bin value negative, to save the swap)
Yep, that's basically it. For the windowing: yes, you should window the original impulse response, which will alter the result a bit. But if the IR is long enough, you might not need to. The lower the impulse response level at the end of the buffer, the better. If you can make it long enough so you don't cut much away at the end, it's usually better to go with rectangular window, because the rest isn't affected. If you cut a significant amount of information, you should use a smooth window to make the artifacts a bit nicer.

Post

Great thanks!
I think i've got it.

Post

Do not forget to test the filter as described in the book as the method depends on the *inability* of a short impulse to match the sampled spectrum. If the impulse you use is too long, it may not match the spectrum you want. If it is too short, this time the bass part will not match.
~stratum~

Post

> If it is too short, this time the bass part will not match.

I agree! Also the smaller the kernel, the less steep a filter can be.

> If the impulse you use is too long, it may not match the spectrum you want

As i understand, its important that the FFT-size which is used to calculate the FIR kernel, must be higher than the used filter kernel itself. From that point, i think there is no problem to use very long filter kernels (they will be just more precise), as long the used FFT-size is as many times higher than the filter-kernel itself.

Post

As i understand, its important that the FFT-size which is used to calculate the FIR kernel, must be higher than the used filter kernel itself. From that point, i think there is no problem to use very long filter kernels (they will be just more precise), as long the used FFT-size is as many times higher than the filter-kernel itself.
Ch17 states that that extra precision will be a problem at some point because the filter specification is samples at frequency domain. Points between the samples are not specified. Your approach may be a solution, as it makes sense, but make a test in any case by zero padding as described.
~stratum~

Post Reply

Return to “DSP and Plugin Development”