How to Make Resonant Butterworth Filters ?
Table Of Contents
Our goal is to enable filters that offer both adjustable slope and resonance simultaneously. The resulting filters are designed to match the exact transfer function of those in the widely-used FabFilter Pro-Q 3.
Introduction
Two popular filters, the second-order lowpass and the Butterworth lowpass, have been studied extensively and are widely used in audio. Anyone familiar with DSP or music production will likely recognize their shapes, shown below.
|
|
These two types of filters each have unique advantages:
- The second-order filter includes a \(Q\) parameter, which can be adjusted to create either a resonant peak or a smooth roll-off at the cutoff frequency.
- The Butterworth filter features a \(\text{slope}\) parameter, allowing for sharper frequency attenuation.
At a specific configuration, where \(Q = \frac{\sqrt{2}}{2}\) and \(\text{slope} = 12 , \text{dB/oct}\), both filters yield the same response.
To combine the benefits of both filters, we aim to design a universal filter that incorporates both \(Q\) and \(\text{slope}\) parameters. However, no standard definition exists for such a filter, and only limited resources cover this concept 1. Many equalizers on the market attempt to merge these controls through various techniques, which can sometimes produce unnatural curves with unwanted peaks or dips for certain \(Q\) and \(\text{slope}\) values.
In the following sections, we propose a method to achieve a filter with both \(Q\) and \(\text{slope}\) control, producing a natural curve shape with minimal computational cost and setup.
Decomposition of the Butterworth Filter into First and Second-Order Sections
Like any linear filter, a Butterworth filter can be represented as a cascade of first and second-order sections, with slopes of 6 dB/oct and 12 dB/oct, respectively. The code below illustrates the previously discussed Butterworth filter and its decomposition into a cascade of first and second-order filters, represented by the dashed lines.
|
|
Making the Butterworth Filter Resonant
To make the Butterworth filter resonant, we can override the resonance of the second-order sections resulting from our decomposition to create a new \(Q\) control. This approach gives us a lot of possibilities, especially with higher-order Butterworth filters, which provide more second-order filters at our disposal. It turns out that overriding only the most resonant section produces natural-looking results. This method is also easy to implement and resource-efficient since we only need to adjust one section. The other sections can maintain a constant \(Q\), allowing us to hardcode the analog coefficients of the prototype filter, resulting in less computational overhead when recalculating the filter coefficients.
This technique seems to be utilized by the FabFilter Pro-Q3, a well-known equalizer in the audio industry, as the response shape closely matches that of the Pro-Q3 equalizer.
The results are shown in the graph below.
|
|
Transfer function fomula
We might formalize the transfer function of the designed resonant butterworth filter.
The transfer function of a normalized first order and second order filter are given by:
$$ H_1(s)=\frac{1}{s+1} $$
$$ H_2(s,Q)=\frac{1}{s^2+\frac{s}{Q}+1} $$
The transfert function of a the resonant butterworth filter can be factorized in term of first and second order sections as:
$$ H_n(s)=H_1\left(s\right)^{r}\prod_{k=1}^{\frac{n-r}{2}}H_{2}\left(s,q_{k}\right) $$
Where \(n\) is the order of the filter and \(r=1\) if \(n\) is odd and \(r=0\) if \(n\) is even, as we need to add an extra first order filter if n is odd. The resonance of each section \(q_k\) can computed threw standard butterworth definition, to which we override the last resonance factor, as:
$$ q_{k} = \begin{cases} -2\cos\left(\frac{2k+n-1}{2n}\pi\right) &\text{if } k = 0, 1, …, \frac{n-r}{2}-1 \newline -2\cos\left(\frac{2k+n-1}{2n}\pi\right) Q\sqrt{2} &\text{if } k = \frac{n-r}{2} \end{cases} $$
When the Q factor is equal to \(\frac{\sqrt{2}}{2}\), it behaves like the standard butterworh filter. This value is chosen as this is the \(Q\) value for which a second order filter is also equal to a 2-order standard butterworth filter.
Magnitude fomula
Let’s be \(G_{n}(\omega, Q)\) the magnitude of the resonnant butterworth prototype, meaning \(G_n(s, Q) = \left|H_n(j\omega, Q)\right|\)
We know the magnitude of a second order filter, expressed as:
$$G_{2}\left(\omega,Q\right)=\sqrt{\frac{1}{1+\left(\frac{1}{Q^{2}}-2\right)\omega^{2}+\omega^{4}}}$$
We also know the magnitude of a butterworth filter, expressed as:
$$G_{n}\left(\omega,\frac{\sqrt{2}}{2}\right)=\sqrt{\frac{1}{1+\omega^{2n}}}$$
By combining the two formulas, we get:
$$G_{n}\left(\omega, Q\right)=G_{n}\left(\omega,\frac{\sqrt{2}}{2}\right)\frac{G_{2}\left(\omega,q_{1}\right)}{G_{2}\left(\omega,\frac{q_{1}}{Q\sqrt{2}}\right)}$$
Which gives:
$$\boxed{G_n(\omega, Q) = \sqrt{\frac{1-2\cos\left(\frac{\pi}{n}\right)\omega^{2}+\omega^{4}}{\left(1+\omega^{2n}\right)\left(1+\left(\frac{1-\cos\left(\frac{\pi}{n}\right)}{Q_{0}^{2}}-2\right)\omega^{2}+\omega^{4}\right)}}}$$
Lowpass, Highpass, Bandpass, and Notch Filters
All filters in this family, lowpass, highpass, bandpass, and notch, can be derived from the lowpass prototype using highpass and bandpass transformations. The highpass transformation is straightforward, requiring only a reversal of the \(a_n\) coefficients in each section. The bandpass transformation, while more complex, is thoroughly explained in this article.
Why the 6dB/oct. case isn’t working ?
Perhaps you noticed that this trick doesn’t work for the 6dB/oct slope. This is because the 6dB/oct decomposition doesn’t contains any second order section we could override. In fact, making a Q control on the 6dB/oct version is not as trivial thing. An overdamped 6dB would mean a transition with a softer slope than 6dB/oct, which involve fractionnal order filters that are a complex topic which would need a dedicated post.