]> Sound and music - Example: Digital Lowpass Filter

## Example: Digital Lowpass Filter

Suppose we want to construct a digital filter with cutoff ${f}_{c}$ from a 2-pole Butterworth lowpass filter. Then start with its transfer function

$H\left(s\right)=\frac{1}{{s}^{2}+\sqrt{2}s+1}$

which has $1$ as the cutoff freqency.

In order for the transformation to work we need the cutoff to be $\mathrm{tan}\left(a/2\right)$ instead of $1$, where $a=2\pi {f}_{c}/{f}_{s}$. So we compute $\omega =\mathrm{tan}\left(\pi {f}_{c}/{f}_{s}\right)$ and replace $s$ with $s/\omega$ so that the cutoff is at $i\omega$ instead of $i$. Then we perform a bilinear transform by replacing $s$ with $\frac{z-1}{z+1}$. We end up with

$H\left(z\right)=\frac{1}{\frac{1}{{\omega }^{2}}\left(\frac{z-1}{z+1}{\right)}^{2}+\sqrt{2}\frac{1}{\omega }\frac{z-1}{z+1}+1}=\frac{{z}^{2}+2z+1}{\left(\frac{1}{{\omega }^{2}}+\frac{\sqrt{2}}{\omega }+1\right){z}^{2}+\left(2-\frac{2}{{\omega }^{2}}\right)z+\left(\frac{1}{{\omega }^{2}}-\frac{\sqrt{2}}{\omega }+1\right)}$

So letting $d=\frac{1}{\omega }$, $c=1/\left({d}^{2}+\sqrt{2}d+1\right)$, we have the filter coefficients:

${a}_{0}=c,{a}_{1}=2c,{a}_{2}=c,{b}_{1}=\left(2-2{d}^{2}\right)c,{b}_{2}=\left({d}^{2}+1-\sqrt{2}d\right)c$