[PD-cvs] pd/src builtins_dsp.c,1.1.2.30,1.1.2.31
Mathieu Bouchard
matju at users.sourceforge.net
Thu Jul 19 21:57:17 CEST 2007
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18303
Modified Files:
Tag: desiredata
builtins_dsp.c
Log Message:
interleaved code of hip~ lop~
Index: builtins_dsp.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/builtins_dsp.c,v
retrieving revision 1.1.2.30
retrieving revision 1.1.2.31
diff -C2 -d -r1.1.2.30 -r1.1.2.31
*** builtins_dsp.c 19 Jul 2007 19:35:19 -0000 1.1.2.30
--- builtins_dsp.c 19 Jul 2007 19:57:15 -0000 1.1.2.31
***************
*** 2337,2371 ****
/* ---------------- hip~ - 1-pole 1-zero hipass filter. ----------------- */
! struct t_hipctl {
! float x;
! float coef;
! };
! struct t_sighip : t_object {
! float sr;
! float hz;
! t_hipctl cspace;
! t_hipctl *ctl;
! float a;
! };
! t_class *sighip_class;
! static void sighip_ft1(t_sighip *x, t_floatarg f);
static void *sighip_new(t_floatarg f) {
t_sighip *x = (t_sighip *)pd_new(sighip_class);
! inlet_new(x, x, &s_float, gensym("ft1"));
! outlet_new(x, &s_signal);
! x->sr = 44100;
! x->ctl = &x->cspace;
! x->cspace.x = 0;
! sighip_ft1(x, f);
! x->a = 0;
! return x;
! }
! static void sighip_ft1(t_sighip *x, t_floatarg f) {
! if (f < 0) f = 0;
! x->hz = f;
! x->ctl->coef = 1 - f * (2 * 3.14159) / x->sr;
! if (x->ctl->coef < 0) x->ctl->coef = 0;
! else if (x->ctl->coef > 1) x->ctl->coef = 1;
! }
static t_int *sighip_perform(t_int *w) {
float *in = (float *)w[1];
--- 2337,2361 ----
/* ---------------- hip~ - 1-pole 1-zero hipass filter. ----------------- */
! /* ---------------- lop~ - 1-pole lopass filter. ----------------- */
! t_class *sighip_class; struct t_hipctl {float x; float coef;};
! t_class *siglop_class; struct t_lopctl {float x; float coef;};
! struct t_sighip : t_object {float sr; float hz; t_hipctl cspace; t_hipctl *ctl; float a;};
! struct t_siglop : t_object {float sr; float hz; t_lopctl cspace; t_lopctl *ctl; float a;};
!
! static void sighip_ft1(t_sighip *x, t_floatarg f) {x->hz = max(f,0.f); x->ctl->coef = clip(1-f*(2*3.14159)/x->sr,0.,1.);}
! static void siglop_ft1(t_siglop *x, t_floatarg f) {x->hz = max(f,0.f); x->ctl->coef = clip( f*(2*3.14159)/x->sr,0.,1.);}
!
static void *sighip_new(t_floatarg f) {
t_sighip *x = (t_sighip *)pd_new(sighip_class);
! inlet_new(x, x, &s_float, gensym("ft1")); outlet_new(x, &s_signal);
! x->sr = 44100; x->ctl = &x->cspace; x->cspace.x = 0; sighip_ft1(x, f); x->a = 0; return x;}
! static void *siglop_new(t_floatarg f) {
! t_siglop *x = (t_siglop *)pd_new(siglop_class);
! inlet_new(x, x, &s_float, gensym("ft1")); outlet_new(x, &s_signal);
! x->sr = 44100; x->ctl = &x->cspace; x->cspace.x = 0; siglop_ft1(x, f); x->a = 0; return x;}
!
! static void sighip_clear(t_sighip *x, t_floatarg q) {x->cspace.x = 0;}
! static void siglop_clear(t_siglop *x, t_floatarg q) {x->cspace.x = 0;}
!
static t_int *sighip_perform(t_int *w) {
float *in = (float *)w[1];
***************
*** 2381,2386 ****
last = noo;
}
! if (PD_BIGORSMALL(last))
! last = 0;
c->x = last;
} else {
--- 2371,2375 ----
last = noo;
}
! if (PD_BIGORSMALL(last)) last = 0;
c->x = last;
} else {
***************
*** 2390,2444 ****
return w+5;
}
- static void sighip_dsp(t_sighip *x, t_signal **sp) {
- x->sr = sp[0]->sr;
- sighip_ft1(x, x->hz);
- dsp_add(sighip_perform, 4, sp[0]->v, sp[1]->v, x->ctl, sp[0]->n);
- }
- static void sighip_clear(t_sighip *x, t_floatarg q) {
- x->cspace.x = 0;
- }
- void sighip_setup() {
- sighip_class = class_new2("hip~",sighip_new,0,sizeof(t_sighip),0,"F");
- CLASS_MAINSIGNALIN(sighip_class, t_sighip, a);
- class_addmethod2(sighip_class, sighip_dsp, "dsp","");
- class_addmethod2(sighip_class, sighip_ft1, "ft1","f");
- class_addmethod2(sighip_class, sighip_clear,"clear","");
- }
-
- /* ---------------- lop~ - 1-pole lopass filter. ----------------- */
- struct t_lopctl {
- float x;
- float coef;
- };
- struct t_siglop : t_object {
- float sr;
- float hz;
- t_lopctl cspace;
- t_lopctl *ctl;
- float a;
- };
- t_class *siglop_class;
- static void siglop_ft1(t_siglop *x, t_floatarg f);
- static void *siglop_new(t_floatarg f) {
- t_siglop *x = (t_siglop *)pd_new(siglop_class);
- inlet_new(x, x, &s_float, gensym("ft1"));
- outlet_new(x, &s_signal);
- x->sr = 44100;
- x->ctl = &x->cspace;
- x->cspace.x = 0;
- siglop_ft1(x, f);
- x->a = 0;
- return x;
- }
- static void siglop_ft1(t_siglop *x, t_floatarg f) {
- if (f < 0) f = 0;
- x->hz = f;
- x->ctl->coef = f * (2 * 3.14159) / x->sr;
- if (x->ctl->coef > 1) x->ctl->coef = 1;
- if (x->ctl->coef < 0) x->ctl->coef = 0;
- }
- static void siglop_clear(t_siglop *x, t_floatarg q) {
- x->cspace.x = 0;
- }
static t_int *siglop_perform(t_int *w) {
float *in = (float *)w[1];
--- 2379,2382 ----
***************
*** 2454,2462 ****
return w+5;
}
static void siglop_dsp(t_siglop *x, t_signal **sp) {
! x->sr = sp[0]->sr;
! siglop_ft1(x, x->hz);
! dsp_add(siglop_perform, 4, sp[0]->v, sp[1]->v, x->ctl, sp[0]->n);
}
void siglop_setup() {
--- 2392,2408 ----
return w+5;
}
+ static void sighip_dsp(t_sighip *x, t_signal **sp) {
+ x->sr = sp[0]->sr; sighip_ft1(x, x->hz);
+ dsp_add(sighip_perform, 4, sp[0]->v, sp[1]->v, x->ctl, sp[0]->n);}
static void siglop_dsp(t_siglop *x, t_signal **sp) {
! x->sr = sp[0]->sr; siglop_ft1(x, x->hz);
! dsp_add(siglop_perform, 4, sp[0]->v, sp[1]->v, x->ctl, sp[0]->n);}
+ void sighip_setup() {
+ sighip_class = class_new2("hip~",sighip_new,0,sizeof(t_sighip),0,"F");
+ CLASS_MAINSIGNALIN(sighip_class, t_sighip, a);
+ class_addmethod2(sighip_class, sighip_dsp, "dsp","");
+ class_addmethod2(sighip_class, sighip_ft1, "ft1","f");
+ class_addmethod2(sighip_class, sighip_clear,"clear","");
}
void siglop_setup() {
More information about the Pd-cvs
mailing list