I am implementing EQ lines in my filter. I need to do biquad with slope 24 db/oct, 36/oct and bigger so I would like to cascade several biquads. I am stuck with calculating frequency response of two biquads - now I am able to calculate magnitude and phase and draw one curve (peak filter). Should I multiply this response by itself? Thank you in advance for the answers.
3 Answers
The application of a filter to a signal in the time domain is defined as convolution. Convolution in the time domain is mathematically equivalent to multiplication in the frequency domain. So if we filter a signal, and then filter the output of the first filter, this is equivalent to multiplying the signal by both filters in the frequency domain. Therefor, this is equivalent to filtering with a third single filter whose frequency response is equal to the product of the first two filters’ frequency responses. Because frequency responses are complex numbers, the resulting magnitude is equal to the product of the two input magnitudes and the resulting phase is the sum of the input phases. This can be easily extrapolated for more than two filters as well.
Should I multiply this response by itself?
The transfer function of some cascaded biquads is simply the complex multiplication of the individual transfer functions, i.e. magnitudes are multiplied and phases are added.
It's much more efficient to design the filter at the desired order and property and then break it into biquads than the other way around. If you want a 36dB/octave filter, just design a 6th order Butterworth filter and don't cascade three second order Butterworth filters.
-
$\begingroup$ Note that magnitude as a ratio is multiplied. If you're using magnitude in dB then you add them -- because a dB is log ratio, and log this + log that = log (this * that). $\endgroup$ Commented Dec 2, 2020 at 18:55
-
$\begingroup$ Maybe it's just semantics but "magnitude" means linear amplitude and once it's in dB I would call it either "log magnitude" or just level. $\endgroup$– HilmarCommented Dec 3, 2020 at 18:00
-
$\begingroup$ It is "just" semantics -- but that doesn't mean it won't tangle people up. "Log magnitude" certainly clarifies the meaning -- or saying "the magnitude is 20dBm" is pretty unambiguous. $\endgroup$ Commented Dec 3, 2020 at 22:26
Thank you for the answer, but i need some clarification - i think i am missing something important to draw this plot. I am doing steps below:
- calculate in for loop freq response of standard biquad (peak) and get array of complex responses
- get abs() from each response and it gives me magnitude for given frequency on plot
- do 20 * log10(magn) to get values in dB and i am getting for example peak line with min in -9dB
- Phase i am calculating for each magnitude in first biquad using atan2(imag(freqRes)/real(freqRes)).
Then i am trying to calculate 4th order so cascading the biquad:
- each complex response from previous biquad i am multiplying by itself (freqRes)^2
- an multiply it by exp(2jphase) so (freqRes)^2 * (cos(2jphase) + sin(2j*phase)
- and do an abs() and 20log() from this value
I am getting incorrect values - instead of curve with max/min gain in -9 dB and steeper slope i have -18 dB. Maybe i am using phase incorrectly?
-
$\begingroup$ Hello @Mike91, I am assuming you are the OP. Instead of posting an answer as an extension to your initial question, please use the same account used when posting the initial question and edit the question there with the clarifications needed. $\endgroup$– GillesCommented Dec 2, 2020 at 8:54
-
$\begingroup$ Hello @Gilles, actually i post questions as guest without account and don't have access to it. $\endgroup$– Mike91Commented Dec 2, 2020 at 9:43
-
$\begingroup$ it's best you open an account if you want a better follow up. Also to better comment on the answers people freely provide to your question, and if satisfied to upvote/accept those answers. $\endgroup$– GillesCommented Dec 2, 2020 at 10:26