This question arose from a discussion in the comments to this question and its answer. The author of that question discussed a discrete-time second order filter described by the following difference equation:
y[n]=b0x[n]+b1x[n−1]+b2x[n−2]−a1y[n−1]−a2y[n−2]
with b0=b2=(1−r2)/2, b1=0, a1=−2rcos(2πf0T), and a2=r2.
The transfer function corresponding to the difference equation (1) is
H(z)=1−r221−z−21−2rcos(ωp)z−1+r2z−2
where I use the abbreviation ωp=2πf0T.
In the original question quoted above, f0 was called "resonant frequency", and the discussion inspired by that question was about whether or not f0 equals the peak frequency of the filter's frequency response.
So the questions I pose are:
What is the meaning of r and f0 as used in the coefficients of Eqs. (1) and (2)?
Does f0 equal the filter's peak frequency (i.e., the frequency where the magnitude of the filter's frequency response attains its maximum)?
Answer
According to the Audio EQ Cookbook the transfer function of a second-order band-pass filter with 0dB peak gain is given by
H(z)=α−αz−2(1+α)−2cos(ω0)z−1+(1−α)z−2=α1+α⋅1−z−21−21+αcos(ω0)z−1+1−α1+αz−2
where ω0 is the angular frequency where the peak occurs ("peak frequency"), and α=sin(ω0)/(2Q) is a parameter determined by ω0 and the desired quality factor Q.
If we express the same transfer function H(z) in terms of its poles we get
H(z)=k1−z−2(1−rejωpz−1)(1−re−jωpz−1)=k1−z−21−2rcos(ωp)z−1+r2z−2
where k is some gain constant to be determined, $0
Comparing (1) and (2) we can express α and ω0 of Eq. (1) in terms of the pole radius r and the pole angle ωp used in Eq. (2):
1−α1+α=r2⟹α=1−r21+r2,k=α1+α=1−r2221+αcos(ω0)=(1+r2)cos(ω0)=2rcos(ωp)
The second line of Eq. (3) shows that the pole angle ωp and the peak frequency ω0 are not equal, and that the following relationship holds:
1+r22rcos(ω0)=cos(ωp)
The following Matlab/Octave example illustrates the above. We choose ω0=0.2π and Q=1 and design the corresponding biquad band-pass filter according to Eq. (1). The figure below shows the magnitude of the resulting frequency response, and the locations of the peak frequency ω0 (red line) and of the pole angle ωp (green line), both normalized by π.
w0 = .2*pi;
Q = 1;
al = sin(w0)/(2*Q);
b = [al,0,-al]/(1+al); % numerator coeffs
a = [1+al,-2*cos(w0),1-al]/(1+al); % denominator coeffs
p = roots(a); % poles
r = abs(p(1)); % pole radius
r2 = sqrt((1-al)/(1+al)); % pole radius according to formula
abs(r-r2) % ans = 0
wp = abs(angle(p(1))); % pole angle: wp = 0.17877*pi
wp2 = acos((1+r^2)/(2*r)*cos(w0)); % pole angle according to formula
abs(wp-wp2) % ans = 0
[H,w]=freqz(b,a,1024);
plot(w/pi,abs(H))
hold on, plot([w0,w0]/pi,[0,1],'r',[wp,wp]/pi,[0,1],'g'), hold off
EDIT:
In Eq. (2) I assumed that there are two complex conjugate poles, because in the original question, which triggered this question and answer, the filter coefficients were chosen in such a way that only complex conjugate poles were possible (cf. the coefficients under Eq. (1) of the question above).
However, the general transfer function in Eq. (1) can also have a double real-valued pole or two different real-valued poles. It can be shown that a double real-valued pole occurs when the quality factor Q is chosen as Q=12. This case is still covered by Eq. (2) with ωp=0 (i.e., a positive real-valued pole) or ωp=π (a negative real-valued pole). For Q<12 we get two different real-valued poles, and Eq. (2) is not valid anymore. Instead, the transfer function becomes
H(z)=k1−z−2(1−β1z−1)(1−β2z−1)=k1−z−21−(β1+β2)z−1+β1β2z−2
where β1 and β2 are the two real-valued poles. Comparing this transfer function to the transfer function given in Eq. (1), we get the following relationships between α, ω0, k and β1 and β2:
α=1−β1β21+β1β2cos(ω0)=β1+β21+β1β2k=1−β1β22
Of course, the pole angles are now either zero or π, because both poles are real-valued. Note that the peak frequency ω0 is not necessarily 0 or π. The peak frequency ω0 can in fact take any value, and the two pole angles will always be either 0 or π as long as the quality factor Q satisfies Q<12.
No comments:
Post a Comment