[PD] PD's biquad (all pole resonant filter)

cyrille henry ch at chnry.net
Sat Sep 12 16:14:12 CEST 2009


hello Loic,

i'm not sure if pd and max biquad are the same structure.
http://en.wikipedia.org/wiki/Digital_biquad_filter
pd use the direct form 2.
i think that max use the form 1 (but may be wrong).

i made a bq~ object that use form 1 (and using audio input for the coef).
maybe it will help.
it is on the nusmuk folder in svn. don't know about pd-extended.

Cyrille

Loic Kessous a écrit :
> Hi,
> 
> I'm trying to implement in PD a resonant all pole filter, that I used in 
> max before.
> It is using a biquad~  with some adequate coefficients.
> So I make a patch reproducing the one in max, with respect to 
> compatibility with PD, it means that I change it a little so all the 
> objects used are now common to  PD and Max.
> And this patch is working in Max correctly. I tested it with Max 4.5, 
> Mac os 10.5.8 (I don't have Max 5).
> the biquad~ is working with lowpass coefficient (using the 'lowpass' 
> external from ggee) but not with the coefficient that I want to use :-(
> 
> I thought that maybe the PD version was not accepting 0 values for the 
> second and third coefficient of the list so a put 0.000001 value instead 
> of 0 , but it doesn't seem to be this.
> 
> I had a look at Miller's code in the d_filter.c file, in [ static void 
> sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv) ]
> 
>  t_float discriminant = fb1 * fb1 + 4 * fb2;
>     t_biquadctl *c = x->x_ctl;
>     if (discriminant < 0) /* imaginary roots -- resonant filter */
>     {
>             /* they're conjugates so we just check that the product
>             is less than one */
>         if (fb2 >= -1.0f) goto stable;
>     }
>     else    /* real roots */
>     {...
>     }
>         /* if unstable, just bash to zero */
>     fb1 = fb2 = ff1 = ff2 = ff3 = 0;
> 
> 
> and I saw something about a stable criteria 'discriminant' , I wonder if 
> it is maybe a reason why it is not working with my coefficient.  they 
> are working in Max but not in PD.
> 
> if anyone know the answer, it will be very well come, it's still a 
> mystery for me.
> best,
> loic
> 
> here is my patch:
> 
> #N canvas 311 124 720 796 10;
> #X msg 256 523 0.0006 1e-06 1e-06 -1.98252 0.994522;
> #X msg 343 55 1;
> #X obj 343 31 loadbang;
> #X msg 184 71 20;
> #X obj 182 34 loadbang;
> #X msg 25 66 770;
> #X obj 25 43 loadbang;
> #X msg 398 621 0.000599788 0 0 -2 1;
> #X obj 398 598 prepend set;
> #X obj 245 657 dac~;
> #X obj 249 626 biquad~;
> #X obj 111 541 phasor~ 110;
> #X msg 448 90 44100;
> #X obj 448 65 loadbang;
> #X floatatom 381 56 0 0 0 0 - - -;
> #X floatatom 239 59 0 0 0 0 - - -;
> #X floatatom 120 66 0 0 0 0 - - -;
> #X obj 343 77 t b f;
> #X obj 205 498 * 1;
> #X floatatom 218 273 0 0 0 0 - - -;
> #X floatatom 464 374 0 0 0 0 - - -;
> #X obj 79 292 expr 1-($f2/(2*$f1));
> #X obj 460 337 f;
> #X obj 29 435 expr (1-$f1)*sqrt(1-2*$f1*cos(2*$f2)+($f1*$f1));
> #X obj 444 116 / 2;
> #X obj 78 88 t b f;
> #X obj 225 218 / 22050;
> #X obj 95 110 * 3.14159;
> #X text 96 57 fc;
> #X text 196 54 Q;
> #X obj 249 565 pack 0.0006 0 0 -1.98252 0.994522;
> #X text 557 494 b2;
> #X obj 388 458 expr -2*$f1*cos($f2);
> #X obj 519 459 expr $f1*$f1;
> #X text 61 479 a0;
> #X text 395 479 b1;
> #X text 316 56 G;
> #X connect 0 0 30 0;
> #X connect 1 0 17 0;
> #X connect 2 0 1 0;
> #X connect 3 0 21 0;
> #X connect 4 0 3 0;
> #X connect 5 0 25 0;
> #X connect 6 0 5 0;
> #X connect 8 0 7 0;
> #X connect 10 0 9 0;
> #X connect 10 0 9 1;
> #X connect 11 0 10 0;
> #X connect 12 0 24 0;
> #X connect 13 0 12 0;
> #X connect 14 0 17 0;
> #X connect 15 0 21 0;
> #X connect 16 0 25 0;
> #X connect 17 0 21 0;
> #X connect 17 0 27 0;
> #X connect 17 1 18 1;
> #X connect 18 0 30 0;
> #X connect 21 0 22 0;
> #X connect 22 0 23 0;
> #X connect 22 0 32 0;
> #X connect 22 0 20 0;
> #X connect 22 0 33 0;
> #X connect 23 0 18 0;
> #X connect 24 0 26 1;
> #X connect 25 0 21 0;
> #X connect 25 1 27 0;
> #X connect 26 0 21 1;
> #X connect 26 0 19 0;
> #X connect 26 0 23 1;
> #X connect 26 0 32 1;
> #X connect 27 0 26 0;
> #X connect 30 0 10 0;
> #X connect 30 0 8 0;
> #X connect 32 0 30 3;
> #X connect 33 0 30 4;
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list





More information about the Pd-list mailing list