[PD-cvs] pd/src builtins_dsp.c,1.1.2.14,1.1.2.15

Mathieu Bouchard matju at users.sourceforge.net
Fri Jan 5 00:55:55 CET 2007


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

Modified Files:
      Tag: desiredata
	builtins_dsp.c 
Log Message:
shrink


Index: builtins_dsp.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/builtins_dsp.c,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -C2 -d -r1.1.2.14 -r1.1.2.15
*** builtins_dsp.c	4 Jan 2007 23:21:24 -0000	1.1.2.14
--- builtins_dsp.c	4 Jan 2007 23:55:53 -0000	1.1.2.15
***************
*** 2650,2655 ****
  /* ---------------- bp~ - 2-pole bandpass filter. ----------------- */
  struct t_bpctl {
!     float c_x1;
!     float c_x2;
      float c_coef1;
      float c_coef2;
--- 2650,2655 ----
  /* ---------------- bp~ - 2-pole bandpass filter. ----------------- */
  struct t_bpctl {
!     float x1;
!     float x2;
      float c_coef1;
      float c_coef2;
***************
*** 2673,2678 ****
      x->sr = 44100;
      x->ctl = &x->cspace;
!     x->cspace.c_x1 = 0;
!     x->cspace.c_x2 = 0;
      sigbp_docoef(x, f, q);
      x->a = 0;
--- 2673,2678 ----
      x->sr = 44100;
      x->ctl = &x->cspace;
!     x->cspace.x1 = 0;
!     x->cspace.x2 = 0;
      sigbp_docoef(x, f, q);
      x->a = 0;
***************
*** 2704,2708 ****
  static void sigbp_ft1(t_sigbp *x, t_floatarg f) {sigbp_docoef(x, f, x->q);}
  static void sigbp_ft2(t_sigbp *x, t_floatarg q) {sigbp_docoef(x, x->freq, q);}
! static void sigbp_clear(t_sigbp *x, t_floatarg q) {x->ctl->c_x1 = x->ctl->c_x2 = 0;}
  static t_int *sigbp_perform(t_int *w) {
      float *in = (float *)w[1];
--- 2704,2708 ----
  static void sigbp_ft1(t_sigbp *x, t_floatarg f) {sigbp_docoef(x, f, x->q);}
  static void sigbp_ft2(t_sigbp *x, t_floatarg q) {sigbp_docoef(x, x->freq, q);}
! static void sigbp_clear(t_sigbp *x, t_floatarg q) {x->ctl->x1 = x->ctl->x2 = 0;}
  static t_int *sigbp_perform(t_int *w) {
      float *in = (float *)w[1];
***************
*** 2710,2715 ****
      t_bpctl *c = (t_bpctl *)w[3];
      int n = (t_int)w[4];
!     float last = c->c_x1;
!     float prev = c->c_x2;
      float coef1 = c->c_coef1;
      float coef2 = c->c_coef2;
--- 2710,2715 ----
      t_bpctl *c = (t_bpctl *)w[3];
      int n = (t_int)w[4];
!     float last = c->x1;
!     float prev = c->x2;
      float coef1 = c->c_coef1;
      float coef2 = c->c_coef2;
***************
*** 2723,2728 ****
      if (PD_BIGORSMALL(last)) last = 0;
      if (PD_BIGORSMALL(prev)) prev = 0;
!     c->c_x1 = last;
!     c->c_x2 = prev;
      return w+5;
  }
--- 2723,2728 ----
      if (PD_BIGORSMALL(last)) last = 0;
      if (PD_BIGORSMALL(prev)) prev = 0;
!     c->x1 = last;
!     c->x2 = prev;
      return w+5;
  }
***************
*** 2744,2754 ****
  /* ---------------- biquad~ - raw biquad filter ----------------- */
  struct t_biquadctl {
!     float c_x1;
!     float c_x2;
!     float c_fb1;
!     float c_fb2;
!     float c_ff1;
!     float c_ff2;
!     float c_ff3;
  };
  struct t_sigbiquad : t_object {
--- 2744,2754 ----
  /* ---------------- biquad~ - raw biquad filter ----------------- */
  struct t_biquadctl {
!     float x1;
!     float x2;
!     float fb1;
!     float fb2;
!     float ff1;
!     float ff2;
!     float ff3;
  };
  struct t_sigbiquad : t_object {
***************
*** 2763,2767 ****
      outlet_new(x, &s_signal);
      x->ctl = &x->cspace;
!     x->cspace.c_x1 = x->cspace.c_x2 = 0;
      sigbiquad_list(x, s, argc, argv);
      x->a = 0;
--- 2763,2767 ----
      outlet_new(x, &s_signal);
      x->ctl = &x->cspace;
!     x->cspace.x1 = x->cspace.x2 = 0;
      sigbiquad_list(x, s, argc, argv);
      x->a = 0;
***************
*** 2773,2783 ****
      t_biquadctl *c = (t_biquadctl *)w[3];
      int n = (t_int)w[4];
!     float last = c->c_x1;
!     float prev = c->c_x2;
!     float fb1 = c->c_fb1;
!     float fb2 = c->c_fb2;
!     float ff1 = c->c_ff1;
!     float ff2 = c->c_ff2;
!     float ff3 = c->c_ff3;
      for (int i = 0; i < n; i++) {
          float output =  *in++ + fb1 * last + fb2 * prev;
--- 2773,2783 ----
      t_biquadctl *c = (t_biquadctl *)w[3];
      int n = (t_int)w[4];
!     float last = c->x1;
!     float prev = c->x2;
!     float fb1 = c->fb1;
!     float fb2 = c->fb2;
!     float ff1 = c->ff1;
!     float ff2 = c->ff2;
!     float ff3 = c->ff3;
      for (int i = 0; i < n; i++) {
          float output =  *in++ + fb1 * last + fb2 * prev;
***************
*** 2787,2792 ****
          last = output;
      }
!     c->c_x1 = last;
!     c->c_x2 = prev;
      return w+5;
  }
--- 2787,2792 ----
          last = output;
      }
!     c->x1 = last;
!     c->x2 = prev;
      return w+5;
  }
***************
*** 2798,2808 ****
      t_biquadctl *c = (t_biquadctl *)w[3];
      int n = (t_int)w[4]>>3;
!     float last = c->c_x1;
!     float prev = c->c_x2;
!     float fb1 = c->c_fb1;
!     float fb2 = c->c_fb2;
!     float ff1 = c->c_ff1;
!     float ff2 = c->c_ff2;
!     float ff3 = c->c_ff3;
      for (int i = 0; i < n; i++) {
          float output =  *in++ + fb1*last + fb2*prev;
--- 2798,2808 ----
      t_biquadctl *c = (t_biquadctl *)w[3];
      int n = (t_int)w[4]>>3;
!     float last = c->x1;
!     float prev = c->x2;
!     float fb1 = c->fb1;
!     float fb2 = c->fb2;
!     float ff1 = c->ff1;
!     float ff2 = c->ff2;
!     float ff3 = c->ff3;
      for (int i = 0; i < n; i++) {
          float output =  *in++ + fb1*last + fb2*prev;
***************
*** 2820,2825 ****
          *out++ = ff1*output + ff2*last + ff3*prev; prev=last; last=output;
      }
!     c->c_x1 = last;
!     c->c_x2 = prev;
      return w+5;
  }
--- 2820,2825 ----
          *out++ = ff1*output + ff2*last + ff3*prev; prev=last; last=output;
      }
!     c->x1 = last;
!     c->x2 = prev;
      return w+5;
  }
***************
*** 2845,2858 ****
      fb1 = fb2 = ff1 = ff2 = ff3 = 0;
  stable:
!     c->c_fb1 = fb1;
!     c->c_fb2 = fb2;
!     c->c_ff1 = ff1;
!     c->c_ff2 = ff2;
!     c->c_ff3 = ff3;
  }
  static void sigbiquad_set(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv) {
      t_biquadctl *c = x->ctl;
!     c->c_x1 = atom_getfloatarg(0, argc, argv);
!     c->c_x2 = atom_getfloatarg(1, argc, argv);
  }
  static void sigbiquad_dsp(t_sigbiquad *x, t_signal **sp) {
--- 2845,2858 ----
      fb1 = fb2 = ff1 = ff2 = ff3 = 0;
  stable:
!     c->fb1 = fb1;
!     c->fb2 = fb2;
!     c->ff1 = ff1;
!     c->ff2 = ff2;
!     c->ff3 = ff3;
  }
  static void sigbiquad_set(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv) {
      t_biquadctl *c = x->ctl;
!     c->x1 = atom_getfloatarg(0, argc, argv);
!     c->x2 = atom_getfloatarg(1, argc, argv);
  }
  static void sigbiquad_dsp(t_sigbiquad *x, t_signal **sp) {
***************
*** 2907,2914 ****
      dsp_add(sigsamphold_perform, 5, sp[0]->v, sp[1]->v, sp[2]->v, x, sp[0]->n);
  }
! static void sigsamphold_reset(t_sigsamphold *x, t_symbol *s, int argc,
!     t_atom *argv) {
!     x->lastin = ((argc > 0 && (argv[0].a_type == A_FLOAT)) ?
!         argv[0].a_w.w_float : 1e20);
  }
  static void sigsamphold_set(t_sigsamphold *x, t_float f) {
--- 2907,2912 ----
      dsp_add(sigsamphold_perform, 5, sp[0]->v, sp[1]->v, sp[2]->v, x, sp[0]->n);
  }
! static void sigsamphold_reset(t_sigsamphold *x, t_symbol *s, int argc, t_atom *argv) {
!     x->lastin = ((argc > 0 && (argv[0].a_type == A_FLOAT)) ? argv[0].a_w.w_float : 1e20);
  }
  static void sigsamphold_set(t_sigsamphold *x, t_float f) {
***************
*** 2931,2937 ****
  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;
--- 2929,2933 ----
  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;
***************
*** 3198,3205 ****
      float lastim = x->lastim;
      for (int i = 0; i < n; i++) {
!         float nextre = *inre1++;
!         float nextim = *inim1++;
!         float coefre = *inre2++;
!         float coefim = *inim2++;
              /* transfer function is (A bar) - Z^-1, for the same
              frequency response as 1 - AZ^-1 from czero_tilde. */
--- 3194,3199 ----
      float lastim = x->lastim;
      for (int i = 0; i < n; i++) {
!         float nextre = *inre1++, nextim = *inim1++;
!         float coefre = *inre2++, coefim = *inim2++;
              /* transfer function is (A bar) - Z^-1, for the same
              frequency response as 1 - AZ^-1 from czero_tilde. */
***************
*** 3261,3270 ****
  static void sigsend_dsp(t_sigsend *x, t_signal **sp) {
      const int n = x->n;
!     if(n == sp[0]->n) {
!         if(SIMD_CHECK1(n,sp[0]->v)) /* x->vec is aligned in any case */
!     	     dsp_add(sigsend_perfsimd, 3, sp[0]->v, x->vec, n);
!         else dsp_add(sigsend_perform,  3, sp[0]->v, x->vec, n);
!     }
!     else error("sigsend %s: unexpected vector size", x->sym->name);
  }
  static void sigsend_free(t_sigsend *x) {
--- 3255,3262 ----
  static void sigsend_dsp(t_sigsend *x, t_signal **sp) {
      const int n = x->n;
!     if(n != sp[0]->n) {error("sigsend %s: unexpected vector size", x->sym->name); return;}
!     if(SIMD_CHECK1(n,sp[0]->v)) /* x->vec is aligned in any case */
!          dsp_add(sigsend_perfsimd, 3, sp[0]->v, x->vec, n);
!     else dsp_add(sigsend_perform,  3, sp[0]->v, x->vec, n);
  }
  static void sigsend_free(t_sigsend *x) {
***************
*** 3339,3355 ****
  static void sigreceive_dsp(t_sigreceive *x, t_signal **sp) {
      const int n = x->n;
!     if (sp[0]->n != n) {
!         pd_error(x, "receive~ %s: vector size mismatch", x->sym->name);
!     } else {
!         sigreceive_set(x, x->sym);
! 	if(n&7)
! 	        dsp_add(sigreceive_perform, 3, x, sp[0]->v, n);
!         else 
! 		if(SIMD_CHECK1(n,sp[0]->v))
! 			/* x->wherefrom is aligned because we aligned the sender memory buffer */
! 			dsp_add(sigreceive_perfsimd, 3, x, sp[0]->v, n);
! 		else
! 			dsp_add(sigreceive_perf8, 3, x, sp[0]->v, n);
!     }
  }
  static void sigreceive_setup() {
--- 3331,3341 ----
  static void sigreceive_dsp(t_sigreceive *x, t_signal **sp) {
      const int n = x->n;
!     if (sp[0]->n != n) {pd_error(x, "receive~ %s: vector size mismatch", x->sym->name); return;}
!     sigreceive_set(x, x->sym);
!     /* x->wherefrom is aligned because we aligned the sender memory buffer */
!     if(n&7) dsp_add(sigreceive_perform,  3, x, sp[0]->v, n);
!     else if(SIMD_CHECK1(n,sp[0]->v))
! 	    dsp_add(sigreceive_perfsimd, 3, x, sp[0]->v, n);
!     else    dsp_add(sigreceive_perf8,    3, x, sp[0]->v, n);
  }
  static void sigreceive_setup() {
***************
*** 3399,3412 ****
  static void sigcatch_dsp(t_sigcatch *x, t_signal **sp) {
      const int n = sp[0]->n;
!     if (x->n == n) {
!     	if(n&7)
!     	    dsp_add(sigcatch_perform, 3, x->vec, sp[0]->v, n);
!     	else 
! 			if(SIMD_CHECK2(n,x->vec,sp[0]->v))
! 				dsp_add(sigcatch_perfsimd, 3, x->vec, sp[0]->v, n);
! 			else
! 				dsp_add(sigcatch_perf8, 3, x->vec, sp[0]->v, n);
!     }
!     else error("sigcatch %s: unexpected vector size", x->sym->name);
  }
  static void sigcatch_free(t_sigcatch *x) {
--- 3385,3393 ----
  static void sigcatch_dsp(t_sigcatch *x, t_signal **sp) {
      const int n = sp[0]->n;
!     if (x->n != n) {error("sigcatch %s: unexpected vector size", x->sym->name); return;}
!     if(n&7) dsp_add(sigcatch_perform, 3, x->vec, sp[0]->v, n);
!     else if(SIMD_CHECK2(n,x->vec,sp[0]->v))
! 	 dsp_add(sigcatch_perfsimd,   3, x->vec, sp[0]->v, n);
!     else dsp_add(sigcatch_perf8,      3, x->vec, sp[0]->v, n);
  }
  static void sigcatch_free(t_sigcatch *x) {
***************
*** 3440,3444 ****
      t_float *out = x->whereto;
      if(out) testaddvec(out,(t_float *)w[2],w[3]);
- 
      return w+4;
  }
--- 3421,3424 ----
***************
*** 3451,3466 ****
  }
  static void sigthrow_set(t_sigthrow *x, t_symbol *s) {
!     t_sigcatch *catcher = (t_sigcatch *)pd_findbyclass((x->sym = s),
!         sigcatch_class);
      if (catcher) {
          if (catcher->n == x->n) x->whereto = catcher->vec;
!         else {
!             pd_error(x, "throw~ %s: vector size mismatch", x->sym->name);
!             x->whereto = 0;
!         }
!     } else {
!         pd_error(x, "throw~ %s: no matching catch", x->sym->name);
!         x->whereto = 0;
!     }
  }
  static void sigthrow_dsp(t_sigthrow *x, t_signal **sp) {
--- 3431,3441 ----
  }
  static void sigthrow_set(t_sigthrow *x, t_symbol *s) {
!     x->sym = s;
!     t_sigcatch *catcher = (t_sigcatch *)pd_findbyclass(s,sigcatch_class);
!     x->whereto = 0;
      if (catcher) {
          if (catcher->n == x->n) x->whereto = catcher->vec;
!         else pd_error(x, "throw~ %s: vector size mismatch", x->sym->name);
!     } else pd_error(x, "throw~ %s: no matching catch", x->sym->name);
  }
  static void sigthrow_dsp(t_sigthrow *x, t_signal **sp) {
***************
*** 3502,3511 ****
      const t_float lo = *(t_float *)w[3],hi = *(t_float *)w[4];
      int n = (int)w[5];
!     while (n--) {
!         float f = *in++;
!     	if (f < lo) f = lo;
!     	else if (f > hi) f = hi;
!         *out++ = f;
!     }
      return w+6;
  }
--- 3477,3481 ----
      const t_float lo = *(t_float *)w[3],hi = *(t_float *)w[4];
      int n = (int)w[5];
!     while (n--) *out++ = clip(*in++,lo,hi);
      return w+6;
  }
***************
*** 3513,3517 ****
      if(SIMD_CHECK2(sp[0]->n,sp[0]->v,sp[1]->v))
  	 dsp_add(clip_perf_simd, 5, sp[0]->v, sp[1]->v, &x->lo, &x->hi, sp[0]->n);
!     else dsp_add(clip_perform, 5, sp[0]->v, sp[1]->v, &x->lo, &x->hi, sp[0]->n);
  }
  static void clip_setup() {
--- 3483,3487 ----
      if(SIMD_CHECK2(sp[0]->n,sp[0]->v,sp[1]->v))
  	 dsp_add(clip_perf_simd, 5, sp[0]->v, sp[1]->v, &x->lo, &x->hi, sp[0]->n);
!     else dsp_add(clip_perform,   5, sp[0]->v, sp[1]->v, &x->lo, &x->hi, sp[0]->n);
  }
  static void clip_setup() {
***************
*** 3570,3574 ****
      float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
      t_int n = *(t_int *)(w+3);
!     while (n--) {   
          float f = *in;
          long l = *(long *)(in++);
--- 3540,3544 ----
      float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
      t_int n = *(t_int *)(w+3);
!     while (n--) {
          float f = *in;
          long l = *(long *)(in++);
***************
*** 3576,3580 ****
          else {
              float g = rsqrt_exptab[(l >> 23) & 0xff] *
!                 rsqrt_mantissatab[(l >> 13) & 0x3ff];
              *out++ = 1.5 * g - 0.5 * g * g * g * f;
          }
--- 3546,3550 ----
          else {
              float g = rsqrt_exptab[(l >> 23) & 0xff] *
!                  rsqrt_mantissatab[(l >> 13) & 0x3ff];
              *out++ = 1.5 * g - 0.5 * g * g * g * f;
          }
***************
*** 3669,3680 ****
  
  /* ------------------------------ mtof_tilde~ and such -------------------------- */
- 
  struct t_func1 : t_object {float a;};
! t_class *mtof_tilde_class;
! t_class *ftom_tilde_class;
! t_class *dbtorms_tilde_class;
! t_class *rmstodb_tilde_class;
! t_class *dbtopow_tilde_class;
! t_class *powtodb_tilde_class;
  
  static t_int *mtof_tilde_perform(t_int *w) {
--- 3639,3646 ----
  
  /* ------------------------------ mtof_tilde~ and such -------------------------- */
  struct t_func1 : t_object {float a;};
! t_class *mtof_tilde_class, *ftom_tilde_class;
! t_class *dbtorms_tilde_class, *rmstodb_tilde_class;
! t_class *dbtopow_tilde_class, *powtodb_tilde_class;
  
  static t_int *mtof_tilde_perform(t_int *w) {
***************
*** 3683,3695 ****
      for (; n--; in++, out++) {
          float f = *in;
!         if (f <= -1500) *out = 0;
!         else {
!             if (f > 1499) f = 1499;
!             *out = 8.17579891564 * exp(.0577622650 * f);
!         }
      }
      return w+4;
  }
- 
  static t_int *ftom_tilde_perform(t_int *w) {
      float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
--- 3649,3656 ----
      for (; n--; in++, out++) {
          float f = *in;
!         *out = f<=-1500 ? 0 : 8.17579891564 * exp(.0577622650 * min(f,1499.f));
      }
      return w+4;
  }
  static t_int *ftom_tilde_perform(t_int *w) {
      float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
***************
*** 3704,3712 ****
      for (t_int n = *(t_int *)(w+3); n--; in++, out++) {
          float f = *in;
!         if (f <= 0) *out = 0;
!         else {
!             if (f > 485) f = 485;
!             *out = exp((LOGTEN * 0.05) * (f-100.));
!         }
      }
      return w+4;
--- 3665,3669 ----
      for (t_int n = *(t_int *)(w+3); n--; in++, out++) {
          float f = *in;
!         *out = f<=0 ? 0 : exp((LOGTEN * 0.05) * (min(f,485.f)-100.));
      }
      return w+4;
***************
*** 3716,3724 ****
      for (t_int n = *(t_int *)(w+3); n--; in++, out++) {
          float f = *in;
!         if (f <= 0) *out = 0;
!         else {
!             float g = 100 + 20./LOGTEN * log(f);
!             *out = (g < 0 ? 0 : g);
!         }
      }
      return w+4;
--- 3673,3677 ----
      for (t_int n = *(t_int *)(w+3); n--; in++, out++) {
          float f = *in;
!         *out = f<=0 ? 0 : max(100 + 20./LOGTEN * log(f),0.);
      }
      return w+4;
***************
*** 3728,3736 ****
      for (t_int n = *(t_int *)(w+3); n--; in++, out++) {
          float f = *in;
!         if (f <= 0) *out = 0;
!         else {
!             if (f > 870) f = 870;
!             *out = exp((LOGTEN * 0.1) * (f-100.));
!         }
      }
      return w+4;
--- 3681,3685 ----
      for (t_int n = *(t_int *)(w+3); n--; in++, out++) {
          float f = *in;
!         *out = f<=0 ? 0 : exp((LOGTEN * 0.1) * (min(f,870.f)-100.));
      }
      return w+4;
***************
*** 3740,3797 ****
      for (t_int n = *(t_int *)(w+3); n--; in++, out++) {
          float f = *in;
!         if (f <= 0) *out = 0;
!         else {
!             float g = 100 + 10./LOGTEN * log(f);
!             *out = (g < 0 ? 0 : g);
!         }
      }
      return w+4;
  }
  
! static void *mtof_tilde_new() {t_func1 *x = (t_func1 *)pd_new(mtof_tilde_class);
!     outlet_new(x, gensym("signal")); x->a = 0; return x;}
! static void *ftom_tilde_new() {t_func1 *x = (t_func1 *)pd_new(ftom_tilde_class);
!     outlet_new(x, gensym("signal")); x->a = 0; return x;}
! static void *dbtorms_tilde_new() {t_func1 *x = (t_func1 *)pd_new(dbtorms_tilde_class);
!     outlet_new(x, gensym("signal")); x->a = 0; return x;}
! static void *rmstodb_tilde_new() {t_func1 *x = (t_func1 *)pd_new(rmstodb_tilde_class);
!     outlet_new(x, gensym("signal")); x->a = 0; return x;}
! static void *dbtopow_tilde_new() {t_func1 *x = (t_func1 *)pd_new(dbtopow_tilde_class);
!     outlet_new(x, gensym("signal")); x->a = 0; return x;}
! static void *powtodb_tilde_new() {t_func1 *x = (t_func1 *)pd_new(powtodb_tilde_class);
!     outlet_new(x, gensym("signal")); x->a = 0; return x;}
  
! static void    mtof_tilde_dsp(t_func1 *x, t_signal **sp) {
!     dsp_add(   mtof_tilde_perform, 3, sp[0]->v, sp[1]->v, sp[0]->n);}
! static void    ftom_tilde_dsp(t_func1 *x, t_signal **sp) {
!     dsp_add(   ftom_tilde_perform, 3, sp[0]->v, sp[1]->v, sp[0]->n);}
! static void dbtorms_tilde_dsp(t_func1 *x, t_signal **sp) {
!     dsp_add(dbtorms_tilde_perform, 3, sp[0]->v, sp[1]->v, sp[0]->n);}
! static void rmstodb_tilde_dsp(t_func1 *x, t_signal **sp) {
!     dsp_add(rmstodb_tilde_perform, 3, sp[0]->v, sp[1]->v, sp[0]->n);}
! static void dbtopow_tilde_dsp(t_func1 *x, t_signal **sp) {
!     dsp_add(dbtopow_tilde_perform, 3, sp[0]->v, sp[1]->v, sp[0]->n);}
! static void powtodb_tilde_dsp(t_func1 *x, t_signal **sp) {
!     dsp_add(powtodb_tilde_perform, 3, sp[0]->v, sp[1]->v, sp[0]->n);}
  
  void mtof_tilde_setup() {
!     mtof_tilde_class = class_new2("mtof~",mtof_tilde_new,0,sizeof(t_func1),0,"");
!     CLASS_MAINSIGNALIN(mtof_tilde_class,t_func1,a);
!     class_addmethod2(mtof_tilde_class, mtof_tilde_dsp, "dsp","");
!     ftom_tilde_class = class_new2("ftom~",ftom_tilde_new,0,sizeof(t_func1),0,"");
!     CLASS_MAINSIGNALIN(ftom_tilde_class,t_func1,a);
!     class_addmethod2(ftom_tilde_class, ftom_tilde_dsp, "dsp","");
!     dbtorms_tilde_class = class_new2("dbtorms~",dbtorms_tilde_new,0,sizeof(t_func1),0,"");
!     CLASS_MAINSIGNALIN(dbtorms_tilde_class,t_func1,a);
!     class_addmethod2(dbtorms_tilde_class, dbtorms_tilde_dsp, "dsp","");
!     rmstodb_tilde_class = class_new2("rmstodb~",rmstodb_tilde_new,0,sizeof(t_func1),0,"");
!     CLASS_MAINSIGNALIN(rmstodb_tilde_class,t_func1,a);
!     class_addmethod2(rmstodb_tilde_class, rmstodb_tilde_dsp, "dsp","");
!     dbtopow_tilde_class = class_new2("dbtopow~",dbtopow_tilde_new,0,sizeof(t_func1),0,"");
!     CLASS_MAINSIGNALIN(dbtopow_tilde_class,t_func1,a);
!     class_addmethod2(dbtopow_tilde_class, dbtopow_tilde_dsp, "dsp","");
!     powtodb_tilde_class = class_new2("powtodb~",powtodb_tilde_new,0,sizeof(t_func1),0,"");
!     CLASS_MAINSIGNALIN(powtodb_tilde_class,t_func1,a);
!     class_addmethod2(powtodb_tilde_class, powtodb_tilde_dsp, "dsp","");
      t_symbol *s = gensym("acoustics~.pd");
      class_sethelpsymbol(mtof_tilde_class, s);
--- 3689,3721 ----
      for (t_int n = *(t_int *)(w+3); n--; in++, out++) {
          float f = *in;
!         *out = f<=0 ? 0 : max(100 + 10./LOGTEN * log(f),0.);
      }
      return w+4;
  }
  
! #define FUNC1(NAME) \
! static void *NAME##_new() {t_func1 *x = (t_func1 *)pd_new(NAME##_class); \
!     outlet_new(x,&s_signal); x->a = 0; return x;} \
! static void NAME##_dsp(t_func1 *x, t_signal **sp) { \
!     dsp_add(NAME##_perform, 3, sp[0]->v, sp[1]->v, sp[0]->n);}
! FUNC1(mtof_tilde)
! FUNC1(ftom_tilde)
! FUNC1(dbtorms_tilde)
! FUNC1(dbtopow_tilde)
! FUNC1(rmstodb_tilde)
! FUNC1(powtodb_tilde)
  
! #define FUNC1DECL(NAME,SYM) \
!     NAME##_class = class_new2(SYM,NAME##_new,0,sizeof(t_func1),0,""); \
!     CLASS_MAINSIGNALIN(NAME##_class,t_func1,a); \
!     class_addmethod2(NAME##_class, NAME##_dsp, "dsp","");
  
  void mtof_tilde_setup() {
!     FUNC1DECL(mtof_tilde,"mtof~")
!     FUNC1DECL(ftom_tilde,"ftom~")
!     FUNC1DECL(dbtorms_tilde,"dbtorms~")
!     FUNC1DECL(dbtopow_tilde,"dbtopow~")
!     FUNC1DECL(rmstodb_tilde,"rmstodb~")
!     FUNC1DECL(powtodb_tilde,"powtodb~")
      t_symbol *s = gensym("acoustics~.pd");
      class_sethelpsymbol(mtof_tilde_class, s);
***************
*** 3831,3841 ****
      dsp_add(print_perform, 3, x, sp[0]->v, sp[0]->n);
  }
! static void print_float(t_print *x, t_float f) {
!     if (f < 0) f = 0;
!     x->count = (int)f;
! }
! static void print_bang(t_print *x) {
!     x->count = 1;
! }
  static void *print_new(t_symbol *s) {
      t_print *x = (t_print *)pd_new(print_class);
--- 3755,3760 ----
      dsp_add(print_perform, 3, x, sp[0]->v, sp[0]->n);
  }
! static void print_float(t_print *x, t_float f) {x->count = max(0,(int)f);}
! static void print_bang(t_print *x) {x->count = 1;}
  static void *print_new(t_symbol *s) {
      t_print *x = (t_print *)pd_new(print_class);
***************
*** 3863,3875 ****
      return w+2;
  }
! static void bang_tilde_dsp(t_bang *x, t_signal **sp) {
!     dsp_add(bang_tilde_perform, 1, x);
! }
! static void bang_tilde_tick(t_bang *x) {
!     outlet_bang(x->outlet);
! }
! static void bang_tilde_free(t_bang *x) {
!     clock_free(x->clock);
! }
  static void *bang_tilde_new(t_symbol *s) {
      t_bang *x = (t_bang *)pd_new(bang_tilde_class);
--- 3782,3788 ----
      return w+2;
  }
! static void bang_tilde_dsp(t_bang *x, t_signal **sp) {dsp_add(bang_tilde_perform, 1, x);}
! static void bang_tilde_tick(t_bang *x) {outlet_bang(x->outlet);}
! static void bang_tilde_free(t_bang *x) {clock_free(x->clock);}
  static void *bang_tilde_new(t_symbol *s) {
      t_bang *x = (t_bang *)pd_new(bang_tilde_class);
***************
*** 3979,3988 ****
      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;
      }
--- 3892,3901 ----
      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;
      }
***************
*** 4203,4207 ****
      t_noise *x = (t_noise *)pd_new(noise_class);
      static int init = 307;
!     x->val = (init *= 1319); 
      outlet_new(x, gensym("signal"));
      return x;
--- 4116,4120 ----
      t_noise *x = (t_noise *)pd_new(noise_class);
      static int init = 307;
!     x->val = (init *= 1319);
      outlet_new(x, gensym("signal"));
      return x;
***************
*** 4213,4218 ****
      int val = *vp;
      while (n--) {
!         *out++ = ((float)((val & 0x7fffffff) - 0x40000000)) *
!             (float)(1.0 / 0x40000000);
          val = val * 435898247 + 382842987;
      }
--- 4126,4130 ----
      int val = *vp;
      while (n--) {
!         *out++ = ((float)((val & 0x7fffffff) - 0x40000000)) * (float)(1.0 / 0x40000000);
          val = val * 435898247 + 382842987;
      }





More information about the Pd-cvs mailing list