Calculating Q factor for cascading biquads

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Hello.

I'm having a play with the RBJ biquads. I want to cascade multiple filters to get a steeper roll-off. I've set the Q factor to 0.701 for a flat corner, however cascading multiple filters with the same Q starts to increase gain around the cutoff.

I've found a couple of resources that give examples of the different Q factor values for different filters, but nothing about how to actually calculate the different Q. Is there any formula to calculate the different Q values, from any given value, for any number of filters?

Cheers in advance.

Post

mibix wrote:Hello.

I'm having a play with the RBJ biquads. I want to cascade multiple filters to get a steeper roll-off. I've set the Q factor to 0.701 for a flat corner, however cascading multiple filters with the same Q starts to increase gain around the cutoff.
The exact Q you want for a "maximally flat" 2-pole filter (known as Butterworth) is sqrt(.5) which is about 0.707, but it gets a bit more complicated for higher orders. The good news is that the specific design for this particular type of filter is pretty simple.

On analog s-plane you simple arrange the poles into a half-circle of radius matching your cutoff. This is actually the case even for the 2-pole filter, since the Q=sqrt(.5) puts the poles at 45 degree angle from the real axis.. but let's say you had 3 poles instead, then you'd put one on the real-axis and the other two at 60 degrees angles in two directions... and so on.

If you take the BLT of such an analog filter, you'll get a maximally flat digital filter and although the poles still sit on an circular arc, you probably don't want to bother trying to design these directly in the digital domain, because it's way easier to do it in analog and then transform the result.

Anyway.. back to the good news: all the poles are at the same distance (or "cutoff" if you want) so solving the Q values becomes pretty easy. To place a pole at p (which should have a negative real part for stability) on the s-plane all you simply have 1/(s-p).

So we can put one at -exp(i*w) and the other at -exp(-i*w) and using exp(i*w) = cos(w)+i*sin(w) we get:

1/((s + exp(i*w))*(s + exp(-i*w)) = 1/(s^2 + 2*cos(w)*s + 1).

Since the formula for a unit-cutoff 2-pole lowpass is 1/(s^2 + s/Q + 1) we have Q=1/(2*cos(w))!

For 2-pole we have 45 degrees, ie. w=pi/4 and Q = 1/(2*cos(pi/4))=sqrt(.5) but now you can put any arbitrary amount of pole-pairs at equal angles from each other in a similar fashion and calculate the Q values (if you have an odd-order filter, the last one goes at real axis) and then you can just design digital filters with these Q values and get a maximally flat filter when you put them in series (as long as you use the same cutoff for all of them).

Note that for RBJ, you need to use the "case Q" version that uses the "raw" Q value directly.

Now... if you want something other than maximally flat.. then things get complicated because a single "Q" value is only sufficient to describe the shape of 2nd order filter. As should be obvious from the above, for higher order filters you have more flexibility to combine different Q values (and different cutoff values too) ... but like the Butterworth case is pretty easy (and if you're really lazy, just google "butterworth Q values" and you can find tables where someone else calculated them for you). ;)

Post

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.

Post

mystran wrote:Now... if you want something other than maximally flat.. then things get complicated because a single "Q" value is only sufficient to describe the shape of 2nd order filter. As should be obvious from the above, for higher order filters you have more flexibility to combine different Q values (and different cutoff values too) ... but like the Butterworth case is pretty easy (and if you're really lazy, just google "butterworth Q values" and you can find tables where someone else calculated them for you). ;)
I'm hoping to summon you again, mystran :)

So I just hit this case, having N cascaded 2nd order filters, and starting with one Q value I'm hoping to design the cascade such that the transfer function |H(w)| equals that of a single 2nd order filter's |H(w)|, or put another way: Ensure the transfer function's magnitude at the resonant frequency for the cascade matches the standard 2nd order filter for a given Q.

I believe the transfer functions are simply multiplied, but I'm not sure how this connects to solving for the separate Q values in the cascade. I thought your example above made sense for the design Q of sqrt(0.5), ie. the butterworth response, but for any other starting Q are you supposed to alter the "spacing" of the poles in the s-plane? I don't see how anything else can affect the outcome, otherwise since the Q is a direct result of the pole angle

Post

I may remember this wrong, but think I recall that some of the old analog FC and Q tables for the fancier high-order responses were generated with MiniMax type computer techniques to best-fit for instance 6th order 3 dB ripple Chebyschev or whatever.

Or maybe the engineers who used such techniques just found it easier to do it thataway rather than do the abstract math to figure it out "from basic principles".

Post

JCJR wrote:I may remember this wrong, but think I recall that some of the old analog FC and Q tables for the fancier high-order responses were generated with MiniMax type computer techniques to best-fit for instance 6th order 3 dB ripple Chebyschev or whatever.

Or maybe the engineers who used such techniques just found it easier to do it thataway rather than do the abstract math to figure it out "from basic principles".
Actually certain minimax setups allow analytic solutions. I believe they were developed before the numeric approach (Remez minimax algorithm) or even the appearance of computers, so that the computations could be done manually. Chebyshev filters is one case of those, where you can gain a more steep cutoff curve of the filter by allowing "minimax" ripples either in the passband or in the stopband. In the limit (zero ripple amplitude) they turn into Butterworth. An even further generalization for which analytic solution exists is the elliptic (Cauer-Zolotaryov) filter, which allows to simultaneously have ripples in the passband and in the stopband. In the limit (zero passband ripples or zero stopband ripples) it turns into Chebyshev filter.

Post

Mayae wrote:
mystran wrote:Now... if you want something other than maximally flat.. then things get complicated because a single "Q" value is only sufficient to describe the shape of 2nd order filter. As should be obvious from the above, for higher order filters you have more flexibility to combine different Q values (and different cutoff values too) ... but like the Butterworth case is pretty easy (and if you're really lazy, just google "butterworth Q values" and you can find tables where someone else calculated them for you). ;)
I'm hoping to summon you again, mystran :)
You just need to sacrifice a couple of dozen virgins. ;)
I believe the transfer functions are simply multiplied, but I'm not sure how this connects to solving for the separate Q values in the cascade. I thought your example above made sense for the design Q of sqrt(0.5), ie. the butterworth response, but for any other starting Q are you supposed to alter the "spacing" of the poles in the s-plane? I don't see how anything else can affect the outcome, otherwise since the Q is a direct result of the pole angle
If you put multiple filters in series, then their combined response is indeed the product of the individual responses, but this won't give you any Butterworth responses by simply stacking fixed-Q filters. You get Butterworth (of order N which doesn't need to be even) by building a circle of 2*N points with even angles around origin, throwing away the points with positive real coordinate and putting individual poles at the rest of them. Once you combine conjugate pairs to biquads make the filter real-valued, the Q values for each conjugate pair (=biquad) can then be solved from the first-order terms of the respective denominators. For the 2nd order case this procedure happens to result in a single pole-pair at 45-degrees from either axis, which solves into Q=sqrt(.5) for this particular pole-pair, but there is (one!) such a pole pair only in Butterworth filters of orders of 2^k for k=1,2,3...

In general though, Butterworth is bit of a special case since all the poles are placed at the same angular frequency, which is not really the case for most classic higher-order designs. The same principle applies though if you can build the filter by placing poles (or realistically pole-pairs in an actual implementation). The other possible option is to factor the roots from some suitable polynomial (whether closed form or a fit/tailor expansion/whatever over some non-polynomial formula). You can obviously do other stuff too, and I'm not sure if this answers your question.. but when it comes to higher order filters, trying to thinking in terms of some global "Q" won't get you anywhere. :)

Post

Mayae wrote:I believe the transfer functions are simply multiplied, but I'm not sure how this connects to solving for the separate Q values in the cascade. I thought your example above made sense for the design Q of sqrt(0.5), ie. the butterworth response, but for any other starting Q are you supposed to alter the "spacing" of the poles in the s-plane? I don't see how anything else can affect the outcome, otherwise since the Q is a direct result of the pole angle
The idea of the Butterworth is to get a "maximally flat" response. If you stack two 2-pole Butterworth in serias you will get a 4-pole filter with a flat response, but you can do better than that. The steepness of the cutoff can be pushed a bit further while still having no ripples by tuning the Q's of different stages differently. This is what the Butterworth approach does.

Post

Hi JCJR, mystran & Z - thanks for chiming in, and thanks for the knowledge! As suspected I'm looking for the analytical solution
mystran wrote:You can obviously do other stuff too, and I'm not sure if this answers your question.. but when it comes to higher order filters, trying to thinking in terms of some global "Q" won't get you anywhere. :)
I realize there are many degrees of freedom with higher orders, but for this particular case I'll be designing a filter with poles all at the same frequency, while trying to solve the required Q values for the 2nd order cascades. Or in other terms, depicted is a 2nd order filter and a 4th order filter:

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).
mystran wrote:If you put multiple filters in series, then their combined response is indeed the product of the individual responses
I guess one way to calculate this is to relate Q and the transfer function at w, then it can be solved... but it seems backwards. Curiously, looking at a butterworth table the product of all Q values results in sqrt(0.5), but designing a cascade of order N with Q = sqrt(0.5)^(1/N) sadly doesn't produce a butterworth filter.

Your formulas work nicely for designing butterworth filters of degree N as said, but let's assume a Q of 1. Given

Code: Select all

Q=1/(2*cos(w))
Then the angle becomes

Code: Select all

w = acos(1/(2*Q)) = 60 degs (or pi/3)
If we design a 2 2th order filters, and place the poles symmetrically (around pi/2) in the negative real s-plane using unreasonable math we get pole angles of 15 degrees and 75 degrees (again spaced w degrees apart). Using

Code: Select all

Q=1/(2*cos(w))
we get the following Q values for the cascade: 0.51763809021 and 1.93185165 - which seems to be what I want! How this generalizes to any Nth order I don't really know, and at this point I'm really just screwing around... But it works for any two cascaded 2th order filter

Post

Mayae 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).
Oh, I think I can guess where you getting at. You probably want to design a resonating synth filter with a variable number of poles. I guess many DSP developers sooner or later ask themselves that question: why are there only 2- and 4-pole synth filter designs ;)

One thing to understand here is that filter designs like Butterworth, Chebyshev, elliptic etc. are not intended to serve as musical filters. So musical filters are designed in other ways, which are often more art than abstract science. They are supposed to sound good rather than mathematically correct. That said, there are not many options for a 2-pole filter, all linear resonating 2-pole filters have identical families of transfer functions. The differences if any, will lie in how the filter parameters can be controlled (that includes the response shape change artifacts in e.g. naive digital filters), in filter nonlinearities, response to modulation.

So what you need to do is "scientific art" rather than pure science. In order to find the direction you want to go in I could suggest the following analysis as a starting step. Remember that any (linear) 4-pole can be represented as a cascade of two 2-poles. Take a look at the 3 following cases:
- using two 2-poles with identical cutoff and resonance (you probably would need to lower the resonance to math the resonance of a single 2-pole)
- using two 2-poles with identical cutoff but different resonance, where one of the filters should be practically non-resonating (Q less that the one of a Butterworth 2-pole). Again you might need to match the resonance level to a single 2-pole somehow.
- using two 2-poles which are equivalent to a (linear model of a) Moog filter. Maybe also need matching the resonance level to a single 2-pole.

One other interesting case to look at is a "8-pole Moog filter" which is trivially constructed (remember, you shouldn't invert the feedback in this case).

Edit: obviously, most important is to compare sound rather than simply curves on the plot.

Also you need to keep in mind that this could help you design linear filters. Once you start thinking about introducing nonlinearities, there will be more options and more things to consider. Particularly an implementation using a cascade of 2-poles will be only one way to implement an N-pole filter, which would be missing quite a lot of possible nonlinear options.

Post

Actually, off the top of my head, as long as we are talking about musical resonating filters, probably a "musically neutral" design for an arbitrary even-order filter could be a mixture of Moog ladder and SKF (or TSK) filter designs. It can also nicely accomodate nonlinearities in the same way as the original filters do.

For an arbitrary even-order resonating bandpass, one can just use the Moog ladder approach. Simply take a cascade of resonance-neutral (transfer function denominator w^2+2ws+s^2) 2-pole bandpasses (equivalently each such bandpass is simply a cascade of 1-pole LP and HP) with feedback.

For a lowpass whose order is divisible by 4 use the same approach, but remember that the feedback needs to be inverted if N/4 is odd.

For a lowpass whose order is 4n+2 first consider an SKF or a TSK lowpass. It can be built from a 2-pole "Moog ladder" bandpass with feedback, where the 2-pole bandpass is built from a series of 1-pole LP and HP. In order to convert 2-pole bandpass into a lowpass we replace the HP filter with a multimode onepole. In SKF the series contains first HP, then LP. The HP is replaced by a multiinput multmode one pole. Its HP input being used for the feedback (so the feedback loop still contains one LP, one HP) and its LP input is being used for the input signal of the SKF. For the TSK the order is LP, then HP. The HP is replaced by a multimode multioutput 1-pole with its HP output being used for feedback and its LP output as the output signal of the TSK.

Now if we want a 4n+2 order lowpass where n>=1, we first build a Moog lowpass of order 4n, then augment the main path with a 2-pole bandpass made from 1-pole LP and HP. This bandpass may be either inserted in the beginning of the chain, then we modify it SKF-style to turn the whole into a lowpass, or at the end of the chain, in which case we modify it in the TSK style.

The highpass can be built similarly to the lowpass.

Edit: I'm actually not sure if the above will work, never tried, but it's worth taking a look.

Edit2: the idea doesn't work out of the box, but I think it might be brought into working.

Post

So, some further thoughts.

Regarding the 8-pole Moog filter, the idea to use positive feedback is not very good, since it boosts the DC. Negative feedback could work reasonably well for orders N>=4.

But back to the SKF/Moog mixture. The most "symmetic" and neutral way to do it is probably to consider the following. An SKF or TSK can be considered as a modification of a 2-pole "bandpass Moog". Instead of using a multmode 1-pole for one of the 1-poles we could split this multimode into two separate filters. Then a lowpass SKF looks like a serial connection of a feedback loop with a 1-pole lowpass (in SKF the lowpass precedes the loop, in TSK it follows the loop). The loop itself is built around a series of 1-pole LP and 1-pole HP, where the LP is in the feedforward path and HP is in the feedback path. This structure easily generalizes to an arbitrary even order. E.g. for a 4-pole we take a feedback loop with two 1-pole LPs in the ffd path and two 1-pole HPs in the fbk path and connect this in series with two 1-pole LPs. Etc.

One could save the need for additional lowpasses by using modal mixture of the feedback loop. It seems that for a lowpass it's sufficient to take a mixture of the feedback path signals (e.g. for a 4-pole: one before the first HP, one between the HP and one after) as the output signal. Another way to save the need for the additional lowpasses is to implement the resulting transfer function by a series of 2-poles, but it'll require quite some recomputation of parameters.

A highpass is built by replacing all LPs with HPs and vice versa.

A bandpass of order 2N is simply a chain of N 1-pole LPs and N 1-pole HP with a global feedback.

This could be a mathematically neutral way to design a high order filter with resonance (the neutrality is in the constant lowpass unity gain at DC and in the fact that LP, HP and BP share the same transfer function denominator). However I'm not sure if the sound will be good. One needs to try.

Post

Z1202 wrote:
Mayae 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).
Oh, I think I can guess where you getting at.
:) close, but not quite - I just have this terrible idea I need to try out!
Z1202 wrote:So what you need to do is "scientific art" rather than pure science.
Encouraging message; I already tested out your cases while messing around, and I think I'm slowly building a conceptual model of what happens.
Z1202 wrote:using two 2-poles with identical cutoff and resonance (you probably would need to lower the resonance to math the resonance of a single 2-pole)
For any Q > sqrt(0.5) yes, otherwise I assume it would need to be boosted instead..
Z1202 wrote:using two 2-poles with identical cutoff but different resonance, where one of the filters should be practically non-resonating (Q less that the one of a Butterworth 2-pole). Again you might need to match the resonance level to a single 2-pole somehow.
I believe this is where it's at.. And from an analytical perspective, there's more than one solution to matching the transfer function's product w.r.t. a single 2 pole. It doesn't help that that the resonance bump is generally not at the cutoff frequency except for higher resonances
Z1202 wrote:Edit: obviously, most important is to compare sound rather than simply curves on the plot.

Also you need to keep in mind that this could help you design linear filters. Once you start thinking about introducing nonlinearities, there will be more options and more things to consider. Particularly an implementation using a cascade of 2-poles will be only one way to implement an N-pole filter, which would be missing quite a lot of possible nonlinear options.
I do wholeheartedly agree with your sentiments, the reason I ask is that - usually - there's a way stuff is done, commonly tribal knowledge :) And this is not just to copy something else or do everything by the books, but I do think it's valuable to know these approaches in any case; either as tools or anchors you can use to research, learn and/or investigate further from. I also realize there's a whole nonlinear world out there, but this project is linear and I try to work with one subject at a time.

To completely understand your second (and third) reply, I would have to look at Moog models firstly, so you will have to excuse me from not commenting immediately!

Post

Code: Select all

2-pole "Moog bandpass"
---> + ---> LP1 ---> HP1 --------->
     ^                       |
     |                       |
      --------- *k ----------

4-pole "Moog bandpass"
---> + ---> LP1 ---> HP1 ---> LP1 ---> HP1 ------->
     ^                                        |
     |                                        |
      ------------------ *k ------------------


2-pole lowpass TSK (with multimode decomposed)
---> + ---> LP1 ------------> LP1 ---->
     ^                   |
     |                   |
      --- *k <--- HP1 ---

Proposed "neutral" 4-pole lowpass
---> + ---> LP1 ---> LP1---------------> LP1 ---> LP1 --->
     ^                             |
     |                             |
      --- *k <--- HP1 <--- HP1 <---

Equivalent modal mixture
---> + ---> LP1 ---> LP1-----------
     ^                             |
     |                             |
      --- *k <--- HP1 <--- HP1 <---
               |        |        |
               |       *(-2)     |
               |        |        |
                ------- + -------
                        |
                        v

Post

Just noticed that the modal mixture above translates a series of two HPs into an equivalent of a series of two LPs. But then one also can do vice versa, translating two LPs into two HPs which results in a more elegant structure (of a 4-pole "neutral" LP):

Code: Select all

---> + ---> LP1 ---> LP1 ---> LP1 ---> LP1 -------->
     ^                    |        |        |
     |                    |       *(-2)     |
     |                    |        |        |
     |                     ------- + -------
     |                             |
      --- *k <---------------------
Maybe this structure can be referred to as a "generalized TSK"

Post Reply

Return to “DSP and Plugin Development”