• No results found

Basic DSP Theory

Step 5: Direct evaluation

5.20 The Bi-Quadratic Filter

The last fi lter topology to study is the bi-quadratic (or bi-quad) fi lter. The bi-quad consists of two second-order components: a second-order feed-forward and a second-order feed-back fi lter combined together as shown in the block diagram in Figure 5.61 . The resulting transfer function will have two quadratic equations, thus the name.

The difference equation is as follows:

y(n) 5 a0x(n) 1 a1x(n 2 1) 1 a2x(n 2 2) 2 b1y(n 2 1) 2 b2y(n 2 2) (5.86) Steps 1 to 3: Take the z transform of the difference equation to get the transfer function, then factor out a 0 as the scalar gain coeffi cient

y(n) 5 a0x(n) 1 a1x(n 2 1) 1 a2x(n 2 2) 2 b1y(n 2 1) 2 b2y(n 2 2) Y(z) 5 a0X(z) 1 a1X(z)z211 a2X(z)z22 2 b1Y(z)z212 b2Y(z)z22 Separate variables:

Y(z) 1 b1Y(z)z211 b2Y(z)z225 a0X(z) 1 a1X(z)z21 1 a2X(z)z22 Y(z)31 1 b1z21 1 b2z224 5 X(z)3a01 a1z211 a2z224 Form transfer function

H(z) 5 Y(z)

X(z) 5 a0 1 a1z21 1 a2z22 1 1 b1z211 b2z22 Figure 5.61: The bi-quad.

Im

Re Rz

RP z

RP

φ

– φ θ

Factor out a0

H(z) 5 a01 1 a1z21 1 a2z22 1 1 b1z21 1 b2z22

where (5.87)

a1 5a1 a0 a2 5a2 a0 Step 4: Plot the poles and zeros of the transfer function

The bi-quad will produce a conjugate pair of zeros and conjugate pair of poles from the numerator and denominator respectively. Calculating these locations is the same as in the pure second-order feed forward and feed back topologies. All you need to do is plot them in the same unit circle. The transfer function becomes (by simple substitution from previous sections):

H(z) 5 a01 2 2Rzcos(u)z211 Rz2z22

1 2 2Rpcos(f)z21 1 Rp2z22 (5.88) Figure 5.62 shows a pair of poles and a pair of zeros plotted together. Each has its own radius, R z and R p , and angle, u and w. The same kind of pole/zero tug of war goes on with the bi-quad, only now there are more competing entities.

Estimating the frequency response is complicated by the additional poles and zeros, but the rules are still the same:

• Locate each evaluation frequency on the outer rim of the unit circle.

Draw a line from the point on the circle to each zero and measure the length of these vectors. Do it for each evaluation frequency.

Figure 5.62: Second-order poles and zeros.

Im

Re θ

φ

Draw a line from the point on the circle to each pole and measure the length of these vectors. Do it for each evaluation frequency.

• Multiply all the zero magnitudes together.

Multiply all the inverse pole magnitudes together.

• Divide the zero magnitude by the pole magnitude for the fi nal result at that frequency.

Using the following coeffi cients, a 0 5 1.0, a 1 5 0.73, a 2 5 1.00, b 1 5 20.78, b 2 5 0.88, we can directly fi nd the pole and zero locations from Equation 5.88 (note that because a 0 is 1.0, you don’t have to calculate the a terms). The pairs of poles and zeros are plotted in Figure 5.63 .

Zeros are calculated as follows:

a25 R2z 5 1.00 Rz5"1.00 5 1.00 and

a1 5 22Rcos(u) 5 0.73 2(1.00) cos(u) 5 0.73

cos(u) 5 0.365

(5.89)

u 5 arccos(0.365)

u 5 68.68

Poles are calculated as follows:

b2 5 R2p 5 0.88 Rp5"0.88 5 0.94

Figure 5.63: Pole/zero plot for the example bi-quad fi lter.

+24.0 dB +12.0 dB 0.0 dB –12.0 dB –24.0 dB –36.0 dB –48.0 dB

2 kHz 4 kHz 6 kHz 8 kHz 10 kHz 12 kHz 14 kHz 16 kHz 18 kHz 20 kHz Effect of the zero Effect of the pole

and

b1 5 22Rcos(f) 5 20.78 2(0.94)cos(f) 5 0.78

cos(f) 5 0.78

2(0.94) (5.90)

f 5 arccos(0.414) f 5 65.58

The poles and zeros are in close proximity to each other. The zero is directly on the unit circle (R z 5 1.0), so we expect a notch to occur there. The pole is near the unit circle but not touching it, so we expect a resonance there.

We are not going to go through the full response estimation or direct evaluation since it’s just repetitive algebra at this point. But, we can use RackAFX’s bi-quad module to set up the fi lter and evaluate it ( Figure 5.64 ). The frequency response clearly shows the resonant peaking due to the pole, then the sudden notch due to the nearby zero.

In Figure 5.64 , it’s easy to locate the places where the pole or zero dominates. In the low frequencies, the pole dominates and at high frequencies the zero dominates. This is an example of a direct z -plane design where we place a pole and zero pair directly in the z -plane, then calculate the coeffi cients. In the next chapter, we will examine some basic Infi nite Impulse Response (IIR) design techniques and the direct z -plane method will be the fi rst.

Final Review Notes

In this chapter you learned the basics of DSP theory; specifi cally, you learned the sequence:

1. Take the z transform of the difference equation.

2. Fashion the difference equation into a transfer function.

3. Factor out a 0 as the scalar gain coeffi cient.

Figure 5.64: The plot from RackAFX shows the resonant peak and notch formed by the pole and zero.

4. Estimate the frequency response.

5. Direct evaluation of frequency response.

6. z transform of impulse response as a fi nal check.

For geometric estimation, the frequency response and phase responses of a fi lter can be found with Equations 5.91 and 5.92 .

Ui5 the geometric length from the point(v)on the unit circle to the ith zero Vi5 the geometric length from the point(v)on the unit circle to the ith pole

For direct evaluation, you simply plug in various values for frequency and crank through the algebra. We applied this same routine to feed-forward, feed-back, and combination types of algorithms, and then used RackAFX to check our results. We also classifi ed the fi lters into IIR and Finite Impulse Response (FIR) types.

IIR Filters

• Any fi lter with a feed-back path is IIR in nature, even if it has feed-forward branches as well.

The feed-back paths in IIR fi lters produce poles in the z -plane and the poles cause gain to occur in the magnitude response.

• An IIR fi lter can blow up when its output steadily increases toward infi nity, which occurs when the poles are located outside the unit circle.

• If the IIR fi lter also has feed-forward branches it will produce zeros as well as poles.

• IIR fi lters can have fast transient responses but may ring.

FIR Filters

• The FIR fi lter only has feed-forward paths.

It only produces zeros in the z -plane.

• The FIR fi lter is unconditionally stable since its output can only go to zero in the worst case.

• FIR fi lters will have slower transient responses because of the time smearing they do on the impulse response.

• The more delay elements in the FIR, the poorer the transient response becomes.

Bibliography

Ifeachor, E. C. and Jervis, B. W. 1993. Digital Signal Processing: A Practical Approach , Chapter 3. Menlo Park, CA: Addison-Wesley.

Kwakernaak, H. and Sivan, R. 1991. Modern Signals and Systems , Chapter 3. Englewood Cliffs, NJ: Prentice-Hall.

Moore, R. 1990. Elements of Computer Music , Chapter 2. Englewood Cliffs, NJ: Prentice-Hall.

Oppenheim, A. V. and Schafer, R. W. 1999. Discrete-Time Signal Processing (2nd ed.), Chapter 3. Englewood Cliffs, NJ: Prentice-Hall.

Orfanidis, S. 1996. Introduction to Signal Processing , Chapters 10–11. Englewood Cliffs, NJ: Prentice-Hall.

Steiglitz, K. 1996. A DSP Primer with Applications to Digital Audio and Computer Music , Chapters 4–5. Menlo Park, CA: Addison-Wesley.

163

It’s time to put the theory into practice and make some audio fi lters and equalizers (EQs).

You know that the coeffi cients of a fi lter determine its frequency response and other

characteristics. But how do you fi nd the coeffi cients? There are two fundamental ways to fi nd the coeffi cients of the infi nite impulse response (IIR) fi lter:

Direct z -plane design

• Analog fi lter to digital fi lter conversion

This chapter uses the following fi lter naming conventions:

• LPF: Low-pass fi lter

• HPF: High-pass fi lter

• BPF: Band-pass fi lter

• BSF: Band-stop fi lter