# Use of FIR Filters For Audio Practitioners

## Audio Practitioners Will Be Given a Basic Introduction of FIR Filter Generation For Audio Systems

*by Hadi Sumoro and Xian Yu – www.HXAudioLab.com*

### Introduction

Electronic correction in the form of Equalization (EQ) is one of the most useful audio tools for loudspeaker compensation/correction, whether it compensates from non-linearities in the loudspeaker or for altering the effect of room acoustics. Two audio filter types are typically used: IIR and FIR. IIR stands for Infinite Impulse Response and FIR stands for Finite Impulse Response. Each has its own pluses and minuses. This article intends to introduce key terminologies and outline few basic uses of FIR filters for audio system optimization. The audio practitioners will find this information useful.

The IIR filter is based on the idea of an analog/passive filter and has minimum phase characteristics. An example of a passive crossover typically found in a loudspeaker is shown in figure 1. The IIR filter is common and can be used in the passive/analog domain and in a digital signal processor (DSP). Several common terms that relate to IIR (some relate to FIR too) are: passive/analog crossover, minimum phase filter, analog graphic/parametric EQ. FIR filters on the other hand are commonly implemented in the digital domain.

### Phase Response

An IIR filter has a minimum phase characteristic. Minimum phase is a condition where the phase response and frequency response are related by the Hilbert Transform (predictable from each other). In IIR, changes in frequency response will produce changes in the phase response. The minimum phase response is the least amount of phase shift possible for a given magnitude response.

A digital IIR filter is setup as shown in figure 2, containing a high pass filter (HPF) at 60Hz, Butterworth 12dB/oct, a low pass filter at 12500Hz, Butterworth 12dB/oct, a -3dB 1/3oct wide peak EQ at 300Hz and a +3dB 1/3 oct wide peak EQ at 3000Hz. This table is a screenshot from Filter Hose.

The reader can observe the transfer function (figure 3 – right) and the zoomed filter’s impulse response (figure 3 – left).

Figure 3 – the right graph shows the frequency response (red curve) and the phase response (green curve) of the IIR filter. As previously discussed, the changes in magnitude are followed by changes in phase, thus the phase response has its own shape. Figure 3 – the left graph shows the filter’s impulse response which has a peak very close to 0ms. Typically, there is minimal processing delay introduced by an IIR minimum phase filter.

Side note: Not all IIR filters are minimum phase. All Pass Filters are non-minimum phase IIR filters.

An FIR filter can also create a similar transfer function as shown in figure 3. Figure 4 is an FIR filter created using 48kHz sample rate and 1024 taps. Although an FIR filter can be created as minimum phase, but what is powerful with FIR is the ability to independently control the frequency and phase responses. This is what is commonly called a linear phase FIR filter.

Figure 4 – the left graph shows the filter’s impulse response. Since the peak of the impulse response is located at 10.65ms, this shows a processing delay caused by the filter. In other words, the output will be delayed by an additional 10.65ms, which can be too long for live stage monitoring or overdub recording but can be acceptable for audio mastering or music listening use (without video).

Figure 4 – the right graph shows the transfer function of the FIR filter with the processing delay removed by cyclic shifting the impulse response for easier viewing. The reader can observe the phase response that is flat at 0deg (there is no phase shift caused by the filter) and the frequency response is similar to figure 3 – right.

### Digital FIR Filter Properties

In the digital world, sample rate (fs) is one of the most limiting conditions to recognize. The FIR filter depends on the sample rate of the hardware/software. One can’t just change the sample rate of a filter and expect the same result.

As the name implies, an FIR filter has a finite duration or a certain number of taps. An FIR’s tap is simply a coefficient value and the impulse response of an FIR filter is the filter’s coefficients. The number of taps (N) is the amount of the memory needed to implement the filter. More taps mean higher frequency resolution, which in turn means narrower filters and/or steeper roll-offs.

Frequency resolution = fs / N.

By dividing the sample rate by N, a practitioner is able to calculate the frequency resolution of the filter. In the example above (figure 4), the FIR is created using 48kHz sample rate and N=1024. This yields a frequency resolution of 46.875Hz. For a quick and rough estimation, we can multiply the frequency resolution by 3 (three) to predict the effective low frequency limit of the filter. 46.875Hz x 3 ≈ 141Hz. This means an FIR filter with fs = 48kHz and N = 1024 will be effective at 141Hz and above. This is just a quick and rough estimation based on a sample rate and number of taps, however other calculation parameters or filter editing will heavily affect the final result.

To create a steep high pass at low frequency (below 200Hz), one may require a high N value which may not be practical. Therefore it is common to implement a HPF as an IIR filter in addition to an FIR filter.

### Filter’s Processing Delay

Another important factor is editing the filter. Figure 4 shows the FIR filter with 10.65ms processing delay. When the location of the filter’s impulse is cyclic shifted and appropriate windowing is performed based on the new impulse location, the result filter’s transfer function may change. Please observe figure 5 (with 6ms processing delay), figure 6 (with 3ms processing delay) and compare them to figure 4 (with 10ms processing delay). All phase response curves in figure 4, 5 and 6 are observed by cyclic shifting the filter’s impulse response peak to 0ms.

The reader can observe how the low frequency roll off changes and how the phase is not as flat in the low frequency region. In general, FIR filter can work effectively to do correction for frequencies below 100Hz if a long processing delay can be tolerated. Here is another example of a 3-way horn-loaded loudspeaker measurement. The loudspeaker’s transfer function is shown in figure 7.

Two FIR filters (fs = 48 kHz, N = 2048, frequency resolution = 23.3 Hz) are created using different processing delay to linearize the loudspeaker’s phase response only, without affecting the frequency response of the loudspeaker. Figure 8 and figure 9 are showing the filter’s transfer function (left graph) and the calculated output (right graph).

Figure 8 shows the result of a filter with 30ms processing delay. The filter’s frequency response is mostly flat with a little bit of dip around 45Hz. This setup will work nice to linearize the phase response of the loudspeaker system. However, if we shorten the processing delay to 10ms in the filter creation process, the result will be very different.

Figure 9 – the left graph shows the filter’s transfer function with 10ms processing delay. Observe a drop starting at 80Hz in the filter’s frequency response. The right graph shows the predicted result of the loudspeaker where the phase response is successfully flattened, but the low frequency response does not extend as low as the original loudspeaker’s response shown in figure 7.

### Windowing

FIR has a finite duration as the name states. Therefore in the creation process, an audio practitioner needs to define where the finite points are. FIR filters are not very good at handling specific frequency response (especially low frequency) because one needs to truncate the impulse of the FIR filter (hence it’s called finite). The act of further truncating is called windowing.

Typically, FIR filters are calculated based on an ideal filter and are then truncated. Here is several illustrative examples about windowing processes.

Figure 10 shows what is commonly called a rectangular window. The window weights all values evenly inside the rectangle/window and the truncation is likely to be abrupt at the end of the filter. This can cause ringing or add other coloration to the sound outside the intended use of the FIR filter. The rectangular window can be useful in specific occasions, but tapering the edges of the filter’s impulse response to smooth out any discontinuities is generally recommended.

Figure 11 shows Hann windowing. The windowing process does not just cut the tail based on the length we want, but also tapers the tail of the filter. The coefficient’s values go to zero at the end of the tail.

Processing delay and windowing setup/editing process are very important to the final result of the FIR filter.

### Creating FIR based on Measurement

Creating an FIR filter in order to create a conjugate of the transfer function, frequency response only, or phase response only is becoming popular as the FIR-capable DSPs are more widely available. Software such as Filter Hose can help users define an FIR filter based on measured data to create a conjugate filter or create a custom FIR filter (the latter is typically done for creating crossover or targeting a specific curve, not discussed in this article).

Several FIR filter applications whose purpose is to create a conjugate of a measured data are as follows:

**1. Creating a conjugate for a single measurement point**

For a one person listening spot (such as studio use), one measurement can be taken at the sweetspot position from each loudspeaker. An FIR filter can be developed to create a conjugate of the transfer function at that point. This is useful to smooth out room effect and improve several loudspeaker non-linearities. The filter has many data points but it is for a unique position in space.

**2. Flattening spatial averages or power response
**

By measuring the frequency response at different listener’s positions, one can average the frequency responses. This should be done per loudspeaker and good results can be achieved by averaging the frequency response at more than three locations. Averaging should not include phase response, only the magnitude.

The measurement can be taken simply by using an RTA. This is another useful way to compensate for the room’s modal behavior in a home theater environment, music listening room, or for sound system optimization for commercial/public places.

**3. Loudspeaker correction**

To properly create a loudspeaker correction, a controlled measurement environment is required. Control in this context means controlling the amount of reflected sound that is captured in the measurement. The simplest and most effective way to do a good loudspeaker measurement is to do an outdoor ground plane measurement under supportive weather conditions or in a very large room. By placing the loudspeaker and mic on the reflective and smooth ground, one can get a good measurement data without a destructive interfering reflection from the floor. When creating an FIR filter to linearize the phase response of a loudspeaker, its best to use measured data from a controlled measurement environment.

**4. Combination**

There are many possibilities to measure a loudspeaker and create FIR filters. One can create a loudspeaker correction using the outdoor ground plane method and create an FIR filter to linearize the loudspeaker’s direct field response. Then bring the loudspeaker inside the room and measure several spots in the room to create a power response/modeal compensation. The two filters can then be convolved/combined. Just like combining IIR filters, several FIR filters with different functions can be combined too.

FIR filters are produced very differently than IIR filters. Both have pluses and minuses and the final result will depend on the intentions of the filter’s creator.

As you can see from this article that FIR Filters is another useful tool for the audio practitioners.

We would like to thank Pat Brown (www.ProSoundTraining.com) and John Loufik for their insights and for reviewing this article prior to publication.