2
$\begingroup$

I'm attempting to use the low- and high-shelf filters from robert bristow-johnson's Audio EQ Cookbook1 for a filter that will have a pronounced peak - high $Q$, with a range of up to +24dB. The goal is to make the filter musically "playable" by controlling its resonant peak.

However, the resonant peak of these filters doesn't seem to be at $f_0$ - but rather, it seems to move based on $f_0$, $Q$ and $\mathit{dB_{gain}}$ in a way that I'm having trouble calculating. (If I could calculate the offset from $f_0$ as a function of $Q$ and $\mathit{dB_{gain}}$ alone, I could compensate for that offset when setting $f_0$ and could center the resonant peak at whatever frequency I want.)

Here's a (terrible screenshot of an) example of three filter responses implemented with the filters in the cookbook, illustrating the problem: all three of these filters have $f_0$ at 250Hz, with varying $Q$ factors and shelf gains. Their resonant peaks seem to be centered at (from left to right) 206Hz, 219Hz, and 229Hz:

a frequency plot showing three low-shelf filters, each with peaks slightly offset in frequency and amplitude

I've found a couple of RBJ's answers that might hint at a solution here, but which I'm not 100% confident with:

  • in an answer to Audio EQ Cookbook without frequency warping, he gives a formula for calculating the location of the frequency peak for a hypothetical 5-parameter Parametric EQ, but "might also have to be adjusted a little and that has yet to be worked out." (I'm also unsure if that same formula would apply to a shelving filter, as $G_{boost}$ doesn't seem to exist in a pure shelving filter.)
  • in Calculate Q factor of a Low Shelf and High Shelf filter, it's suggested that there's a direct relationship between the "shelf slope" parameter $S$ and $Q$ - and while that might allow for calculation of $S$, $S$ appears to be a unitless parameter (unless I'm misunderstanding its definition).

1as implemented in JUCE, which appears to be using the cookbook.

$\endgroup$
2
  • 1
    $\begingroup$ I wish i had my notes from the 90s. $\endgroup$ – robert bristow-johnson Jun 8 at 13:56
  • 1
    $\begingroup$ $S$ and $Q$ are related and tbe relationship is in the cookbook. $S$ is dimensionless because it's the ratio of two slopes that i normally express as dB per octave. $\endgroup$ – robert bristow-johnson Jun 8 at 14:18
3
$\begingroup$

For an example analysis, I’ve picked up the low-shelf filter in Robert Bristow-Johnson’s Audio EQ Cookbook.

In the book, the transfer function is given as;

$$H(s) = A\frac{s^2 + \frac{\sqrt{A}}{Q}s + A}{As^2 + \frac{\sqrt{A}}{Q}s + 1}$$

Since the analysis is going to be done by hand, the asymptotic approximation method of Bode plot analysis can be followed. So, at first, the above transfer function $H(s)$ should be rearranged.

$$H(s) = \frac{s^2 + \frac{\sqrt{A}}{Q}s + A}{s^2 + \frac{\sqrt{A}}{QA}s + \frac{1}{A}}$$

For the Bode plot analysis, the angular frequency/frequency should be considered directly i.e. the variable transform $s = j\omega$ should be done.

$$H(j\omega) = \frac{(j\omega)^2 + \frac{\sqrt{A}}{Q}{j\omega} + A}{(j\omega)^2 + \frac{\sqrt{A}}{QA}{j\omega} + \frac{1}{A}}$$

$$H(j\omega) = \frac{{-\omega}^2 + \frac{\sqrt{A}}{Q}{j\omega} + A}{{-\omega}^2 + \frac{\sqrt{A}}{QA}{j\omega} + \frac{1}{A}}$$

Now, we can start to do asymptotic analysis. At first, the Bode transfer function is obtained by dividing the terms by constants in the regarding parts of the transfer function $H(j\omega)$.

$$H(j\omega) = K_{B}\frac{\frac{{-\omega}^2}{A} + \frac{\sqrt{A}}{QA}{j\omega} + 1}{{-\omega}^2A + \frac{\sqrt{A}}{Q}{j\omega} + 1}$$

In the equation above, $K_{B}$ is called the Bode gain and by comparing the previous equations with the last one;

$$K_{B} = A^2$$

So, the transfer function becomes;

$$H(j\omega) = A^2\frac{\frac{{-\omega}^2}{A} + \frac{\sqrt{A}}{QA}{j\omega} + 1}{{-\omega}^2A + \frac{\sqrt{A}}{Q}{j\omega} + 1}$$

After this point, by considering every term of both the numerator and denominator of the transfer function $H(j\omega)$ as separate transfer functions (actually, this approach is based on the characteristics of the complex numbers), the overall gain equation (which is used to plot the magnitude graph $|H(j\omega)|$) and the overall phase equation (this is utilised when plotting the phase graph $\angle{H(j\omega)}$) can be found. However, since now we’re only dealing with the magnitude graph, I’m not going to do analysis on the phase plot. This will reduce the complexity of the script of.

For $A^2$ term;

$$Gain = 40\log{|A|} = 40\log{(|A|)} dB$$

For $1 + {\frac{\sqrt{A}}{QA}}{j\omega} - {\frac{{\omega}^2}{A}}$ term;

$$Gain = 20\log{| 1 + {\frac{\sqrt{A}}{QA}}{j\omega} - {\frac{{\omega}^2}{A}} |} = 20\log{ ( \sqrt{ (1 - { \frac{ {\omega}^2 }{A} })^2 + ( { \frac{ \sqrt{A} }{QA} ) }^2 ) }} dB$$

And, for $\frac{1}{1 + \frac{\sqrt{A}}{Q}{j\omega} – {\omega}^2A}$ term;

$$Gain = -20\log{| 1 + \frac{\sqrt{A}}{Q}j\omega - {\omega}^2A |} = -20\log{(\sqrt{ (1 - A{\omega}^2)^2 + (\frac{\sqrt{A}}{Q})^2 ) } } dB$$

As a result, the overall/total gain $|H(j\omega)|$ is the sum of the terms’s gains which is given below.

$$|H(j\omega)| = 40\log{(|A|)} + 20\log{ ( \sqrt{ (1 - { \frac{ {\omega}^2 }{A} })^2 + ( { \frac{ \sqrt{A} }{QA} ) }^2 ) }} - 20\log{(\sqrt{ (1 - A{\omega}^2)^2 + (\frac{\sqrt{A}}{Q})^2 ) } } dB$$

This equation is not that handy for finding out the peak conditions i.e. the resonance instants of the magnitude plot. So, after some algebraic calculations, the final form of $|H(j\omega)|$ is found to be;

$$|H(j\omega)| = 20\log{( \sqrt{ \frac{ Q^2A^2 – 2{\omega}^2Q^2A + {\omega}^4Q^2 + A}{ Q^2A^2 – 2{\omega}^2Q^2A^3 + {\omega}^4Q^2A^4 + A^3} } )} + 40\log{(|A|)}dB$$

In order to find the peaks, both the overshoot and undershoot of the magnitude plot, the partial derivative of $|H(j\omega)|$ with regards to the angular frequency $\omega$ can be equaled to zero. After too many algebraic calculations, they are really time-consuming things to do, the relevant equation is found below:

$$\frac{\partial{|H(j\omega)|}}{\partial{\omega}} = 0$$

$${\omega}^4(Q^2A^3 – Q^2A) + {\omega}^2(Q^2 + A – Q^2A^4 – A^3) + Q^2A^3 + A^2 – Q^2A – A^2 = 0$$

The above equation is of a quartic polynomial of $\omega$ which means that it is not that easy to determine the roots i.e. the resonance frequencies, both the resonance and anti-resonance frequencies, of the system of the transfer function $H(s)$. In this case, an easy trick which involves a variable transform can be applied on that quartic equation.

Let’s say;

$${\omega}^2 = a$$

When returning the values of $\omega$, which can be represented as $\omega \epsilon R^+$ i.e. the values of $\omega$ are positive real numbers, we will use the values of $a$ and the formula below:

$$\omega = \sqrt{a}$$

With the variable transform, the quartic equation becomes;

$$a^2(Q^2A^3 – Q^2A) + a(Q^2 + A – Q^2A^4 – A^3) + Q^2A^3 + A^2 – Q^2A – A^2 = 0$$

and after some further calculations, the roots of this equation becomes;

$$a_{1,2} = \frac{ -(Q^2 + A – Q^2A^4 – A^3)\pm\sqrt{ (Q^2 + A –Q^2A^4 – A^3)^2 – 4(Q^2A^3 – Q^2A)(Q^2A^3 + A^2 – Q^2A – A^2) } }{ 2(Q^2A^3 – Q^2A)}$$

Consequently, the corresponding values of $\omega$ i.e. the angular resonance frequencies become;

$$\omega_{1,2} = \sqrt{\frac{ -(Q^2 + A – Q^2A^4 – A^3)\pm\sqrt{ (Q^2 + A –Q^2A^4 – A^3)^2 – 4(Q^2A^3 – Q^2A)(Q^2A^3 + A^2 – Q^2A – A^2) } }{ 2(Q^2A^3 – Q^2A)}} rad/s$$

The usage of plus sign gives the angular anti-resonance frequency. On the other hand, selecting the minus sign makes us to find the angular resonance frequency.

I’ve just wanted to test whether my calculations are correct and for doing so, I’ve plotted an example transfer function with $A = 2$ and $Q = 4$ which yield the transfer function;

$$H(s) = \frac{2s^2 + 0.708s + 4}{2s^2 + 0.354s + 1}$$

The MATLAB source code for this example application is given below:

sys = tf([2, 0.708, 4], [2, 0.354, 1]);

bode(sys);

And this source code generates this Bode plot of the magnitude graph:

The Bode plot

Both the angular resonance and anti-resonance frequency values are coherent with my calculations.

Consequently, I can say that this way of approach can be followed when determining the resonance frequencies of a specific system of concern.

$\endgroup$
5
  • $\begingroup$ There's an error in your 2nd equation. The $1$ in the denominator has to be divided by $A$. $\endgroup$ – robert bristow-johnson Jun 8 at 14:48
  • $\begingroup$ @robert bristow-johnson I've got that mistake, I'm recalculating equations right now. Thank you for your attention. $\endgroup$ – Karakoncolos Jun 8 at 15:12
  • $\begingroup$ the easiest way to do this is to drop that constant gain $A$ and deal with the odd symmetry between the numerator and denominator. recently this has come up. $\endgroup$ – robert bristow-johnson Jun 8 at 15:27
  • $\begingroup$ @robert-bristow johnson Thank you for your advice, but I'd recalculated all those equations other way round and the script has been edited. $\endgroup$ – Karakoncolos Jun 8 at 16:04
  • $\begingroup$ Thank you @Karakoncolos! This is a wonderful explanation, and seems very accurate too - I've plotted this against the "true" measured value of the filter peak for varying values of $A$ and $Q$, and found it's within 0.5% of the measured value. (My guess is that the remaining difference is either a rounding error in my code, or potentially the effect of frequency warping that I haven't taken into account.) $\endgroup$ – Peter Sobot Jun 9 at 0:20
3
$\begingroup$

The resonant frequency is related to the "significant frequency" (which is the shelf midpoint frequency) by a factor of $\frac{1}{\sqrt{A}}$ for the lowShelf and the reciprocal of that for the highShelf.

$\endgroup$
3
  • $\begingroup$ Thank you! The graph above suggests that the peak also moves when $Q$ changes but $A$ remains constant, though - is $Q$ not a factor in determining the resonant frequency? $\endgroup$ – Peter Sobot Jun 8 at 14:22
  • 1
    $\begingroup$ No. $Q$ and $A$ determine how steep the shelf slope is. Without accounting for frequency warping (a consequence of the bilinear transform), $\frac{f_0}{\sqrt{A}}$ is the biquad resonant frequency for the lowShelf. For the highShelf the resonant frequency is $f_0 \sqrt{A}$. Again approximate because frequency warping is not considered. $\endgroup$ – robert bristow-johnson Jun 8 at 14:44
  • 1
    $\begingroup$ FWIW, the case is the same for resonant low and high pass filters. The peak isn’t exactly at the resonant frequency, but it becomes increasingly close with increasing Q. $\endgroup$ – Dan Szabo Jun 8 at 19:39
0
$\begingroup$

However, the resonant peak of these filters doesn't seem to be at $f_0$

It's not supposed to be. The center frequency you specify is the midpoint between the two parts of the shelf. So for a shelf with a gain of X dB, the center frequency is defined where the gain is X/2.

If you increase the Q above $\sqrt{2}$ you end up with TWO resonances: a peak and a dip: one below and one above the center frequencies. The location of the resonance does indeed move with gain and Q but the center frequency stays put.

$\endgroup$
3
  • $\begingroup$ Thanks @Hilmar - I agree with all of that, but it doesn’t help determine where the resonances are relative to the center frequency, which is my question. $\endgroup$ – Peter Sobot Jun 8 at 12:59
  • $\begingroup$ Do you need both resonances or just the peak? Do you just need to calculate where the peak is or do you need to back-calculate the coefficients for a given resonant frequency? Who "precise" does the frequency need to be ? $\endgroup$ – Hilmar Jun 8 at 13:27
  • $\begingroup$ I need just the peak; although because the response is symmetric, if I know one peak I should be able to find the other trivially. It'd be great if I could back-calculate the coefficients for a given resonant frequency, but I think I can also calculate the coefficients the usual way if I know the peak's frequency offset from $f_0$ for a given $Q$ and $dB_{gain}$. $\endgroup$ – Peter Sobot Jun 8 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.