Part II: Digital Filters

In this section digital filters are configured as an audio system 3-way crossover. The concept is that the filter would get a digital input from a CD player, feed 3 digital-to-analog (D/A) converters, which feed 3 analog stereo channels.

It is important to realize that a digital filter is a completely different animal than an analog filter. The order of an analog filter directly determines the slope (dB per octave) of the filter attenuation beyond cutoff. The number of taps of a digital filter are related to the slope, but the slopes are very dependent on the cutoff frequency. For a given sample rate, a high-pass at 300 Hz requires twice as many taps as a high-pass at 600 Hz, to achieve the same slope. And for a 300 Hz high-pass it takes almost 40 taps to provide the same slope as a 4th order analog. For a given number of taps, high-pass and low-pass filters have different slopes. It is easy to to achieve a perfect phase response with a digital filter, and impossible to achieve with any analog filter of order greater than one. It is possible to emulate a analog filter response with a digital filter if you want, but why?

For theory underlying digital signal processing see Part I: Fourier Transforms and Sampling.

Part II consists of:

Types of Digital Filters

The input xn and output yn sequences of a digital filter both represent signals sampled at discrete, uniformly spaced, time increments tn. A finite impulse response (FIR) digital filter takes N+1 of the most recent input samples of xn, multiplies them by N+1 coefficients, and sums the result to form yn. For an infinite impulse response (IIR) filter, the M previous output samples of yn are weighted and added in as well. In other words, an IIR filter uses feedback. This is expressed mathematically by All of the a's are zero for a FIR filter. The main advantage of IIR filters is that they can produce a steeper slope for a given number of coefficients. The main advantage of FIR filters is that the group delay is constant. This provides the capability of obtaining both a steep cutoff and perfect phase response. This is impossible to achieve with an analog filter.

Filter Transfer Functions and the z-transform

The frequency domain response, or transfer function can be obtained from a z-transform, which is defined by With r=1, equation (2) is the discrete Fourier transform of y, so evaluating Y with r=1 yields the frequency response. Using the fact that The z-transform of equation (1) is Then the transfer function is given by Comparison of One Analog and Three Digital Filters

A comparison of one analog and three digital low pass filters illustrates significant differences [44 kb] in performance. The analog filter is a 4th order Linkwitz-Riley. Two FIR designs are shown: a design based on a Hamming window, and one based on the Parks-McClellan, or Optimal method. Both filters use 21 coefficients. One IIR filter is shown which uses 20 coefficients. All coefficients were generated using Matlab programs. The Parks-McClellan coefficients were generated using a program posted by I. W. Selesnick.

The first observation is that the cutoff slope of the analog filter is much wimpier than the digital filters. A steep slope is very advantageous: it minimizes distortion and it minimizes lobing. In theory higher order analog filters are possible, but in practice it is uncommon to go beyond a 4th order.

The IIR filter has the steepest slope, but its really not all that much better than the FIR designs, and the phase response is lousy. The phase response of the analog filter is also terrible. In contrast, the phase responses of the two FIR designs are both perfect.

Finally, the Parks-McClellan design is optimal in the sense that its slope is steeper than the Hamming window design, but I would much prefer the deeper drop at frequencies well past the crossover frequency. This is especially important for a high pass filter. For a constant sound pressure level, speaker cone excursion is inversely proportional to frequency squared. So if low frequencies get into the tweeter at a constant level, cone excursion grows 12 dB per octave as frequency decreases. Not good. The Parks-McClellan design has been selected to have a 0.1 dB ripple in the pass-band, and the sidelobes would cause a 0.1 dB ripple in the stop-band if added to an otherwise flat response. The ripple could be reduced, but then the slope would be reduced. In my opinion the FIR Hamming design is the clear winner.

Back to the list of subsections

A Crossover Design Example

In the design comparison above, 1.0 on the relative frequency scale corresponds to 22,050 Hz for a compact disk sample rate. The crossover frequency for the filter comparison is 4,410 Hz. For a crossover frequency of 300 Hz, many more coefficients are required because the filter bandwidth is a much smaller fraction of the total bandwidth. A 256 coefficient design produces pretty good results [45kb]. For the smallest slope, the midband low end rolloff, response is down 19 dB one octave below the crossover frequency. The high side rolloff of the low pass is steeper. The rolloff is almost scary at the upper crossover frequency of 3000 Hz. The magenta curve is the coherent sum of the responses, including phase, and it is flat to 0.02 dB. This is with off-the-shelf coefficients provided by Matlab, and tweaking could probably even improve it a bit.

There is an Analog Devices "Ez-kit lite" development board that includes a demonstration application of a FIR filter using 256 coefficients, so the design shown is quite feasible. A 50 megaflop processor should be capable of handling 400 or more coefficients. Using a fast convolution technique described by Anders Torger, he states a 266 Mhz Pentium can process 14 channels, each with 65,536 filter taps, in real time with a 44.1 kHz rate.

Impulse Response

The digital impulse response of a FIR digital filter is simply the string of filter coefficients. As an example, the impulse responses for a hi-pass and lo-pass FIR filter of order 40 [40 kb], crossed over at 3000 Hz, shows the ringing of the hi-pass and lo-pass filters. But the sum of the two impulse responses almost exactly cancel everywhere except at a single point, where the sum is almost exactly equal to 1.0. For the example shown, using default Matlab coefficients, the sum peak is .003 dB over 1.0, and the maximum value at any other point is 67 dB below the peak. The total impulse response has to be nearly perfect since the combined frequency response is nearly perfect.

The combined impulse response can be made truly perfect by the simple expedient of defining the hi-pass coefficients as the negatives of the lo pass, except for the center tap which is 1 minus the lo pass center. For the case above this produces a very nice looking frequency response, but for higher order filters it doesn't work well. No doubt there is a more sophisticated method that works better.

In any case in the real world of audio the two impulse responses will be aligned perfectly only if the drivers are perfectly time aligned, and then only at a single elevation angle (assuming vertically displaced drivers). So the ringing of the individual filters is an issue. A filter of order 300 can have significant ringing for 1/3 millisecond. (Thanks to Egidijus Jakulis for raising this question).

A comparison of the impulse responses [44 kb] for the same four filters discussed above shows a substantial similarity in all of the responses except for the IIR design, which not surprisingly has significantly greater ringing. The FIR Hamming window has the least ringing.

Time Alignment

A digital filter can delay the output signal by 1 to 1000's of sample intervals. This can be used to time-align loudspeaker drivers to obtain an overall accurate phase response.

Back to the list of subsections

Conclusion

I think these things look fantastic.

________________________

1. Two good references for the material in this section are the books by Richard Lyons, and by Ken Pohlmann. I especially like the latter, which contains lots of information regarding hardware and programming as well as theory.