Study Hall

A Useful Tool: Creating & Applying FIR Filters

Along with solid electro-acoustic design practices, reach new levels of...

In part 1 of this article series (here), I laid out a few guiding principles regarding Finite Impulse Response (FIR) filters. Here’s a quick review:

1) With FIR filters I can have very steep LP and HP filters, such as might be used in a crossover network, that have linear group delay (same delay for all frequencies).

2) The magnitude and phase response of a FIR filter can be adjusted independently. In an Infinite Impulse Response (IIR) filter they are interdependent – you can’t change one without changing the other.

3) WAV impulse responses by definition are FIR filters, since they are fixed in length and cannot (theoretically) decay for infinity. Any IR you measured can potentially be used as a filter.

So, let’s create some FIRs.

Creating The FIR Filter
I created my FIR filters in software, using the freeware rePhase to define a high-pass filter (HPF) and low-pass filter (LPF) based on a few input variables (Figure 1). You’ll want to add rePhase to your toy box for investigating FIRs. (I’ll show some other FIR-creation tools in future installments of this series.)

Figure 1 – FIR filters generated with rePhase.

I’ll create a 1 kHz brickwall HP filter. FIR filters are defined by the number of “taps.” This is a way of specifying the length of the impulse response. The number of taps is equal to the number of samples.

Basically, the more taps, the more samples, the longer the time length, and the greater the precision. The greater the precision, the greater the “sharpness” that can be attained in the frequency domain. Just as you need a long time window to resolve low frequencies when performing acoustical measurements, you need a lot of taps (long IRs) for detailed low frequency FIR filters.

Let me demonstrate. Figure 2 shows the response of a 60 tap, 1 kHz HPF, the response of a 600 tap HPF, and the response of a 6000 tap HPF. Clearly, the 6000 tap filter can be described as “brickwall.” That’s the one we want, right? This is audio, and you never get something for nothing.

Figure 2 – At the top we see a 60 tap FIR HPF. Note the lack of sharpness due to the small tap size. Next, adding more taps (more samples or a longer time length) creates a sharper filter, and then at the bottom, we have a 6000 tap filter that is 136 ms in time duration, with latency of 1/2 of the length (68 ms).

The latency through an FIR is one-half the number of taps, so the signal through this filter will be delayed by 3000 samples. At 44.1 kHz, that’s a bit over 60 milliseconds (ms). While that might be acceptable in a home playback system, it might as well be next week for live sound. I’m going to stay with this to illustrate the concept, but in the real world we’d have to give back some of the precision to reduce the latency.

I created a 1 kHz LP filter in the same manner. Since these brickwall filters essentially do not overlap, I don’t have to worry about how they interact. Filter interaction is a main concern for analog and IIR digital filters.

These are “brickwall” filters that produce no frequency-dependent delay. Note how wacky the phase response gets in the stop band. That’s because the magnitude response is down about 80 dB. If there is no magnitude response (i.e., no signal output from the filter), then the phase is meaningless and looks like garbage.

rePhase allows the filters to be saved in multiple formats, including WAV files (Figure 3). They can be convolved with any audio signal in real time or as a post process.

Figure 3 – The FIR generation and export settings in rePhase.
We’ll need some hardware to do the convolution in real time. I saved them as 32-bit IEEE-754 mono .bin files, and dropped them into a miniDSP OpenDRC 2×2 to allow measurement and listening (Figure 4). This DSP can handle FIRs up to 6144 taps, so the 6k tap filter just makes it.
Figure 4 – The software GUI for the miniDSP OpenDRC 2×2.
This is a very simple FIR, for illustrative purposes. It can actually have a very detailed shape, including corrective equalization filters. One FIR filter can replace a whole bank of parametric EQ filters along with HP and LP filters. It’s like having one super-duper filter rather than a bunch of simple ones.
Study Hall Top Stories