[PD-cvs] pd/src builtins_dsp.c,1.1.2.24,1.1.2.25

Mathieu Bouchard matju at users.sourceforge.net
Thu Jul 19 20:25:29 CEST 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14289

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.24
retrieving revision 1.1.2.25
diff -C2 -d -r1.1.2.24 -r1.1.2.25
*** builtins_dsp.c	19 Jul 2007 18:12:25 -0000	1.1.2.24
--- builtins_dsp.c	19 Jul 2007 18:25:27 -0000	1.1.2.25
***************
*** 465,469 ****
      int maxindex;
      float *buf = x->vec, *fp;
-     int i;
      maxindex = x->npoints - 3;
      if (!buf) goto zero;
--- 465,468 ----
***************
*** 481,500 ****
      }
  #endif
!     for (i = 0; i < n; i++) {
          float findex = *in++;
          int index = (int)findex;
!         float frac,  a,  b,  c,  d, cminusb;
          if (index < 1) index = 1, frac = 0;
          else if (index > maxindex) index = maxindex, frac = 1;
          else frac = findex - index;
          fp = buf + index;
!         a = fp[-1];
!         b = fp[0];
!         c = fp[1];
!         d = fp[2];
          /* if (!i && !(count++ & 1023)) post("fp = %lx,  shit = %lx,  b = %f",  fp, buf->b_shit,  b); */
!         cminusb = c-b;
!         *out++ = b + frac * (cminusb - 0.1666667f * (1.-frac) * (
!                 (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b)));
      }
      return w+5;
--- 480,495 ----
      }
  #endif
!     for (int i=0; i<n; i++) {
          float findex = *in++;
          int index = (int)findex;
!         float frac;
          if (index < 1) index = 1, frac = 0;
          else if (index > maxindex) index = maxindex, frac = 1;
          else frac = findex - index;
          fp = buf + index;
!         float a=fp[-1], b=fp[0], c=fp[1], d=fp[2];
          /* if (!i && !(count++ & 1023)) post("fp = %lx,  shit = %lx,  b = %f",  fp, buf->b_shit,  b); */
!         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)));
      }
      return w+5;
***************
*** 520,547 ****
  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","");
-     class_addmethod2(c, tabread4_tilde_set, "set","s");
- }
- 
  /******************** tabosc4~ ***********************/
  
--- 515,518 ----
***************
*** 625,630 ****
      x->arrayname = s;
      if (!a) {
!         if (*s->name)
!             error("tabosc4~: %s: no such array", x->arrayname->name);
          x->vec = 0;
      } else if (!garray_getfloatarray(a, &pointsinarray, &x->vec)) {
--- 596,600 ----
      x->arrayname = s;
      if (!a) {
!         if (*s->name) error("tabosc4~: %s: no such array", x->arrayname->name);
          x->vec = 0;
      } else if (!garray_getfloatarray(a, &pointsinarray, &x->vec)) {
***************
*** 650,654 ****
  }
  static void tabosc4_tilde_setup() {
!     t_class *c = tabosc4_tilde_class = class_new2("tabosc4~",tabosc4_tilde_new,0,sizeof(t_tabosc4_tilde),0,"S");
      CLASS_MAINSIGNALIN(c, t_tabosc4_tilde, a);
      class_addmethod2(c, tabosc4_tilde_dsp, "dsp","");
--- 620,648 ----
  }
  static void tabosc4_tilde_setup() {
! }
! 
! 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","");
!     class_addmethod2(c, tabread4_tilde_set, "set","s");
!     c = tabosc4_tilde_class = class_new2("tabosc4~",tabosc4_tilde_new,0,sizeof(t_tabosc4_tilde),0,"S");
      CLASS_MAINSIGNALIN(c, t_tabosc4_tilde, a);
      class_addmethod2(c, tabosc4_tilde_dsp, "dsp","");
***************
*** 683,688 ****
      if (!i--) {
          t_garray *a = (t_garray *)pd_findbyclass(x->arrayname, garray_class);
!         if (!a)
!             bug("tabsend_dsp");
          else garray_redraw(a);
          i = x->graphperiod;
--- 677,681 ----
      if (!i--) {
          t_garray *a = (t_garray *)pd_findbyclass(x->arrayname, garray_class);
!         if (!a) bug("tabsend_dsp");
          else garray_redraw(a);
          i = x->graphperiod;
***************
*** 750,757 ****
      t_float *from = x->vec;
      if (from) {
!         int vecsize = x->vecsize;
!         while (vecsize--) *out++ = *from++;
!         vecsize = n - x->vecsize;
!         while (vecsize--) *out++ = 0;
      } else while (n--) *out++ = 0;
      return w+4;
--- 743,748 ----
      t_float *from = x->vec;
      if (from) {
!         int vecsize = x->vecsize; while (vecsize--) *out++ = *from++;
!         vecsize = n - x->vecsize; while (vecsize--) *out++ = 0;
      } else while (n--) *out++ = 0;
      return w+4;
***************
*** 807,819 ****
      t_float *vec;
      t_garray *a = (t_garray *)pd_findbyclass(x->arrayname, garray_class);
!     if (!a) error("%s: no such array", x->arrayname->name);
!     else if (!garray_getfloatarray(a, &npoints, &vec)) {
!         error("%s: bad template for tabread", x->arrayname->name);
!     } else {
!         int n = (int)f;
!         if (n < 0) n = 0;
!         else if (n >= npoints) n = npoints - 1;
!         outlet_float(x->outlet, (npoints ? vec[n] : 0));
!     }
  }
  static void tabread_set(t_tabread *x, t_symbol *s) {
--- 798,805 ----
      t_float *vec;
      t_garray *a = (t_garray *)pd_findbyclass(x->arrayname, garray_class);
!     if (!a) {error("%s: no such array", x->arrayname->name); return;}
!     if (!garray_getfloatarray(a, &npoints, &vec)) {error("%s: bad template for tabread", x->arrayname->name); return;}
!     int n = clip(int(f),0,npoints-1);
!     outlet_float(x->outlet, (npoints ? vec[n] : 0));
  }
  static void tabread_set(t_tabread *x, t_symbol *s) {
***************
*** 838,872 ****
  };
  static void tabread4_float(t_tabread4 *x, t_float f) {
!     t_garray *a = (t_garray *)pd_findbyclass(x->arrayname, garray_class);
      int npoints;
      t_float *vec;
!     if (!a)
!         error("%s: no such array", x->arrayname->name);
!     else if (!garray_getfloatarray(a, &npoints, &vec))
!         error("%s: bad template for tabread4", x->arrayname->name);
!     else if (npoints < 4)
!         outlet_float(x->outlet, 0);
!     else if (f <= 1)
!         outlet_float(x->outlet, vec[1]);
!     else if (f >= npoints - 2)
!         outlet_float(x->outlet, vec[npoints - 2]);
!     else {
!         int n = (int)f;
!         float a, b, c, d, cminusb, frac, *fp;
!         if (n > npoints-3) n = npoints-3;
!         fp = vec + n;
!         frac = f - n;
!         a = fp[-1];
!         b = fp[0];
!         c = fp[1];
!         d = fp[2];
!         cminusb = c-b;
!         outlet_float(x->outlet, b + frac * (
!             cminusb - 0.1666667f * (1.-frac) * ((d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b))));
!     }
! }
! static void tabread4_set(t_tabread4 *x, t_symbol *s) {
!     x->arrayname = s;
  }
  static void *tabread4_new(t_symbol *s) {
      t_tabread4 *x = (t_tabread4 *)pd_new(tabread4_class);
--- 824,843 ----
  };
  static void tabread4_float(t_tabread4 *x, t_float f) {
!     t_garray *ar = (t_garray *)pd_findbyclass(x->arrayname, garray_class);
      int npoints;
      t_float *vec;
!     if (!ar) {error("%s: no such array", x->arrayname->name); return;}
!     if (!garray_getfloatarray(ar, &npoints, &vec)) {error("%s: bad template for tabread4", x->arrayname->name); return;}
!     if (npoints < 4)    {outlet_float(x->outlet, 0); return;}
!     if (f <= 1)         {outlet_float(x->outlet, vec[1]); return;}
!     if (f >= npoints-2) {outlet_float(x->outlet, vec[npoints-2]); return;}
!     int n = min(int(f),npoints-3);
!     float *fp = vec + n;
!     float frac = f - n;
!     float a=fp[-1], b=fp[0], c=fp[1], d=fp[2];
!     float cminusb = c-b;
!     outlet_float(x->outlet, b + frac * (cminusb - 0.1666667f * (1.-frac) * ((d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b))));
  }
+ static void tabread4_set(t_tabread4 *x, t_symbol *s) {x->arrayname = s;}
  static void *tabread4_new(t_symbol *s) {
      t_tabread4 *x = (t_tabread4 *)pd_new(tabread4_class);
***************
*** 891,907 ****
      t_garray *a = (t_garray *)pd_findbyclass(x->arrayname, garray_class);
      t_float *vec;
!     if (!a) error("%s: no such array", x->arrayname->name);
!     else if (!garray_getfloatarray(a, &vecsize, &vec))
!         error("%s: bad template for tabwrite", x->arrayname->name);
!     else {
!         int n = (int)x->ft1;
!         if (n < 0) n = 0; else if (n >= vecsize) n = vecsize-1;
!         vec[n] = f;
!         garray_redraw(a);
!     }
! }
! static void tabwrite_set(t_tabwrite *x, t_symbol *s) {
!     x->arrayname = s;
  }
  static void *tabwrite_new(t_symbol *s) {
      t_tabwrite *x = (t_tabwrite *)pd_new(tabwrite_class);
--- 862,873 ----
      t_garray *a = (t_garray *)pd_findbyclass(x->arrayname, garray_class);
      t_float *vec;
!     if (!a) {error("%s: no such array", x->arrayname->name); return;}
!     if (!garray_getfloatarray(a, &vecsize, &vec)) {error("%s: bad template for tabwrite", x->arrayname->name); return;}
!     int n = (int)x->ft1;
!     if (n < 0) n = 0; else if (n > vecsize-1) n = vecsize-1;
!     vec[n] = f;
!     garray_redraw(a);
  }
+ static void tabwrite_set(t_tabwrite *x, t_symbol *s) {x->arrayname = s;}
  static void *tabwrite_new(t_symbol *s) {
      t_tabwrite *x = (t_tabwrite *)pd_new(tabwrite_class);
***************
*** 934,945 ****
      int n = (int)w[3];
      for (; n; n -= 8, out += 8) {
!         out[0] = f;
!         out[1] = f;
!         out[2] = f;
!         out[3] = f;
!         out[4] = f;
!         out[5] = f;
!         out[6] = f;
!         out[7] = f;
      }
      return w+4;
--- 900,907 ----
      int n = (int)w[3];
      for (; n; n -= 8, out += 8) {
!         out[0] = f; out[1] = f;
!         out[2] = f; out[3] = f;
!         out[4] = f; out[5] = f;
!         out[6] = f; out[7] = f;
      }
      return w+4;
***************
*** 993,999 ****
      int n = (int)w[3];
      float f = x->value;
! 
!     if (PD_BIGORSMALL(f))
!             x->value = f = 0;
      if (x->retarget) {
          int nticks = (int)(x->inletwas * x->dspticktomsec);
--- 955,959 ----
      int n = (int)w[3];
      float f = x->value;
!     if (PD_BIGORSMALL(f)) x->value = f = 0;
      if (x->retarget) {
          int nticks = (int)(x->inletwas * x->dspticktomsec);





More information about the Pd-cvs mailing list