Friday, July 28, 2017

How to derive Q from r in this filter definition?


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.



Answer



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.


No comments:

Post a Comment

periodic trends - Comparing radii in lithium, beryllium, magnesium, aluminium and sodium ions

Apparently the of last four, $\ce{Mg^2+}$ is closest in radius to $\ce{Li+}$. Is this true, and if so, why would a whole larger shell ($\ce{...