BiQuadDesigner

Created: 2020-09-03T21:33:40+00:00

Return to the Index

This card pertains to a resource available on the internet.

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}}

Wikipedia on original formulas

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

Reference on figuring out buquad filter constants

$ 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