Filter Reversing
Given (F_s), Q, and (ƒ_0), we can begin the calculations for any filter with:
(ω_0)=2*π(ƒ_0)/(F_s)
α=sin((ω_0))/(2*Q)
The coefficients from the spec (A_1) and (A_2) are normalized (we know this because (A_0) is not specified) so we know that:
(A_1)=(a_1)/(a_0)
(A_2)=(a_2)/(a_0)
Stage 1 filter
Cookbook definition of a high-shelf filter
We need an extra variable, A which is our gain. If we have gain in decibels G, it can be converted with A=√(,10(G/20))=10(G/40).
(b_0)=A*((A+1)+(A-1)*cos((ω_0))+2√(,A)*α)
(b_1)=−2*A*((A−1)+(A+1)*cos((ω_0)))
(b_2)=A*((A+1)+(A−1)*cos((ω_0))−2√(,A)*α)
(a_0)=(A+1)−(A−1)*cos((ω_0))+2√(,A)*α
(a_1)=2*((A−1)−(A+1)*cos((ω_0)))
(a_2)=(A+1)−(A−1)*cos((ω_0))−2√(,A)*α
Reversing the high-shelf coefficients
Here, we can cheat because we know from the diagram in the spec that G=4. Everything becomes much easier knowing A versus having to solve for it as well.
To solve for (ω_0):
(a_0)+(a_2)=(A+1)
−(A−1)*cos((ω_0))
+2√(,A)*α
+(A+1)
−(A−1)*cos((ω_0))
−2√(,A)*α
(a_0)+(a_2)=2*((A+1)−(A−1)*cos((ω_0)))
(a_0)*(1+(A_2))=2*((A+1)−(A−1)*cos((ω_0)))
(a_0)=(2*((A+1)−(A−1)*cos((ω_0))))/(1+(A_2))
We'll need this form of (a_0) later to calculate Q. Right now, we can use our earlier definition of the normalized coefficients to substitute:
(a_0)=(a_1)/(A_1)and (a_1)=2*((A−1)−(A+1)*cos((ω_0)))
(2*((A−1)−(A+1)*cos((ω_0))))/(A_1)=(2*((A+1)−(A−1)*cos((ω_0))))/(1+(A_2))
((A−1)−(A+1)*cos((ω_0)))/(A_1)=((A+1)−(A−1)*cos((ω_0)))/(1+(A_2))
(A_1)*(A+1)−(A_1)*(A−1)*cos((ω_0)) =(1+(A_2))*(A−1)−(1+(A_2))*(A+1)*cos((ω_0))
(1+(A_2))*(A+1)*cos((ω_0))−(A_1)*(A−1)*cos((ω_0)) =(1+(A_2))*(A−1)−(A_1)*(A+1)
cos((ω_0))*((1+(A_2))*(A+1)-(A_1)*(A-1))=(1+(A_2))*(A−1)−(A_1)*(A+1)
cos((ω_0))=((1+(A_2))*(A−1)−(A_1)*(A+1))/((1+(A_2))*(A+1)-(A_1)*(A-1))
(ω_0)=arccos(((1+(A_2))*(A−1)−(A_1)*(A+1))/((1+(A_2))*(A+1)-(A_1)*(A-1)))
Now, to solve for Q we first must solve for α:
(a_0)-(a_2)=(A+1)
−(A−1)*cos((ω_0))
+2√(,A)*α
-(A+1)
+(A−1)*cos((ω_0))
+2√(,A)*α
(a_0)-(a_2)=4√(,A)*α
(a_0)(1-(A_2))=4√(,A)*α
α=(a_0)(1-(A_2))/(4√(,A))
Time for Q:
(a_0)(1-(A_2))/(4√(,A))=sin((ω_0))/(2*Q)
Q=(2*sin((ω_0))√(,A))/(a_0)(1-(A_2))
And (ƒ_0) is really easy:
2*π(ƒ_0)/(F_s)=(ω_0)
(ƒ_0)=((ω_0)*(F_s))/(2*π)
Stage 2 filter
Cookbook definition of a high-pass filter
(b_0)=(1+cos((ω_0)))/2
(b_1)=-(1+cos((ω_0)))
(b_2)=(1+cos((ω_0)))/2
(a_0)=1+α
(a_1)=-2*cos((ω_0))
(a_2)=1-α
Reversing the low-pass coefficients
This filter should be a lot easier to reverse due to the relative simplicity of the (a_0), (a_1), and (a_2) definitions.
Again, we start by solving for (ω_0) in terms of one of our normalized coefficients.
cos((ω_0))=-(a_1)/2
cos((ω_0))=-((A_1)*(a_0))/2
(a_0)+(a_2)=1+α+1-α
(a_0)+(a_2)=2
(a_0)(1+(A_2))=2
(a_0)=2/((A_2)+1)
Substitute:
cos((ω_0))=-(A_1)/22/((A_2)+1)
cos((ω_0))=-(A_1)/((A_2)+1)
(ω_0)=arccos(-(A_1)/((A_2)+1))
We solve for α reusing our existing definitions:
(a_0)=1+α
2/((A_2)+1)=1+α
α=2/((A_2)+1)-1
α=(1-(A_2))/((A_2)+1)
And then Q:
(1-(A_2))/((A_2)+1)=sin((ω_0))/(2*Q)
Q=(sin((ω_0))*((A_2)+1))/(2*(1-(A_2)))
And (ƒ_0) is the same as done previously.