Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21723
Modified Files: Tag: desiredata builtins_dsp.c Log Message: interleaved code of [rpole~] [rzero~] [rzero_rev~]
Index: builtins_dsp.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/builtins_dsp.c,v retrieving revision 1.1.2.25 retrieving revision 1.1.2.26 diff -C2 -d -r1.1.2.25 -r1.1.2.26 *** builtins_dsp.c 19 Jul 2007 18:25:27 -0000 1.1.2.25 --- builtins_dsp.c 19 Jul 2007 18:44:47 -0000 1.1.2.26 *************** *** 2830,2899 ****
/* ---------------- rpole~ - real one-pole filter (raw) ----------------- */ ! struct t_sigrpole : t_object { ! float a; ! float last; ! }; ! t_class *sigrpole_class; static void *sigrpole_new(t_float f) { t_sigrpole *x = (t_sigrpole *)pd_new(sigrpole_class); ! pd_float((t_pd *)inlet_new(x, x, &s_signal, &s_signal), f); ! outlet_new(x, &s_signal); ! x->last = 0; ! return x; ! } static t_int *sigrpole_perform(t_int *w) { ! float *in1 = (float *)w[1]; ! float *in2 = (float *)w[2]; ! float *out = (float *)w[3]; ! t_sigrpole *x = (t_sigrpole *)w[4]; ! int n = (t_int)w[5]; ! float last = x->last; ! for (int i = 0; i < n; i++) { ! float next = *in1++; ! float coef = *in2++; ! *out++ = last = coef * last + next; } ! if (PD_BIGORSMALL(last)) ! last = 0; x->last = last; return w+6; } - static void sigrpole_dsp(t_sigrpole *x, t_signal **sp) { - dsp_add(sigrpole_perform, 5, sp[0]->v, sp[1]->v, sp[2]->v, x, sp[0]->n); - } - static void sigrpole_clear(t_sigrpole *x) {x->last = 0;} - static void sigrpole_set(t_sigrpole *x, t_float f) {x->last = f;} - void sigrpole_setup() { - sigrpole_class = class_new2("rpole~",sigrpole_new,0,sizeof(t_sigrpole),0,"F"); - CLASS_MAINSIGNALIN(sigrpole_class, t_sigrpole, a); - class_addmethod2(sigrpole_class, sigrpole_set, "set","F"); - class_addmethod2(sigrpole_class, sigrpole_clear,"clear",""); - class_addmethod2(sigrpole_class, sigrpole_dsp, "dsp",""); - } - - /* ---------------- rzero~ - real one-zero filter (raw) ----------------- */ - struct t_sigrzero : t_object { - float a; - float last; - }; - t_class *sigrzero_class; - static void *sigrzero_new(t_float f) { - t_sigrzero *x = (t_sigrzero *)pd_new(sigrzero_class); - pd_float((t_pd *)inlet_new(x, x, &s_signal, &s_signal), f); - outlet_new(x, &s_signal); - x->last = 0; - return x; - } static t_int *sigrzero_perform(t_int *w) { ! float *in1 = (float *)w[1]; ! float *in2 = (float *)w[2]; ! float *out = (float *)w[3]; ! t_sigrzero *x = (t_sigrzero *)w[4]; ! int n = (t_int)w[5]; ! float last = x->last; for (int i = 0; i < n; i++) { ! float next = *in1++; ! float coef = *in2++; ! *out++ = next - coef * last; last = next; } --- 2830,2866 ----
/* ---------------- rpole~ - real one-pole filter (raw) ----------------- */ ! /* ---------------- rzero~ - real one-zero filter (raw) ----------------- */ ! /* --------- rzero_rev~ - real, reverse one-zero filter (raw) ----------- */ ! t_class *sigrpole_class; struct t_sigrpole : t_object {float a; float last;}; ! t_class *sigrzero_class; struct t_sigrzero : t_object {float a; float last;}; ! t_class *sigrzrev_class; struct t_sigrzrev : t_object {float a; float last;}; ! static void *sigrpole_new(t_float f) { t_sigrpole *x = (t_sigrpole *)pd_new(sigrpole_class); ! pd_float((t_pd *)inlet_new(x, x, &s_signal, &s_signal), f); outlet_new(x, &s_signal); x->last=0; return x;} ! static void *sigrzero_new(t_float f) { ! t_sigrzero *x = (t_sigrzero *)pd_new(sigrzero_class); ! pd_float((t_pd *)inlet_new(x, x, &s_signal, &s_signal), f); outlet_new(x, &s_signal); x->last=0; return x;} ! static void *sigrzrev_new(t_float f) { ! t_sigrzrev *x = (t_sigrzrev *)pd_new(sigrzrev_class); ! pd_float((t_pd *)inlet_new(x, x, &s_signal, &s_signal), f); outlet_new(x, &s_signal); x->last=0; return x;} ! static t_int *sigrpole_perform(t_int *w) { ! float *in1 = (float *)w[1]; float *in2 = (float *)w[2]; float *out = (float *)w[3]; ! t_sigrpole *x = (t_sigrpole *)w[4]; int n = (t_int)w[5]; float last = x->last; ! for (int i=0; i<n; i++) { ! float next = *in1++, coef = *in2++; ! *out++ = last = coef*last + next; } ! if (PD_BIGORSMALL(last)) last = 0; x->last = last; return w+6; } static t_int *sigrzero_perform(t_int *w) { ! float *in1 = (float *)w[1]; float *in2 = (float *)w[2]; float *out = (float *)w[3]; ! t_sigrzero *x = (t_sigrzero *)w[4]; int n = (t_int)w[5]; float last = x->last; for (int i = 0; i < n; i++) { ! float next = *in1++, coef = *in2++; ! *out++ = next - coef*last; last = next; } *************** *** 2901,2910 **** return w+6; } ! static void sigrzero_dsp(t_sigrzero *x, t_signal **sp) { ! dsp_add(sigrzero_perform, 5, sp[0]->v, sp[1]->v, sp[2]->v, x, sp[0]->n); } static void sigrzero_clear(t_sigrzero *x) {x->last = 0;} static void sigrzero_set(t_sigrzero *x, t_float f) {x->last = f;} ! void sigrzero_setup() { sigrzero_class = class_new2("rzero~",sigrzero_new,0,sizeof(t_sigrzero),0,"F"); CLASS_MAINSIGNALIN(sigrzero_class, t_sigrzero, a); --- 2868,2898 ---- return w+6; } ! static t_int *sigrzrev_perform(t_int *w) { ! float *in1 = (float *)w[1]; float *in2 = (float *)w[2]; float *out = (float *)w[3]; ! t_sigrzrev *x = (t_sigrzrev *)w[4]; int n = (t_int)w[5]; float last = x->last; ! for (int i = 0; i < n; i++) { ! float next = *in1++, coef = *in2++; ! *out++ = last - coef*next; ! last = next; ! } ! x->last = last; ! return w+6; } + + static void sigrpole_dsp(t_sigrpole *x, t_signal **sp) {dsp_add(sigrpole_perform, 5, sp[0]->v, sp[1]->v, sp[2]->v, x, sp[0]->n);} + static void sigrzero_dsp(t_sigrzero *x, t_signal **sp) {dsp_add(sigrzero_perform, 5, sp[0]->v, sp[1]->v, sp[2]->v, x, sp[0]->n);} + static void sigrzrev_dsp(t_sigrzrev *x, t_signal **sp) {dsp_add(sigrzrev_perform, 5, sp[0]->v, sp[1]->v, sp[2]->v, x, sp[0]->n);} + static void sigrpole_clear(t_sigrpole *x) {x->last = 0;} static void sigrzero_clear(t_sigrzero *x) {x->last = 0;} + static void sigrzrev_clear(t_sigrzrev *x) {x->last = 0;} + static void sigrpole_set(t_sigrpole *x, t_float f) {x->last = f;} static void sigrzero_set(t_sigrzero *x, t_float f) {x->last = f;} ! static void sigrzrev_set(t_sigrzrev *x, t_float f) {x->last = f;} ! void sigr_setup() { ! sigrpole_class = class_new2("rpole~",sigrpole_new,0,sizeof(t_sigrpole),0,"F"); ! CLASS_MAINSIGNALIN(sigrpole_class, t_sigrpole, a); ! class_addmethod2(sigrpole_class, sigrpole_set, "set","F"); ! class_addmethod2(sigrpole_class, sigrpole_clear,"clear",""); ! class_addmethod2(sigrpole_class, sigrpole_dsp, "dsp",""); sigrzero_class = class_new2("rzero~",sigrzero_new,0,sizeof(t_sigrzero),0,"F"); CLASS_MAINSIGNALIN(sigrzero_class, t_sigrzero, a); *************** *** 2912,2959 **** class_addmethod2(sigrzero_class, sigrzero_clear,"clear",""); class_addmethod2(sigrzero_class, sigrzero_dsp, "dsp",""); ! } ! ! /* ---------- rzero_rev~ - real, reverse one-zero filter (raw) ------------ */ ! struct t_sigrzero_rev : t_object { ! float a; ! float last; ! }; ! t_class *sigrzero_rev_class; ! static void *sigrzero_rev_new(t_float f) { ! t_sigrzero_rev *x = (t_sigrzero_rev *)pd_new(sigrzero_rev_class); ! pd_float( ! (t_pd *)inlet_new(x, x, &s_signal, &s_signal), ! f); ! outlet_new(x, &s_signal); ! x->last = 0; ! return x; ! } ! static t_int *sigrzero_rev_perform(t_int *w) { ! float *in1 = (float *)w[1]; ! float *in2 = (float *)w[2]; ! float *out = (float *)w[3]; ! t_sigrzero_rev *x = (t_sigrzero_rev *)w[4]; ! int n = (t_int)w[5]; ! float last = x->last; ! for (int i = 0; i < n; i++) { ! float next = *in1++; ! float coef = *in2++; ! *out++ = last - coef * next; ! last = next; ! } ! x->last = last; ! return w+6; ! } ! static void sigrzero_rev_dsp(t_sigrzero_rev *x, t_signal **sp) { ! dsp_add(sigrzero_rev_perform, 5, sp[0]->v, sp[1]->v, sp[2]->v, x, sp[0]->n); ! } ! static void sigrzero_rev_clear(t_sigrzero_rev *x) {x->last = 0;} ! static void sigrzero_rev_set(t_sigrzero_rev *x, t_float f) {x->last = f;} ! void sigrzero_rev_setup() { ! sigrzero_rev_class = class_new2("rzero_rev~",sigrzero_rev_new,0,sizeof(t_sigrzero_rev),0,"F"); ! CLASS_MAINSIGNALIN(sigrzero_rev_class, t_sigrzero_rev, a); ! class_addmethod2(sigrzero_rev_class, sigrzero_rev_set, "set","F"); ! class_addmethod2(sigrzero_rev_class, sigrzero_rev_clear,"clear",""); ! class_addmethod2(sigrzero_rev_class, sigrzero_rev_dsp, "dsp",""); }
--- 2900,2908 ---- class_addmethod2(sigrzero_class, sigrzero_clear,"clear",""); class_addmethod2(sigrzero_class, sigrzero_dsp, "dsp",""); ! sigrzrev_class = class_new2("rzero_rev~",sigrzrev_new,0,sizeof(t_sigrzrev),0,"F"); ! CLASS_MAINSIGNALIN(sigrzrev_class, t_sigrzrev, a); ! class_addmethod2(sigrzrev_class, sigrzrev_set, "set","F"); ! class_addmethod2(sigrzrev_class, sigrzrev_clear,"clear",""); ! class_addmethod2(sigrzrev_class, sigrzrev_dsp, "dsp",""); }
*************** *** 4024,4030 **** sigbiquad_setup(); sigsamphold_setup(); ! sigrpole_setup(); ! sigrzero_setup(); ! sigrzero_rev_setup(); sigcpole_setup(); sigczero_setup(); --- 3973,3977 ---- sigbiquad_setup(); sigsamphold_setup(); ! sigr_setup(); sigcpole_setup(); sigczero_setup();