I'm new into DSP and Filters in general. Its the first step ahead I do from learning and using a 1-pole IIR basic Low Pass Filter.

I'm about to implement for my VST audio application (using C++ and IPlug Framework) a RBJ's Peak filter.

By steps (from that document), the formula that I'll use within my Process() function will be y[n], thus (as code):

inline double Process(double input) {
    mBuffer += (b0/a0)*x[n] + (b1/a0)*x[n-1] + (b2/a0)*x[n-2] - (a1/a0)*y[n-1] - (a2/a0)*y[n-2];
    return mBuffer;

Since I'll use peakingEQ, I need to calculate these coefficients:

b0 =   1 + alpha*A
b1 =  -2*cos(w0)
b2 =   1 - alpha*A
a0 =   1 + alpha/A
a1 =  -2*cos(w0)
a2 =   1 - alpha/A

which all depends by user defined parameters and intermediate variables.

My questions are:

  1. What's the difference between using Q (thus sin(w0)/(2*Q)) or BW (thus sin(w0)*sinh( ln(2)/2 * BW * w0/sin(w0))) on calculating alpha? Isn't Bandwidth = Q when reasoing as Peak filter?

  2. What's the meaning of H(s) function (which is (s^2 + s*(A/Q) + 1) / (s^2 + s/(A*Q) + 1) for the peaking filter)? I don't see where to "insert" it in the formulas.

I hope you can help me to undestand these two dubts.

  • $\begingroup$ uhm, "Bandwidth" cannot equal "Q" everywhere because they are monotonic decreasing functions of each other. if you keep the definition between bandwidth (in octaves) and Q that you get with the -3 dB bandedges of the BPF, then $$ \frac1Q = 2 \sinh \left( \frac{\ln(2)}{2} BW \right) $$ is the relationship between the two. but there is a difference in definition of the bandedges in the Cookbook BPF and Peaking filter. (and the Q in the peaking is not the same as the EE definition of Q). $\endgroup$ Nov 12, 2016 at 23:47
  • $\begingroup$ Oh... wow, you are RBJ :) Nice to talk with the genius himself. Big up for your intensive work, shared free for everyone! I think human being deserve more people like you. Well, I'm not a proper matematician, thus I didn't totally get what you mean. Usually on plugin when I switch between lowpass or peak, it keeps the same q (or bandwidth) param. At this point I think only the name remain the same, internally the coefficients change. So in my case (peak filter) I calculate alpha using the bandwidth formula right? $\endgroup$
    – markzzz
    Nov 13, 2016 at 18:46
  • $\begingroup$ when Q gets higher, then BW gets skinnier. one number goes up when the other goes down. so they can't be the same thing, but they are about the same thing. it's like sample rate vs. sampling period. one goes up when the other goes down. but they are referring to the same thing. they are not two independent quantities. Think of Q and BW as being two different sets of tick marks going around the same knob. (and my email is readily visible. i'm easy to get a hold of, but i am not always quick to respond.) $\endgroup$ Nov 14, 2016 at 2:04
  • $\begingroup$ @robertbristow-johnson: I see. The fact is: on your code, you write "case Q" and "case BW", which means two different alphas. Since I'll use peaking filter, which alpha should I use? The one using Q (sin(w0)/(2*Q)) or the one using BW (sin(w0)*sinh( ln(2)/2 * BW * w0/sin(w0)))? I need only one alpha right? $\endgroup$
    – markzzz
    Nov 14, 2016 at 14:00
  • $\begingroup$ @robertbristow-johnson; in this code for example: musicdsp.org/showone.php?id=128 . When should I pass q_is_bandwidth as true? Only for peaking? $\endgroup$
    – markzzz
    Nov 15, 2016 at 13:24

1 Answer 1

  1. Maybe this thread helps you in this Q - Prewarping both resonant frequency $f_0$ and bandwidth (or $Q$) when using bilinear transform

  2. H(s) is the s-plane transfer function

    Analog prototype of RBJ peak filter (Octave):

K  = 10^(gain/40);
w0 = 2*pi*fc;
% H(s) = (s^2 + (K w0/Q)*s + w0^2) / (s^2 + w0 s/(K*Q) + w0^2)
BC = [1 K*w0/Q w0^2];
AC = [1 w0/(K*Q) w0^2];

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.