BiQuadDesigner
Created on 2020-09-03T21:33:40+00:00
- Nyquist frequency is 1/2 the sampling rate
- Digital processing must happen below the Nyquist frequency or sound quality goes to shit
- Audio filtering began with equations and then finding analogue equivalents to implement it
- Circuits can be modelled as differential equations which are then solved.
- Solving circuits via differential equations quickly gets out of hand (long, complex formulas.)
- Biquadratic filter is named because it is a filter function and it contains two quadratic equations.
- a0 is often set to 1 or cancelled for performance reasons
Original biquad filter function:
$ H(z)=\frac{b_0+b_1z^{-1}+b_2z^{-2}}{a_0+a_1z^{-1}+a_2z^{-2}}
Biquad filter where a_o is set to 1
$ H(z)=\frac{b_0+b_1z^{-1}+b_2z^{-2}}{1+a_1z^{-1}+a_2z^{-2}}
Rewrite as a difference equation:
$ b_0x(n)+b_1x(n-1)+b_2x(n-2)-a_1y(n-1)-a_2y(n-2)
How do you get from two quadratics to a difference equation? Math magic. TODO?
"Solving the biquadratic difference equation":
filter*(self: var Filter; x: float): float = y = self.b0 * x + self.b1 * x1 + self.b2 * x2 - self.a1 * y1 - self.a2 * y2 x2 = x1 x1 = x y2 = y1 y1 = y return y
$ f(p)^2 = \frac{16 b_0 b_2 p^2 + (b_0 + b_1 + b_2)^2 - 4(b_0 b_1 + 4 b_0 b_2 + b_1 b_2) p}{16 a_2 p^2 + (a_1 + a_2 + 1)^2 - 4 (a_1 a_2 + a_1 + 4 a_2) p}
where
$ p=(\frac{sin(2 pi f)}{2samplerate})^2