Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9126
Modified Files: Tag: desiredata builtins_dsp.c Log Message: cleanup
Index: builtins_dsp.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/builtins_dsp.c,v retrieving revision 1.1.2.23 retrieving revision 1.1.2.24 diff -C2 -d -r1.1.2.23 -r1.1.2.24 *** builtins_dsp.c 19 Jul 2007 05:14:02 -0000 1.1.2.23 --- builtins_dsp.c 19 Jul 2007 18:12:25 -0000 1.1.2.24 *************** *** 234,241 **** if (g) g = 1.f / g; for (; n; n -= 8, in += 8, out += 8) { ! float f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3]; ! float f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7]; ! out[0] = f0 * g; out[1] = f1 * g; out[2] = f2 * g; out[3] = f3 * g; ! out[4] = f4 * g; out[5] = f5 * g; out[6] = f6 * g; out[7] = f7 * g; } return w+5; --- 234,239 ---- if (g) g = 1.f / g; for (; n; n -= 8, in += 8, out += 8) { ! out[0] = in[0] * g; out[1] = in[1] * g; out[2] = in[2] * g; out[3] = in[3] * g; ! out[4] = in[4] * g; out[5] = in[5] * g; out[6] = in[6] * g; out[7] = in[7] * g; } return w+5; *************** *** 300,305 **** } x->phase = phase; ! } ! else x->phase = 0x7fffffff; bad: return w+4; --- 298,302 ---- } x->phase = phase; ! } else x->phase = 0x7fffffff; bad: return w+4; *************** *** 330,343 **** } } - static void tabwrite_tilde_setup() { - t_class *c = tabwrite_tilde_class = - class_new2("tabwrite~",tabwrite_tilde_new,0,sizeof(t_tabwrite_tilde),0,"S"); - CLASS_MAINSIGNALIN(c, t_tabwrite_tilde, a); - class_addmethod2(c, tabwrite_tilde_dsp, "dsp",""); - class_addmethod2(c, tabwrite_tilde_set, "set","s"); - class_addmethod2(c, tabwrite_tilde_stop,"stop",""); - class_addmethod2(c, tabwrite_tilde_start,"start","F"); - class_addbang(c, tabwrite_tilde_bang); - }
/* ------------ tabplay~ - non-transposing sample playback --------------- */ --- 327,330 ---- *************** *** 365,375 **** t_tabplay_tilde *x = (t_tabplay_tilde *)w[1]; t_float *out = (t_float *)w[2], *fp; ! int n = (int)w[3], phase = x->phase, ! endphase = (x->nsampsintab < x->limit ? x->nsampsintab : x->limit), nxfer, n3; ! if (!x->vec || phase >= endphase) goto zero; ! nxfer = endphase - phase; fp = x->vec + phase; - if (nxfer > n) - nxfer = n; n3 = n - nxfer; phase += nxfer; --- 352,359 ---- t_tabplay_tilde *x = (t_tabplay_tilde *)w[1]; t_float *out = (t_float *)w[2], *fp; ! int n = (int)w[3], phase = x->phase, endphase = (x->nsampsintab < x->limit ? x->nsampsintab : x->limit), nxfer, n3; ! if (!x->vec || phase >= endphase) {while (n--) *out++ = 0; goto bye;} ! nxfer = min(endphase-phase,n); fp = x->vec + phase; n3 = n - nxfer; phase += nxfer; *************** *** 378,387 **** clock_delay(x->clock, 0); x->phase = 0x7fffffff; ! while (n3--) ! *out++ = 0; } else x->phase = phase; return w+4; ! zero: ! while (n--) *out++ = 0; return w+4; } --- 362,369 ---- clock_delay(x->clock, 0); x->phase = 0x7fffffff; ! while (n3--) *out++ = 0; } else x->phase = phase; return w+4; ! bye: return w+4; } *************** *** 401,408 **** dsp_add(tabplay_tilde_perform, 3, x, sp[0]->v, sp[0]->n); } ! static void tabplay_tilde_list(t_tabplay_tilde *x, t_symbol *s, ! int argc, t_atom *argv) { ! long start = (int)atom_getfloatarg(0, argc, argv); ! long length = (int)atom_getfloatarg(1, argc, argv); if (start < 0) start = 0; if (length <= 0) x->limit = 0x7fffffff; else x->limit = start + length; --- 383,389 ---- dsp_add(tabplay_tilde_perform, 3, x, sp[0]->v, sp[0]->n); } ! static void tabplay_tilde_list(t_tabplay_tilde *x, t_symbol *s, int argc, t_atom *argv) { ! long start = atom_getintarg(0, argc, argv); ! long length = atom_getintarg(1, argc, argv); if (start < 0) start = 0; if (length <= 0) x->limit = 0x7fffffff; else x->limit = start + length; *************** *** 412,423 **** static void tabplay_tilde_tick(t_tabplay_tilde *x) {outlet_bang(x->out(1));} static void tabplay_tilde_free(t_tabplay_tilde *x) {clock_free(x->clock);} - static void tabplay_tilde_setup() { - t_class *c = tabplay_tilde_class = - class_new2("tabplay~",tabplay_tilde_new,tabplay_tilde_free,sizeof(t_tabplay_tilde),0,"S"); - class_addmethod2(c, tabplay_tilde_dsp, "dsp",""); - class_addmethod2(c, tabplay_tilde_stop, "stop",""); - class_addmethod2(c, tabplay_tilde_set, "set","S"); - class_addlist(c, tabplay_tilde_list); - }
/******************** tabread~ ***********************/ --- 393,396 ---- *************** *** 442,449 **** t_float *out = (t_float *)w[3]; int n = (int)w[4]; - int maxindex; float *buf = x->vec; ! maxindex = x->npoints - 1; ! if (!buf) goto zero; for (int i = 0; i < n; i++) { int index = (int)*in++; --- 415,421 ---- t_float *out = (t_float *)w[3]; int n = (int)w[4]; float *buf = x->vec; ! int maxindex = x->npoints - 1; ! if (!buf) {while (n--) *out++ = 0; goto bad;} for (int i = 0; i < n; i++) { int index = (int)*in++; *************** *** 451,458 **** *out++ = buf[index]; } ! return w+5; ! zero: ! while (n--) *out++ = 0; ! return w+5; } void tabread_tilde_set(t_tabread_tilde *x, t_symbol *s) { --- 423,427 ---- *out++ = buf[index]; } ! bad:return w+5; } void tabread_tilde_set(t_tabread_tilde *x, t_symbol *s) { *************** *** 472,482 **** } static void tabread_tilde_free(t_tabread_tilde *x) {} - static void tabread_tilde_setup() { - t_class *c = tabread_tilde_class = class_new2("tabread~",tabread_tilde_new,tabread_tilde_free, - sizeof(t_tabread_tilde),0,"S"); - CLASS_MAINSIGNALIN(c, t_tabread_tilde, a); - class_addmethod2(c, tabread_tilde_dsp, "dsp",""); - class_addmethod2(c, tabread_tilde_set, "set","s"); - }
/******************** tabread4~ ***********************/ --- 441,444 ---- *************** *** 557,563 **** } static void tabread4_tilde_free(t_tabread4_tilde *x) {} ! static void tabread4_tilde_setup() { ! t_class *c = tabread4_tilde_class = ! class_new2("tabread4~",tabread4_tilde_new,tabread4_tilde_free,sizeof(t_tabread4_tilde),0,"S"); CLASS_MAINSIGNALIN(c, t_tabread4_tilde, a); class_addmethod2(c, tabread4_tilde_dsp, "dsp",""); --- 519,542 ---- } static void tabread4_tilde_free(t_tabread4_tilde *x) {} ! ! static void tab_tilde_setup() { ! t_class *c; ! c = tabwrite_tilde_class = class_new2("tabwrite~",tabwrite_tilde_new,0,sizeof(t_tabwrite_tilde),0,"S"); ! CLASS_MAINSIGNALIN(c, t_tabwrite_tilde, a); ! class_addmethod2(c, tabwrite_tilde_dsp, "dsp",""); ! class_addmethod2(c, tabwrite_tilde_set, "set","s"); ! class_addmethod2(c, tabwrite_tilde_stop,"stop",""); ! class_addmethod2(c, tabwrite_tilde_start,"start","F"); ! class_addbang(c, tabwrite_tilde_bang); ! c = tabplay_tilde_class = class_new2("tabplay~",tabplay_tilde_new,tabplay_tilde_free,sizeof(t_tabplay_tilde),0,"S"); ! class_addmethod2(c, tabplay_tilde_dsp, "dsp",""); ! class_addmethod2(c, tabplay_tilde_stop, "stop",""); ! class_addmethod2(c, tabplay_tilde_set, "set","S"); ! class_addlist(c, tabplay_tilde_list); ! c = tabread_tilde_class = class_new2("tabread~",tabread_tilde_new,tabread_tilde_free, sizeof(t_tabread_tilde),0,"S"); ! CLASS_MAINSIGNALIN(c, t_tabread_tilde, a); ! class_addmethod2(c, tabread_tilde_dsp, "dsp",""); ! class_addmethod2(c, tabread_tilde_set, "set","s"); ! c = tabread4_tilde_class = class_new2("tabread4~",tabread4_tilde_new,tabread4_tilde_free,sizeof(t_tabread4_tilde),0,"S"); CLASS_MAINSIGNALIN(c, t_tabread4_tilde, a); class_addmethod2(c, tabread4_tilde_dsp, "dsp",""); *************** *** 581,586 ****
union tabfudge { ! double tf_d; ! int32 tf_i[2]; }; static t_class *tabosc4_tilde_class; --- 560,565 ----
union tabfudge { ! double d; ! int32 i[2]; }; static t_class *tabosc4_tilde_class; *************** *** 610,614 **** t_float *out = (t_float *)w[3]; int n = (int)w[4]; - int normhipart; union tabfudge tf; float fnpoints = x->fnpoints; --- 589,592 ---- *************** *** 617,648 **** float *tab = x->vec, *addr; double dphase = fnpoints * x->phase + UNITBIT32; ! if (!tab) goto zero; ! tf.tf_d = UNITBIT32; ! normhipart = tf.tf_i[HIOFFSET]; #if 1 while (n--) { ! float frac, a, b, c, d, cminusb; ! tf.tf_d = dphase; dphase += *in++ * conv; ! addr = tab + (tf.tf_i[HIOFFSET] & mask); ! tf.tf_i[HIOFFSET] = normhipart; ! frac = tf.tf_d - UNITBIT32; ! a = addr[0]; ! b = addr[1]; ! c = addr[2]; ! d = addr[3]; ! cminusb = c-b; ! *out++ = b + frac * (cminusb - 0.1666667f * (1.-frac) * ( ! (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b))); } #endif ! tf.tf_d = UNITBIT32 * fnpoints; ! normhipart = tf.tf_i[HIOFFSET]; ! tf.tf_d = dphase + (UNITBIT32 * fnpoints - UNITBIT32); ! tf.tf_i[HIOFFSET] = normhipart; ! x->phase = (tf.tf_d - UNITBIT32 * fnpoints) * x->finvnpoints; ! return w+5; ! zero: ! while (n--) *out++ = 0; return w+5; } --- 595,621 ---- float *tab = x->vec, *addr; double dphase = fnpoints * x->phase + UNITBIT32; ! if (!tab) {while (n--) *out++ = 0; return w+5;} ! tf.d = UNITBIT32; ! int normhipart = tf.i[HIOFFSET]; #if 1 while (n--) { ! tf.d = dphase; dphase += *in++ * conv; ! addr = tab + (tf.i[HIOFFSET] & mask); ! tf.i[HIOFFSET] = normhipart; ! float frac = tf.d - UNITBIT32; ! float a = addr[0]; ! float b = addr[1]; ! float c = addr[2]; ! float d = addr[3]; ! float cminusb = c-b; ! *out++ = b + frac * (cminusb - 0.1666667f * (1.-frac) * ((d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b))); } #endif ! tf.d = UNITBIT32 * fnpoints; ! normhipart = tf.i[HIOFFSET]; ! tf.d = dphase + (UNITBIT32 * fnpoints - UNITBIT32); ! tf.i[HIOFFSET] = normhipart; ! x->phase = (tf.d - UNITBIT32 * fnpoints) * x->finvnpoints; return w+5; } *************** *** 3733,3747 **** int normhipart; float conv = x->conv; ! tf.tf_d = UNITBIT32; ! normhipart = tf.tf_i[HIOFFSET]; ! tf.tf_d = dphase; while (n--) { ! tf.tf_i[HIOFFSET] = normhipart; dphase += *in++ * conv; ! *out++ = tf.tf_d - UNITBIT32; ! tf.tf_d = dphase; } ! tf.tf_i[HIOFFSET] = normhipart; ! x->phase = tf.tf_d - UNITBIT32; return w+5; } --- 3706,3720 ---- int normhipart; float conv = x->conv; ! tf.d = UNITBIT32; ! normhipart = tf.i[HIOFFSET]; ! tf.d = dphase; while (n--) { ! tf.i[HIOFFSET] = normhipart; dphase += *in++ * conv; ! *out++ = tf.d - UNITBIT32; ! tf.d = dphase; } ! tf.i[HIOFFSET] = normhipart; ! x->phase = tf.d - UNITBIT32; return w+5; } *************** *** 3781,3794 **** int normhipart; union tabfudge tf; ! tf.tf_d = UNITBIT32; ! normhipart = tf.tf_i[HIOFFSET];
#if 0 /* this is the readable version of the code. */ while (n--) { dphase = (double)(*in++ * (float)(COSTABSIZE)) + UNITBIT32; ! tf.tf_d = dphase; ! addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1)); ! tf.tf_i[HIOFFSET] = normhipart; ! frac = tf.tf_d - UNITBIT32; f1 = addr[0]; f2 = addr[1]; --- 3754,3767 ---- int normhipart; union tabfudge tf; ! tf.d = UNITBIT32; ! normhipart = tf.i[HIOFFSET];
#if 0 /* this is the readable version of the code. */ while (n--) { dphase = (double)(*in++ * (float)(COSTABSIZE)) + UNITBIT32; ! tf.d = dphase; ! addr = tab + (tf.i[HIOFFSET] & (COSTABSIZE-1)); ! tf.i[HIOFFSET] = normhipart; ! frac = tf.d - UNITBIT32; f1 = addr[0]; f2 = addr[1]; *************** *** 3797,3814 **** #else /* this is the same, unwrapped by hand. */ dphase = (double)(*in++ * (float)(COSTABSIZE)) + UNITBIT32; ! tf.tf_d = dphase; ! addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1)); ! tf.tf_i[HIOFFSET] = normhipart; while (--n) { dphase = (double)(*in++ * (float)(COSTABSIZE)) + UNITBIT32; ! frac = tf.tf_d - UNITBIT32; ! tf.tf_d = dphase; f1 = addr[0]; f2 = addr[1]; ! addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1)); *out++ = f1 + frac * (f2 - f1); ! tf.tf_i[HIOFFSET] = normhipart; } ! frac = tf.tf_d - UNITBIT32; f1 = addr[0]; f2 = addr[1]; --- 3770,3787 ---- #else /* this is the same, unwrapped by hand. */ dphase = (double)(*in++ * (float)(COSTABSIZE)) + UNITBIT32; ! tf.d = dphase; ! addr = tab + (tf.i[HIOFFSET] & (COSTABSIZE-1)); ! tf.i[HIOFFSET] = normhipart; while (--n) { dphase = (double)(*in++ * (float)(COSTABSIZE)) + UNITBIT32; ! frac = tf.d - UNITBIT32; ! tf.d = dphase; f1 = addr[0]; f2 = addr[1]; ! addr = tab + (tf.i[HIOFFSET] & (COSTABSIZE-1)); *out++ = f1 + frac * (f2 - f1); ! tf.i[HIOFFSET] = normhipart; } ! frac = tf.d - UNITBIT32; f1 = addr[0]; f2 = addr[1]; *************** *** 3830,3835 **** /* here we check at startup whether the byte alignment is as we declared it. If not, the code has to be recompiled the other way. */ ! tf.tf_d = UNITBIT32 + 0.5; ! if ((unsigned)tf.tf_i[LOWOFFSET] != 0x80000000) bug("cos~: unexpected machine alignment"); } static void cos_setup() { --- 3803,3808 ---- /* here we check at startup whether the byte alignment is as we declared it. If not, the code has to be recompiled the other way. */ ! tf.d = UNITBIT32 + 0.5; ! if ((unsigned)tf.i[LOWOFFSET] != 0x80000000) bug("cos~: unexpected machine alignment"); } static void cos_setup() { *************** *** 3867,3879 **** union tabfudge tf; float conv = x->conv; ! tf.tf_d = UNITBIT32; ! normhipart = tf.tf_i[HIOFFSET]; #if 0 while (n--) { ! tf.tf_d = dphase; dphase += *in++ * conv; ! addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1)); ! tf.tf_i[HIOFFSET] = normhipart; ! frac = tf.tf_d - UNITBIT32; f1 = addr[0]; f2 = addr[1]; --- 3840,3852 ---- union tabfudge tf; float conv = x->conv; ! tf.d = UNITBIT32; ! normhipart = tf.i[HIOFFSET]; #if 0 while (n--) { ! tf.d = dphase; dphase += *in++ * conv; ! addr = tab + (tf.i[HIOFFSET] & (COSTABSIZE-1)); ! tf.i[HIOFFSET] = normhipart; ! frac = tf.d - UNITBIT32; f1 = addr[0]; f2 = addr[1]; *************** *** 3881,3898 **** } #else ! tf.tf_d = dphase; dphase += *in++ * conv; ! addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1)); ! tf.tf_i[HIOFFSET] = normhipart; ! frac = tf.tf_d - UNITBIT32; while (--n) { ! tf.tf_d = dphase; f1 = addr[0]; dphase += *in++ * conv; f2 = addr[1]; ! addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1)); ! tf.tf_i[HIOFFSET] = normhipart; *out++ = f1 + frac * (f2 - f1); ! frac = tf.tf_d - UNITBIT32; } f1 = addr[0]; --- 3854,3871 ---- } #else ! tf.d = dphase; dphase += *in++ * conv; ! addr = tab + (tf.i[HIOFFSET] & (COSTABSIZE-1)); ! tf.i[HIOFFSET] = normhipart; ! frac = tf.d - UNITBIT32; while (--n) { ! tf.d = dphase; f1 = addr[0]; dphase += *in++ * conv; f2 = addr[1]; ! addr = tab + (tf.i[HIOFFSET] & (COSTABSIZE-1)); ! tf.i[HIOFFSET] = normhipart; *out++ = f1 + frac * (f2 - f1); ! frac = tf.d - UNITBIT32; } f1 = addr[0]; *************** *** 3900,3908 **** *out++ = f1 + frac * (f2 - f1); #endif ! tf.tf_d = UNITBIT32 * COSTABSIZE; ! normhipart = tf.tf_i[HIOFFSET]; ! tf.tf_d = dphase + (UNITBIT32 * COSTABSIZE - UNITBIT32); ! tf.tf_i[HIOFFSET] = normhipart; ! x->phase = tf.tf_d - UNITBIT32 * COSTABSIZE; return w+5; } --- 3873,3881 ---- *out++ = f1 + frac * (f2 - f1); #endif ! tf.d = UNITBIT32 * COSTABSIZE; ! normhipart = tf.i[HIOFFSET]; ! tf.d = dphase + (UNITBIT32 * COSTABSIZE - UNITBIT32); ! tf.i[HIOFFSET] = normhipart; ! x->phase = tf.d - UNITBIT32 * COSTABSIZE; return w+5; } *************** *** 3971,3976 **** int normhipart, tabindex; union tabfudge tf; ! tf.tf_d = UNITBIT32; ! normhipart = tf.tf_i[HIOFFSET]; for (int i = 0; i < n; i++) { float cf, cfindx, r, oneminusr; --- 3944,3949 ---- int normhipart, tabindex; union tabfudge tf; ! tf.d = UNITBIT32; ! normhipart = tf.i[HIOFFSET]; for (int i = 0; i < n; i++) { float cf, cfindx, r, oneminusr; *************** *** 3982,3990 **** oneminusr = 1.0f - r; dphase = ((double)(cfindx)) + UNITBIT32; ! tf.tf_d = dphase; ! tabindex = tf.tf_i[HIOFFSET] & (COSTABSIZE-1); addr = tab + tabindex; ! tf.tf_i[HIOFFSET] = normhipart; ! frac = tf.tf_d - UNITBIT32; f1 = addr[0]; f2 = addr[1]; coefr = r * (f1 + frac * (f2 - f1)); addr = tab + ((tabindex - (COSTABSIZE/4)) & (COSTABSIZE-1)); --- 3955,3963 ---- oneminusr = 1.0f - r; dphase = ((double)(cfindx)) + UNITBIT32; ! tf.d = dphase; ! tabindex = tf.i[HIOFFSET] & (COSTABSIZE-1); addr = tab + tabindex; ! tf.i[HIOFFSET] = normhipart; ! frac = tf.d - UNITBIT32; f1 = addr[0]; f2 = addr[1]; coefr = r * (f1 + frac * (f2 - f1)); addr = tab + ((tabindex - (COSTABSIZE/4)) & (COSTABSIZE-1)); *************** *** 4052,4059 **** min_setup();
! tabwrite_tilde_setup(); ! tabplay_tilde_setup(); ! tabread_tilde_setup(); ! tabread4_tilde_setup(); tabosc4_tilde_setup(); tabsend_setup(); --- 4025,4029 ---- min_setup();
! tab_tilde_setup(); tabosc4_tilde_setup(); tabsend_setup();