[PD] Resonant filter using cpole~ czero~

Mike Moser-Booth mmoserbooth at gmail.com
Mon Feb 20 04:31:09 CET 2012


On Sun, Feb 19, 2012 at 6:12 PM, Mathieu Bouchard <matju at artengine.ca> wrote:
> Le 2012-02-19 à 17:48:00, Mike Moser-Booth a écrit :
>
>> On Sun, Feb 19, 2012 at 4:54 PM, Mathieu Bouchard <matju at artengine.ca>
>> wrote:
>>>
>>> Why would you change the signs of a and b but not c ?
>>> (Was I giving the formula relative to ax²+bx+c=0 or did I assume ax²+bx=c
>>> by
>>> accident ?)
>>
>>
>> I think it has to do with where c is in the difference equation:
>> c*y[n] = g*x[n] + a*y[n-1] + b*y[n-2]
>
>
> This equation uses a for the middle term (y[n-1]) ? Weird.

> I'd expect b to go with y[n-1], whereas a and c would go with either y[n] or
> y[n-2]...

Sorry, I kind of confused myself. I'm used to thinking of the
coefficients as a_0, a_1, etc. You're right, b should go with y[n-1],
and the one that should go with y[n] is which ever one is equal to 1,
which would be c if you think of it as a + bx + cx^2, not ax^2 + bx +
c.

To clarify, think of the z-transform of the filter as H(z) = 1/A(z),
where A(z) = 1 - 2r*cos(ω)*z^-1 + r^2*z^-2. If we decide c=1,
b=2r*cos(ω), and a=r^2, we have A(z) = c - bz^-1 + az^-2. In order to
apply the quadratic formula, those exponents need to be positive, so
you have to multiply by (z^2)/(z^2), which leaves you with H(z) = z^2
/ (cz^2 - bz +a).

That's what I meant earlier when I said a and c should be switched,
and I thought you were trying to say that you were thinking in terms
of a + bx +cx^2. ;-)

>
> BTW, the equations I used are things that I reconstituted from the source
> code of [biquad~] in pd/src/d_filter.c. They don't come from manuals.

You mean for [bp~]? The equation used for [biquad~] is in the
helpfile, if I'm not mistaken. But, yeah, that's what I'm going off
of, too.

btw, you wouldn't happen to know where the source for [vcf~] is, would
you? I'd like to know how that one works as well, but I can't find it.

.mmb



More information about the Pd-list mailing list