Forums

Filtering of complete sample - FIR versus IIR versus FFT

Started by Ross Clement (Email address invalid - do not use) February 17, 2006
Hi. I have some quite long samples. I would like to produce filtered
versions of these. Originally I used a FFT to do this. I would fft the
entire sample (e.g. 20 seconds of 44.1khz mono 16-bit sound). I would
then (for lowpass filtering) zero the magnitudes in the stop band and
leave the phases alone. I would then inverse FFT to get the filtered
sample back again. Using the fftw3 library on even modest hardware was
easily quick enough for my needs.

A colleague advised me to use FIR filters. However, to do some of the
filtering I would like to do, this forces me to use very long FIR
filters. E.g. if I used a FIR filter with 91 taps, then it's difficult
to get a filter with a resolution of cutoff frequency within say +/-
10hz, which would be my desired resolution. However, if convolution in
the time domain equals multiplication in the frequency domain, then
isn't my original method equivalent to using very long FIR filters
(since I have about 882000 samples in a typical audio sample). In any
case, in terms of setting magnitudes of frequencies to 1 or zero, I get
good resolution if I FFT the whole sound, and it's also quite quick to
do things this way.

Though, in my original implemention of filtering in the frequency
domain, I didn't apply any windowing. I presume that to improve the
quality of the filtering I get I should apply a suitable window before
the FFT, and then undo the windowing after the iFFT. Is this correct?
Can't I do filtering as good as a FIR filter in the frequency domain?
If not, why not?

My alternative will probably to use IIR filters (e.g. Butterworth) in
forward and then reverse directions as recommended in another thread to
get zero phase shift.

Cheers,

Ross-c

Ross Clement (Email address invalid - do not use) wrote:

> Though, in my original implemention of filtering in the frequency > domain, I didn't apply any windowing. I presume that to improve the > quality of the filtering I get I should apply a suitable window before > the FFT, and then undo the windowing after the iFFT. Is this correct? > Can't I do filtering as good as a FIR filter in the frequency domain? > If not, why not?
You certainly can. You just need to be aware that you probably have time-domain aliasing if you started with 882000 samples and ended with the same number in the frequency domain. What's happening is you're effectively convolving your 882000 samples with an FIR filter of length 882000... so the output length using convolution should be 2*882000 - 1. Because, when using the FFT, you're actually using circular convolution, you're going to get some (much?) overlap at each end of the signal. If you zero pad your 882000 samples to longer than 2*882000 - 1, your approach should be OK. However, just because you're setting zeros and ones at all bins doesn't mean that the filter's frequency response is only zero or one... you might be surprised to see what it is. Hope that's not to cryptic. Ciao, Peter K.
Actually, that makes huge amounts of sense. It overlaps with a number
of things I read recently, explained a slightly weird resonant noise I
could hear in my filtered sounds, and gives me a very simple method of
solving the problem.

Thanks,

Ross-c