[PD] can [bp~] be obtained with biquad coefficients?
Alexandre Torres Porres
porres at gmail.com
Wed Apr 9 19:20:05 CEST 2014
"I'd start with a look at the [bp~] source to see if you can extract some
hints about how the filter is implemented."
Anyway, this is what I got from the code. But I wasn't successful to
extract biquad coefficients from it. I still assume it can be done. It says
it's a 2-pole bandpass filter, so I understand you can get to it with
biquad, cause biquad is 2-pole and 2-zero. It's just a matter to get rid of
the zeros somehow. I was able to leave them with a vlue of 0, but didn't
seem to do the job.
thanks
static t_float sigbp_qcos(t_float f)
{
if (f >= -(0.5f*3.14159f) && f <= 0.5f*3.14159f)
{
t_float g = f*f;
return (((g*g*g * (-1.0f/720.0f) + g*g*(1.0f/24.0f)) - g*0.5) + 1);
}
else return (0);
}
static void sigbp_docoef(t_sigbp *x, t_floatarg f, t_floatarg q)
{
t_float r, oneminusr, omega;
if (f < 0.001) f = 10;
if (q < 0) q = 0;
x->x_freq = f;
x->x_q = q;
omega = f * (2.0f * 3.14159f) / x->x_sr;
if (q < 0.001) oneminusr = 1.0f;
else oneminusr = omega/q;
if (oneminusr > 1.0f) oneminusr = 1.0f;
r = 1.0f - oneminusr;
x->x_ctl->c_coef1 = 2.0f * sigbp_qcos(omega) * r;
x->x_ctl->c_coef2 = - r * r;
x->x_ctl->c_gain = 2 * oneminusr * (oneminusr + r * omega);
/* post("r %f, omega %f, coef1 %f, coef2 %f",
r, omega, x->x_ctl->c_coef1, x->x_ctl->c_coef2); */
}
2014-04-08 22:21 GMT-03:00 Alexandre Torres Porres <porres at gmail.com>:
> "I'd start with a look at the [bp~] source to see if you can extract some
> hints about how the filter is implemented."
>
> Done that, way out of my head. What I can deal with is wether I can get to
> it with biquad coefficients.
>
> thanks
>
>
>
> 2014-04-08 21:28 GMT-03:00 Bill Gribble <grib at billgribble.com>:
>
> The quick and dirty way is just to feed the filter white noise and plot
>> the output signal's spectrum. Guaranteed to show the actual performance
>> of the filter, and not somebody's idea of how it ought to be working.
>>
>> If you need a theoretical curve, I'd start with a look at the [bp~]
>> source to see if you can extract some hints about how the filter is
>> implemented. It may be quite easy to figure out the poles and zeros if the
>> code is clear and/or documented.
>>
>> Good luck!
>> Bill Gribble
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20140409/8a11168b/attachment.htm>
More information about the Pd-list
mailing list