Calculating Q factor for cascading biquads

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

And then using multmode 1-poles with LP and HP outputs one could further transform the structure as (if I didn't make a mistake):

Code: Select all

2-pole TSK LP
---> + ---> LP1 ---> LP1 --->
     ^               HP1
     |                |
     |                |
     |                |
     |                |
      --- *k <--------

4-pole TSK LP
---> + ---> LP1 ---> LP1 ---> LP1 ---> LP1 -------->
     ^                        HP1      HP1
     |                         |        |
     |                         |       *(-1)
     |                         |        |
     |                          --- + --
     |                              |
      --- *k <----------------------

Post

Mayae wrote: ...

Image

Goal is to design the 4th order filter (or any Nth order filter) from the arbitrary Q of the 2nd order filter, such that they peak at the same magnitude (or in more precise terms, approach it).
...
1/2 csc((π (n + 1/2))/N) , where N = filter order and  {0<=n<(N-1)/2}
Last edited by juha_p on Mon Feb 27, 2023 8:03 am, edited 5 times in total.

Post

juha_p wrote:Goal is to design the 4th order filter (or any Nth order filter) from the arbitrary Q of the 2nd order filter, such that they peak at the same magnitude (or in more precise terms, approach it).
I think there are infinitely many different solution to that problem.
- you could take two cascaded biquads with identical cutoffs and resonance. then find the resonance value for a single biquad giving you the half-height (in decibels) of the resonant peak of the target two-pole. then two biquads will give you exactly the same resonance height. now adjust the cutoff so that the resonant peak is exactly at the same frequency. not sure if there is an analytical (rather than numerical) solution, since the expressions might be slightly involved. basically, given a cutoff and resonance of a biquad one needs to find the expressions for the exact frequency and height of the peak. the math is straightforward, but not sure if the expressions are analytically invertible.
- you could take two cascaded biquads tuned to emulate a moog filter. that is you don't control their cutoff and resonances directly, but specifify the cutoff and resonance of a moog filter instead. this will give you a different shape of the response (I think the resonance peak will be slightly wider than in the previous case, thus becoming closer to a 2-pole resonance peak shape, but I'm not sure)
- you could take any other relationship between the two biquads. the main (but not the only) difference between the approaches will be the shape of the resonance peak

An interesting goal could be trying to also match the shape of the resonance peak as close as possible. This is more complicated and probably doesn't have a unique solution either (depending on how you define "as close as possible").

Imposing a restriction that the solution has to be analytical might result in no available solution. Or maybe there are also infinitely many, but off the top of my head I'm not sure how to pursue that direction (other that obtaining analytical expressions for the dependencies in the cases I mentioned and then seeing if they are analytically invertible).

Note. I'm referring to doing the above in analog domain, which allows to easily decouple cutoff from resonance. Conversion to the digital domain is then supposed to be done by BLT.

Edit:
trying to match the peak frequencies at low resonance settings (when there is no or almost no peak) might be a bad idea, since the peak might have a very different distance from the main slope. so the solution will need to be changed to properly accommodate the low resonance case.

If it's just about the sound rather than about the exact height, then it might be simpler to solve the problem only in the limiting case of infinitely high resonance (because at lower resonance the difference is not that audible). the reason to do that is that the math for the limiting case is much simpler (the resonance occurs exactly at the cutoff and you can do further simplifications).

Post

Limiting case matching example. Given a 2-pole lowpass
H(s)=1/(1+2Rs+s^2)
match the 4-pole peak height of
H'(s)=1/(1+2R's+s^2)^2

The limiting case peak of H(s) is occuring at the cutoff. The response at the cutoff is 1/2Rj, the magnitude is 1/2R. Respectively the magintude of the 4-pole at the cutoff is 1/(2R')^2. Equating
1/2R=1/(2R')^2
or
2R=4R'^2
or
R/2=R'^2
we have
R'=sqrt(R/2)

Post

So, the exact solution for the case of cascading identical biquads.

Given a biquad lowpass H(s)=1/(1+2Rs+s^2)
The reciprocal of its squared amplitude response is
A(w)=|1+2Rjw-w^2|^2=(1-w^2)^2+4R^2w^2

Differentiating in respect to w^2:
dA/d(w^2)=2(w^2-1)+4R^2.
We are looking for the minimum of A(w):
2(w^2-1)+4R^2=0
1-w^2=2R^2
w^2=1-2R^2
Notice that the solution exists only when R<=1/sqrt(2). The threshold corresponds to the Butterworth 2-pole.
For the found w we have
Apeak=A(w)=(2R^2)^2+4R^2(1-2R^2)=4R^4+4R^2-8R^4=4R^2(1-R^2)
The peak amplitude response value is 1/sqrt(Apeak)

Considering a cascade of N biquads of the form H'(s)=1/(1+2R's+s^2)
we have the peak amplitude of each biquad equal to 1/sqrt(A'peak)
where A'peak=4R'^2(1-R'^2)
and the peak amplitude of the total chain is 1/sqrt(A'peak)^N

We wish
1/sqrt(A'peak)^N = 1/sqrt(Apeak)
that is
A'peak=Apeak^(1/N)
4R'^2(1-R'^2)=(4R^2(1-R^2))^(1/N)
Introducing C=(4R^2(1-R^2))^(1/N) we have
4R'^2(1-R'^2)=C
R'^2-R'^4=C/4
R'^4-R'^2+C/4=0
R'^2=(1+-sqrt(1-C))/2
Now notice that the value for the + gives R' larger than 1/sqrt(2) and thus is inacceptable.
That leaves us with
R'^2=(1-sqrt(1-C))/2
and
R'=sqrt( (1-sqrt(1-C))/2 )

The cutoff adjustment can be made from
w^2=1-2R^2
w'^2=1-2R'^2
which allows to compute the ratio of the peak frequencies:
w/w'=sqrt( (1-2R^2)/(1-2R'^2) )
However this could give poor results for low resonance (R close to the threshold value).

Post

Mayae wrote:I was actually looking for exactly the same information, oddly enough :)

I found the tables but was seeking a generic solution, so thanks for the very exhaustive answer mystran.
r b-j gives here some advice for Butterworth type filter ...

Code: Select all

Q = 1/( 2*sin((pi/N)*(n + 1/2)) ) , where  N = filter order and {0 <= n < (N-1)/2}
Example for 4th order :
Q(1) = 1/( 2*sin((pi/N)*(0 + 1/2)) ) ==> Q1 = 1.30656
Q(2) = 1/( 2*sin((pi/N)*(1 + 1/2)) ) ==> Q2 = 0.541196

... is this a generic solution?
Last edited by juha_p on Mon Feb 27, 2023 7:05 am, edited 1 time in total.

Post

It seems that the generalized TSK filters I suggested above are not a nice option, as their amplitude response has a dip before the peak.

However it seems that Butterworth filter design is generalizable to a filter with resonance peak. Just instead of classical Butterworth design equation:
|H|^2 = 1 / (1 + w^(2N))
use
|H|^2 = 1 / (1 - k * w^N + w^(2N))
where 0 <= k <= 2 is the "resonance amount".

The resulting curve will not have a dip.

Not sure yet if it works for odd orders (although probably it does).

For a 4-pole filter the solution is very nice and simple. You just get a cascade of two 2-poles with identical cutoffs, whose dampings are related as R1^2+R2^2=1, where the damping is the coefficient in the denominator of the transfer function: 1+2Rs+s^2.

Practically, this means that R1>=1/sqrt(2) and R2<=1/sqrt(2). I didn't derive the explicit dependency of R1 and R2 on k, but it's not really needed. Just specify e.g. R2, then you know R1.

Post

So the derivation and the poles of a resonating Butterworth are as follows.

We slightly change the notation:
|H(s)|^2= 1 / (1 - 2kw^N + w^(2N))
where 0<=k<=1, or, actually -1<=k<=1. k=0 corresponds to Butterworth, k > 0 adds resonance, k < 0 somewhat dampens the resonance below Butterworth.

First let x=w^N. Then
1-2kw^N+w^(2N)=1-2kx+x^2=(1-kx)^2 + (1-k^2)x^2 >= 0
Furthermore, at w=x=0 this function is equal to 1, it decreases on x in [0,k], has a minimum at x=k (the minimum of this function corresponds to the resonance peak) and increases for x>k.

To find the poles we solve 1-2kx+x^2=0 for x:
x=k+-j*sqrt(1-k^2)
Notice that x is lying on a unit circle.

And then w = x^(1/N), where the power is taken in the complex root sense. Since |x|=1, so also |w|=1. Recalling that s=jw we can find the values of s (the poles). Notice that |s|=1.

Instead of finding the positions of the poles directly, it might be simpler to perturb the Butterworth solution (occurring at k=0). Notice that if we change k from 0 to some other value, then x will move along the unit circle by some angle a, where the two different solutions corresponding to +- signs will move in the opposite direction. The corresponding values of w will lie on the unit circle and their angle will shift by +-a/N.

Notice that for k close to 1 (k<1) the values of w corresponding to the two solutions for x will be interleaved on the unit circle. Indeed, for k=1 the two solutions for x coincide, and for k very close to 1 they should be very close together.

Now, for k=1 we have a single solution for x and N different solutions for w equally spaced on the unit circle. As k decreases each of the solutions splits into two different ones, which begin to move in the opposite directions (on the unit circle) by the same angle. At some point all solutions for w will become equally spaced. As we know, this corresponds to the Butterworth case. Further decreasing k, we get the solutions move further until they "overlap". This should happen when then move further by the same angle as the angle which they moved from k=1 to k=0. This should occur at k=-1, as the angle by which x moves from k=1 to k=0 is equal to respective movement angle from k=0 to k=-1.

Thus, in order to make the Butterworth filter resonate we should shift its "even and odd" poles on the unit circle in the opposite directions by the same angle (the shift should be small enough, so that the poles do not overlap). At k=1 two of the poles will get on the imaginary axis, at which point the resonance is infinite.

Notably for odd N the above procedure will not result in a real filter, as the complex poles will not build mutually conjugate pairs.

Examples.

N=2. Butterworth poles are a complex conjugate pair at 45 degrees from the negative real axis. At k=-1 we get two coinciding poles at s=-1, at k=1 two poles at s=+-j. The same as a usual 2-pole.

N=4. Butterworth poles are two pairs at 22.5 and 67.5 degrees respectively (spaced at 45 degrees). At k=1 two poles are at s=+-j, two are at s=-1. Since the poles are symmetric relative to the 45 degrees line, their angles are related as a1+a2=90. Recalling that the damping R=cos(a), from cos^2(a1)+cos^2(a2)=1 we get R1^2+R2^2=1.

And so on.

Edit: in order to exactly specify the resonance peak height, recall that the resonance peak occurs at x=k, where 1-2kx+x^2=1-2k^2+k^2=1-k^2
Thus the peak amplitude response is
|H|^2=1/(1-k^2)
that is
A=|H|=1/sqrt(1-k^2)
where A is the peak value.
Thus 1-k^2=1/A^2
k^2=1-1/A^2
k=sqrt(1-1/A^2)
Knowing k, we find the angular shift of x (in respect to the position at k=0) from sin(a)=k. The angular shifts for w and s are a/N.

Post

It's an interesting observation that the design amplitude response
|H|^2= 1 / (1 - 2kw^N + w^2N)
can be obtained from the response of a 2-pole filter
H= 1 / (1 + 2Rs + s^2)
s = jw
H= 1 / (1-w^2 + 2Rjw)
|H|^2 = 1 / ( (1-w^2)^2 + 4R^2w^2 ) = 1 / ( 1 - 2(1-2R^2)w^2 + w^4 )
Now substitute w^2 <- w^N
|H|^2 = 1 / ( 1 - 2(1-2R^2)w^N + w^2N )
k = 1-2R^2

At R=1/sqrt(2) we have k=0 (Butterworth)

That is the amplitude response of the resulting filter is simply the 2-pole amplitude response, warped by the w^2 <- w^N mapping.

This also implies that one could attempt to design such filters for k < -1 ( R > 1 ), but that's probably not very interesting anyway.

Post

Notably, from the idea of w^2 <- w^N substitution it immediately follows, that the same poles can be used to make highpass (just put s^N into the numerator) and bandpass (put s^(N/2)) filters or any other kind of modal mixture of an SVF.

Furthermore, applying the similar substutution w <- w^N (where N can also now take odd values) to 1-pole filters we can make "non-resonating Butterworth" filter versions from 1-pole modal mixtures (shelving and allpass).

Post

I've used a "permutation" approach based on the idea that for 2-poles Q gives the gain at resonant frequency directly. You can then factor out the -3dB for Butterworth prototype and bump the Q of the poles to match the 2-pole gain, one way or another (distributing the "extra gain" to all the pole-pairs equally works pretty well). You don't even need to worry about transfer functions, because in the Butterworth case all poles are on the same angular frequency anyway, so it's enough to work with the Q values directly.

Working from a Butterworth prototype though and simply messing with the Q values, you tend to get peaks that get more narrow as the order increases, which is not necessarily that musical sounding. in fact the 4-poles known for being "musical" generally do the opposite, moving the second pole-pair up in frequency to smooth out the cutoff region further compared to a two-poles.

But like.. it depends on what you want.

Post

@mystran: Part of the question was "how to compute Q for different biquad sections". I was just trying to develop something which easily generalized to order N, while still sounding "reasonably". And, after having quickly implemented them, I should say they do sound reasonably.

The resonance peak width problem which you are mentioning is definitely a valid point, although I'm not sure if it really needs to be addressed for orders higher than 4 (where Moog ladder offers a nice solution). I was giving some thought to the question whether Moog ladder transfer function (which I guess is the one you're primarily referring to, when talking about moving the second pole pair up in frequency) is somehow generalizable to higher orders, esp. while keeping only one pair of poles resonating, but so far without much success.

In case you're interested, I tried to formulate the problem as follows:
- the lowpass should have no zeros
- only one pole pair should be resonating at most (that is, the damping is allowed to become smaller than for the 2-pole Butterworth position)
- non-resonating pole pairs may not have cutoffs lower than the resonating pair
- at zero resonance all poles should coincide
- the amplitude response should be growing from DC to the peak, afterward it should be decreasing
- (optional) at N=4 the solution should coincide with the Moog ladder
- (optional) the transfer function should allow a nice topological implementation, not just a series of Biquads
:wink:

Post

mystran wrote:I've used a "permutation" approach based on the idea that for 2-poles Q gives the gain at resonant frequency directly. You can then factor out the -3dB for Butterworth prototype and bump the Q of the poles to match the 2-pole gain, one way or another (distributing the "extra gain" to all the pole-pairs equally works pretty well).
I wonder if in this case the monotonicity of the amplitude response before and after the peak is guaranteed (probably it is, but who knows). In that respect, I wonder, if there are any reasonably generic sufficient conditions for this property ;)

Post

Z1202 wrote:@mystran: Part of the question was "how to compute Q for different biquad sections". I was just trying to develop something which easily generalized to order N, while still sounding "reasonably". And, after having quickly implemented them, I should say they do sound reasonably.
Yes, I just wanted to share my observation that you CAN start from straight Butterworth and then adjust the Q values directly and get something sensible. Again, for a 2-pole the Q value gives the gain at the angular frequency directly and this a rather useful property that can be used directly if the goal is to match the peaks of a 2-pole with a higher order filter of the type where all poles share the same angular frequency.
I was giving some thought to the question whether Moog ladder transfer function (which I guess is the one you're primarily referring to, when talking about moving the second pole pair up in frequency) is somehow generalizable to higher orders, esp. while keeping only one pair of poles resonating, but so far without much success.
Well, Moog and various diode-ladders etc. The second pole-pair of Moog is resonant in the sense it's not on the real-axis, but not enough to manifest itself as a distinct peak... but yeah, that was more like a random observation.

Post

mystran wrote:Yes, I just wanted to share my observation that you CAN start from straight Butterworth and then adjust the Q values directly and get something sensible. Again, for a 2-pole the Q value gives the gain at the angular frequency directly and this a rather useful property that can be used directly if the goal is to match the peaks of a 2-pole with a higher order filter of the type where all poles share the same angular frequency.
Ironically (or not) the method that I ended up with (and described above) does start from straight Butterworth and adjusts the Q. In the result you get a filter whose amplitude response is exactly the one of a 2-pole, just compressed in the logarithmic frequency scale :D
And I just started doing the same to 1-poles, works quite nicely. E.g. you can get a high-order shelving filter without resonance peaks and dips.
mystran wrote:Well, Moog and various diode-ladders etc. The second pole-pair of Moog is resonant in the sense it's not on the real-axis, but not enough to manifest itself as a distinct peak...
Typically I'd refer to a pair of complex-conjugate poles as resonating (2-pole damping R<1) and real poles (2-pole damping R>=1) as non-resonating. However sometimes it's more convenient to consider only R < 1/sqrt(2) as a resonance, because that's where the peak begins to appear. Thus 2-pole Butterworth is the threshold between the two areas.

Post Reply

Return to “DSP and Plugin Development”