# How can I design a very narrow filter?

Suppose I've got an audio signal sampled at $48000$ Hz, and I'd like to design a low-pass filter that isolates everything below ~$60$Hz. In the digital world, this is a low-pass filter with the passband at $[-\frac{\pi}{400} , \frac{\pi}{400} ]$. Also, the transition band should be reasonable as well. Building a FIR filter for this can have a lot of taps which in the long run affects precision. An IIR filter is too not ideal because audio suffers for non-linear-phase response in filters, so unless the signal is filtered, then reversed and filtered again, it is not really an option.

Could a wavelet transform be better at this than in-one-go regular filtering?

• Is there a reason you don't want to decimate? – Lorem Ipsum Aug 31 '11 at 0:31
• No, decimating is fine as long as I get what I want. – Phonon Aug 31 '11 at 1:26
• What is a "reasonable" transition band? That's going to determine the order of your filter. If your stopband starts at 300 Hz, for example, you're probably in pretty good shape. If you want high attenuation at something like 60.1 Hz, then it is going to be long. Long FIR filters aren't necessarily bad though, – Jason R Aug 31 '11 at 2:25
• You need an actual filter specification otherwise the question is meaningless. State the acceptable passband ripple, stopband rejection, width of transition band, etc. – Paul R Aug 31 '11 at 10:16
• Makes sense. Will do. – Phonon Sep 1 '11 at 15:55

If you are optimizing for engineering time and are on a platform that supports large FFTs well (i..e not fixed point), then take hotpaw2's advice and use fast convolution. It will perform much better than a naive FIR implementation and should be relatively easy to implement.

On the other hand, if you have some time to spend on this to get the best implementation or are on a fixed-point platform, you should use a multirate down-filter-up-subtract structure. But it's a bit trickier to get everything right.

I've got access to trusted and highly optimized implementations of both fast convolution and multirate filtering tools. The fast convolution takes about 3x longer to get equivalent signal performance compared to the multirate structure. Furthermore, that is even on a floating point platform. The gap would widen considerably on a fixed point dsp.

In general terms:

## Down-conversion:

Use 8 stages of halfband,decimate-by-2 filters to transform your 48kHz signal into a 187.5 Hz signal. The first stage of this downsampling can have a very wide transition band, allowing energy to alias as long as it doesn't alias back into the sub 60 Hz range. As the stages progress, the number of taps needs to increase, but they will be applied at a progressively lower sampling rates, so the overall cost of each stage remains small.

## Filtering:

Perform your tight filtering around the 60 Hz bw to keep the energy you will eventually want to subtract. There is a double advantage to doing your tight filtering at the low rate:

1. 1Hz of transition bandwidth is 256 times larger in terms of digital frequency at the low rate vs. the original rate. So every tap of your filter is 256 times as powerful.
2. The signal itself is at a lower rate, so the filter only needs to process 1/256 the data.

## Up-conversion:

Essentially, this is the reverse of the decimation stages. Each of the 8 interpolator stages doubles the rate by estimating the sample that goes between consecutive input samples. The transition band gets wider as the sample rate gets higher.

## Subtract:

Subtract your full-rate low-pass filtered signal from the original signal. If you've adjusted for all the group delays properly, the overall structure will be a highpass filter with a narrow transition bandwidth.

Try an overlap add/save convolution filter with the longest FFT/IFFT that fits your latency and computational performance constraints. You can design extremely long FIR filters when using this method with even longer FFTs.

If you can FFT the entire song, or your entire audio signal file, in one very long FFT+IFFT (there are special FFT algorithms for long vectors that don't fit in dcache or RAM), you won't need to do any overlap add/save processing, and you can get a very narrow transition band.

There are clearly two choices: FIR & IIR. As already stated FIR requires a VERY long (1000s of taps) impulse response and is expensive in terms of memory, MIPS & latency with overlap add/save being the most efficient choice. However, latency can be a real issue. If you want to use that as a high pass for a home theater subwoofer, the latency will be so high that you will be losing lip synch with the video.

IIR is several orders of magnitude less expensive and therefore frequently used. It does indeed have a non-flat phase response but in many cases this is not a problem or can be worked around. For example if you need a high pass filter to protect the drivers in a bass box, the phase response is not very important as the overall system phase response is dominated by the driver, the enclosure and the acoustics in the room. The filter plays only a minor role here. In many cases you also need to maintain "relative" phase not absolute phase. Let's say you want to apply the highpass on signal A but not on signal B, you can simply put a matching allpass on signal B so that the relative phase of A and B stay the same. The overall latency & group delay of this approach is still a lot less than that of the FIR method.