3
$\begingroup$

I am trying to build a resonance filter with real-time control of both center frequency and Q. I've come across what looks to me like a suitable "recipe" for a second-order IIR filter that might do the job, at http://www.music.mcgill.ca/~gary/307/week2/filters.html (toward the bottom of the page, quoted here with some loss of formatting):

$$y[n] = x[n] - a_1 y[n-1] - a_2 y[n-2]$$

where $a_1 = -2r \cos(2 \pi f_0 T) \\ a_2 = r^2 \\ f_0 = \text{resonant frequency} \\ T = \text{sampling period} $

or more "refined:"

$$y[n] = b_0 x[n] + b_1 x[n-1] + b_2 x[n-2] - a_1 y[n-1] - a_2 y[n-2]$$ where $ b_0 = \frac{1 - r^2}{2} \\ b_1 = 0 \\ b_2 = -b_0 $

The text says of the parameter $r$ that "the closer $r$ is to 1.0, the narrower the bandwidth of the resonance peak." This sounds to me like the definition of $Q$, but I suspect that it's not identical.

My question: What is the relationship between $r$ above and the more usual filter parameter $Q$?

I am just beginning to learn (self-teach) how to build filters, and I am still unclear on some of the concepts. Thanks in advance for any help.


See also this question and its answer.

$\endgroup$
9
  • 2
    $\begingroup$ there are multiple ways of mapping an analog or continuous-time filter (in which $Q$ has an unambiguous definition) to a digital or discrete-time filter. what you have expressed in your question is a discrete-time filter. so it depends on how it maps back to the continuous-time filter. usually the choice is between Impulse Invariant mapping or Bilinear Transform. so you have to choose which one (or another completely different mapping). it you choose Bilinear Transform, then checkout the Audio EQ Cookbook. $\endgroup$ Commented Nov 10, 2015 at 23:47
  • $\begingroup$ Note that $f_0$ in your formula is not the resonant frequency, i.e. it's not the frequency where the peak of the magnitude response occurs. It is the pole frequency. Its relation to the actual resonant frequency $f_r$ is $$\cos(2\pi f_r)=\frac{2r\cos(2\pi f_0)}{1+r^2}$$ $\endgroup$
    – Matt L.
    Commented Nov 11, 2015 at 8:11
  • $\begingroup$ i don't think i agree with @MattL regarding the Bilinear tranformation. and if it's different regarding Impulse Invariant, i think there might be a factor of $\sqrt{4 Q^2 - 1}$ in there, but i haven't yet checked it out. admittedly i didn't want to crank through the whole math over again. $\endgroup$ Commented Nov 11, 2015 at 18:54
  • $\begingroup$ @robertbristow-johnson: If you check the OP you'll find that $a_1=-2r\cos(2\pi f_0 T)$, which makes it clear that $f_0$ is the pole frequency, not the peak frequency (as in your formulas). Has absolutely nothing to do with bilinear or impulse invariant etc. Not sure why you don't agree (or at least think you don't ...). $\endgroup$
    – Matt L.
    Commented Nov 11, 2015 at 20:37
  • $\begingroup$ Matt, i know this is hard for you to believe, but you're wrong again. if you look at the cookbook, you will see that very same $-2 \text{ something } \cos(2 \pi f_0 T)$ for $a_1$. and i know first hand and very intimately, that $2 \pi f_0$ corrosponds to the $\Omega_0$ that you will find in the denominator of an analog biquad: $$ H(s) = \frac{b_0 + b_1 s + b_2 s^2}{\Omega_0^2 + \frac{\Omega_0}{Q}s + s^2} $$ now if you try to tell me that this $\Omega_0$ is anything other than what we call the "resonant frequency", all i can do in response is giggle. $\endgroup$ Commented Nov 11, 2015 at 21:10

1 Answer 1

1
$\begingroup$

I'll give you one quick answer (without proofs).

If your mapping from $s$ to $z$ is the Bilinear Transform, then

$$ Q = \frac{\sin(2 \pi f_0 T)}{2} \frac{1 + r^2}{1 - r^2} $$

If it's Impulse Invariant, I think it's

$$ Q = -\frac{\pi f_0 T}{\ln(r)} = -\frac{2 \pi f_0 T}{\ln(r^2)} $$

For high $Q$ and reasonably low $f_0 T$, the two expressions come out nearly equal.

$\endgroup$
3
  • $\begingroup$ Robert, your $f_0$ is not the same as the OP's $f_0$. This will cause misunderstandings. Your $f_0$ is the peak frequency, whereas the OP's $f_0$ is the pole frequency. I also left a comment for the OP to clear this up. $\endgroup$
    – Matt L.
    Commented Nov 11, 2015 at 8:12
  • $\begingroup$ take a look at $b_0$, $b_1$, and $b_2$. it's a bandpass filter. the peak frequency and resonant frequency are the same thing. but i take your point, in the Impulse Invariant transformation, i may have $2\pi f_0 T$ as the angle the pole has against the $\Re\{z\}$ axis. $\endgroup$ Commented Nov 11, 2015 at 18:52
  • $\begingroup$ I know it's a band pass, but even there pole and resonant frequency are generally not equal. Check (your own) cookbook for the $a_1$ coefficient and you'll see what I mean. $\endgroup$
    – Matt L.
    Commented Nov 11, 2015 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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