From 33dd6d603830640766aa1a5fe70137c856e2c145 Mon Sep 17 00:00:00 2001 From: musil Date: Thu, 6 Sep 2012 15:54:46 +0000 Subject: other variable names, t_float to t_sample change, array access 64 bit svn path=/trunk/externals/iemlib/; revision=16193 --- iemlib1/src/biquad_freq_resp.c | 46 ++++++----- iemlib1/src/iem_cot4~.c | 1 - iemlib1/src/iem_pow4~.c | 54 +++++++----- iemlib1/src/iem_sqrt4~.c | 57 ++++++------- iemlib1/src/lp1_t~.c | 50 +++++------ iemlib1/src/mov_avrg_kern~.c | 16 ++-- iemlib1/src/para_bp2~.c | 170 +++++++++++++++++++------------------- iemlib1/src/peakenv_hold~.c | 18 ++-- iemlib1/src/peakenv~.c | 18 ++-- iemlib1/src/prvu~.c | 123 ++++++++++++++-------------- iemlib1/src/pvu~.c | 63 +++++++------- iemlib1/src/rvu~.c | 75 +++++++++-------- iemlib1/src/sin_phase~.c | 75 +++++++++-------- iemlib1/src/soundfile_info.c | 182 ++++++++++++++++++++++++++++++++++++++++- iemlib1/src/sparse_FIR~.c | 26 +++--- iemlib1/src/vcf_filter~.c | 174 +++++++++++++++++++-------------------- 16 files changed, 672 insertions(+), 476 deletions(-) diff --git a/iemlib1/src/biquad_freq_resp.c b/iemlib1/src/biquad_freq_resp.c index 4fe9d31..aaadfac 100644 --- a/iemlib1/src/biquad_freq_resp.c +++ b/iemlib1/src/biquad_freq_resp.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2011 */ #include "m_pd.h" @@ -21,33 +21,39 @@ typedef struct _biquad_freq_resp t_float b2; t_outlet *x_out_re; t_outlet *x_out_im; + t_outlet *x_out_abs; + t_outlet *x_out_arg; } t_biquad_freq_resp; static t_class *biquad_freq_resp_class; static void biquad_freq_resp_float(t_biquad_freq_resp *x, t_floatarg freq_phase) { - t_float re1, im1, re2, im2; - t_float c, s, a; - t_float pi = 4.0f * atan(1.0f); + t_float re1, im1, re2, im2, re, im; + t_float c, s, ra; + t_float pi = 4.0 * atan(1.0); - if(freq_phase < 0.0f) - freq_phase = 0.0f; - else if(freq_phase > 180.0f) + if(freq_phase < 0.0) + freq_phase = 0.0; + else if(freq_phase > 180.0) freq_phase = 180.0; freq_phase *= pi; - freq_phase /= 180.0f; + freq_phase /= 180.0; c = cos(freq_phase); s = sin(freq_phase); re1 = x->a0 + x->a1*c + x->a2*(c*c - s*s); - im1 = x->a1*s + x->a2*2.0f*(s*c); - re2 = 1.0f - x->b1*c - x->b2*(c*c - s*s); - im2 = -x->b1*s - x->b2*2.0f*(s*c); - a = re2*re2 + im2*im2; - outlet_float(x->x_out_im, (re1*im2 - re2*im1)/a);/* because z^-1 = e^-jwt, negative sign */ - outlet_float(x->x_out_re, (re1*re2 + im1*im2)/a); + im1 = x->a1*s + x->a2*2.0*(s*c); + re2 = 1.0 - x->b1*c - x->b2*(c*c - s*s); + im2 = -x->b1*s - x->b2*2.0*(s*c); + ra = 1.0 / (re2*re2 + im2*im2); + im = (re1*im2 - re2*im1) * ra; /* because z^-1 = e^-jwt, negative sign */ + re = (re1*re2 + im1*im2) * ra; + outlet_float(x->x_out_arg, 180.0*atan2(im, re)/pi); + outlet_float(x->x_out_abs, sqrt(re*re + im*im)); + outlet_float(x->x_out_im, im); + outlet_float(x->x_out_re, re); } /* y/x = (a0 + a1*z-1 + a2*z-2)/(1 - b1*z-1 - b2*z-2);*/ @@ -69,11 +75,13 @@ static void *biquad_freq_resp_new(void) t_biquad_freq_resp *x = (t_biquad_freq_resp *)pd_new(biquad_freq_resp_class); x->x_out_re = outlet_new(&x->x_obj, &s_float); x->x_out_im = outlet_new(&x->x_obj, &s_float); - x->b1 = 0.0f; - x->b2 = 0.0f; - x->a0 = 0.0f; - x->a1 = 0.0f; - x->a2 = 0.0f; + x->x_out_abs = outlet_new(&x->x_obj, &s_float); + x->x_out_arg = outlet_new(&x->x_obj, &s_float); + x->b1 = 0.0; + x->b2 = 0.0; + x->a0 = 0.0; + x->a1 = 0.0; + x->a2 = 0.0; return (x); } diff --git a/iemlib1/src/iem_cot4~.c b/iemlib1/src/iem_cot4~.c index 4c9c811..70de93f 100644 --- a/iemlib1/src/iem_cot4~.c +++ b/iemlib1/src/iem_cot4~.c @@ -164,5 +164,4 @@ void iem_cot4_tilde_setup(void) CLASS_MAINSIGNALIN(iem_cot4_tilde_class, t_iem_cot4_tilde, x_float_sig_in); class_addmethod(iem_cot4_tilde_class, (t_method)iem_cot4_tilde_dsp, gensym("dsp"), 0); iem_cot4_tilde_maketable(); -// class_sethelpsymbol(iem_cot4_tilde_class, gensym("iemhelp/help-iem_cot4~")); } diff --git a/iemlib1/src/iem_pow4~.c b/iemlib1/src/iem_pow4~.c index 38dfbad..a34a490 100644 --- a/iemlib1/src/iem_pow4~.c +++ b/iemlib1/src/iem_pow4~.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2012 */ #include "m_pd.h" #include "iemlib.h" @@ -14,37 +14,49 @@ static t_class *iem_pow4_tilde_class; typedef struct _iem_pow4_tilde { t_object x_obj; - t_float x_exp; + t_sample x_exp; t_float x_float_sig_in; } t_iem_pow4_tilde; static void iem_pow4_tilde_ft1(t_iem_pow4_tilde *x, t_floatarg f) { - x->x_exp = f; + x->x_exp = (t_sample)f; } static t_int *iem_pow4_tilde_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[2]); + t_sample *in = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[2]); t_iem_pow4_tilde *x = (t_iem_pow4_tilde *)(w[3]); - t_float y=x->x_exp; - t_float f, g; + t_sample exp=x->x_exp; + t_sample f, g; int n = (int)(w[4])/4; while (n--) { - f = *in; - if(f < 0.01f) - f = 0.01f; - else if(f > 1000.0f) - f = 1000.0f; - g = log(f); - f = exp(g*y); - *out++ = f; - *out++ = f; - *out++ = f; - *out++ = f; + f = (t_sample)(*in); + if(f > 0.0) + { + g = log(f); + f = exp(g * exp); + *out++ = f; + *out++ = f; + *out++ = f; + *out++ = f; + + /*g = pow(f, exp); + *out++ = g; + *out++ = g; + *out++ = g; + *out++ = g;*/ + } + else + { + *out++ = 0.0; + *out++ = 0.0; + *out++ = 0.0; + *out++ = 0.0; + } in += 4; } return (w+5); @@ -59,10 +71,10 @@ static void *iem_pow4_tilde_new(t_floatarg f) { t_iem_pow4_tilde *x = (t_iem_pow4_tilde *)pd_new(iem_pow4_tilde_class); - x->x_exp = f; + x->x_exp = (t_sample)f; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); outlet_new(&x->x_obj, gensym("signal")); - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; return (x); } @@ -70,9 +82,7 @@ void iem_pow4_tilde_setup(void) { iem_pow4_tilde_class = class_new(gensym("iem_pow4~"), (t_newmethod)iem_pow4_tilde_new, 0, sizeof(t_iem_pow4_tilde), 0, A_DEFFLOAT, 0); - class_addcreator((t_newmethod)iem_pow4_tilde_new, gensym("icot~"), 0); CLASS_MAINSIGNALIN(iem_pow4_tilde_class, t_iem_pow4_tilde, x_float_sig_in); class_addmethod(iem_pow4_tilde_class, (t_method)iem_pow4_tilde_dsp, gensym("dsp"), 0); class_addmethod(iem_pow4_tilde_class, (t_method)iem_pow4_tilde_ft1, gensym("ft1"), A_FLOAT, 0); -// class_sethelpsymbol(iem_pow4_tilde_class, gensym("iemhelp/help-iem_pow4~")); } diff --git a/iemlib1/src/iem_sqrt4~.c b/iemlib1/src/iem_sqrt4~.c index f721b20..0b4049d 100644 --- a/iemlib1/src/iem_sqrt4~.c +++ b/iemlib1/src/iem_sqrt4~.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2012 */ #include "m_pd.h" #include "iemlib.h" @@ -12,40 +12,40 @@ iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 /* ------------------------ iem_sqrt4~ ----------------------------- */ -static t_float *iem_sqrt4_tilde_exptab=(t_float *)0L; -static t_float *iem_sqrt4_tilde_mantissatab=(t_float *)0L; +static t_float iem_rsqrt4_tilde_exptab[IEMSQRT4TAB1SIZE]; +static t_float iem_rsqrt4_tilde_mantissatab[IEMSQRT4TAB2SIZE]; static t_class *iem_sqrt4_tilde_class; typedef struct _iem_sqrt4_tilde { t_object x_obj; - t_float x_msi; + t_float x_float_sig_in; } t_iem_sqrt4_tilde; static t_int *iem_sqrt4_tilde_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[2]); + t_sample *in = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[2]); t_int n = (t_int)(w[3])/4; while(n--) { - t_float f = *in; - t_float g, h; + t_sample f = *in; + t_sample g, h; union tabfudge_f tf; - if(f < 0.0f) + if(f <= 0.0) { - *out++ = 0.0f; - *out++ = 0.0f; - *out++ = 0.0f; - *out++ = 0.0f; + *out++ = 0.0; + *out++ = 0.0; + *out++ = 0.0; + *out++ = 0.0; } else { tf.tf_f = f; - g = iem_sqrt4_tilde_exptab[((tf.tf_l) >> 23) & 0xff] * iem_sqrt4_tilde_mantissatab[((tf.tf_l) >> 13) & 0x3ff]; + g = iem_rsqrt4_tilde_exptab[((tf.tf_l) >> 23) & 0xff] * iem_rsqrt4_tilde_mantissatab[((tf.tf_l) >> 13) & 0x3ff]; h = f * (1.5f * g - 0.5f * g * g * g * f); *out++ = h; *out++ = h; @@ -62,29 +62,21 @@ static void iem_sqrt4_tilde_dsp(t_iem_sqrt4_tilde *x, t_signal **sp) dsp_add(iem_sqrt4_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } -static void iem_sqrt4_tilde_maketable(void) +static void iem_sqrt4_tilde_init(void) { int i; t_float f; union tabfudge_f tf; - if(!iem_sqrt4_tilde_exptab) + for(i=0; ix_obj, gensym("signal")); - x->x_msi = 0; + x->x_float_sig_in = 0; return (x); } void iem_sqrt4_tilde_setup(void) { + iem_sqrt4_tilde_init(); iem_sqrt4_tilde_class = class_new(gensym("iem_sqrt4~"), (t_newmethod)iem_sqrt4_tilde_new, 0, sizeof(t_iem_sqrt4_tilde), 0, 0); - CLASS_MAINSIGNALIN(iem_sqrt4_tilde_class, t_iem_sqrt4_tilde, x_msi); + CLASS_MAINSIGNALIN(iem_sqrt4_tilde_class, t_iem_sqrt4_tilde, x_float_sig_in); class_addmethod(iem_sqrt4_tilde_class, (t_method)iem_sqrt4_tilde_dsp, gensym("dsp"), 0); - iem_sqrt4_tilde_maketable(); -// class_sethelpsymbol(iem_sqrt4_tilde_class, gensym("iemhelp/help-iem_sqrt4~")); } diff --git a/iemlib1/src/lp1_t~.c b/iemlib1/src/lp1_t~.c index 251cfe7..1444e21 100644 --- a/iemlib1/src/lp1_t~.c +++ b/iemlib1/src/lp1_t~.c @@ -54,8 +54,8 @@ static void lp1_t_tilde_dsp_tick(t_lp1_t_tilde *x) static t_int *lp1_t_tilde_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[2]); + t_sample *in = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[2]); t_lp1_t_tilde *x = (t_lp1_t_tilde *)(w[3]); int i, n = (t_int)(w[4]); double yn0, yn1=x->yn1; @@ -65,7 +65,7 @@ static t_int *lp1_t_tilde_perform(t_int *w) for(i=0; iticks = i; - x->rcp_ticks = 1.0f / (t_float)i; + x->rcp_ticks = 1.0 / (t_float)i; } static void lp1_t_tilde_ft1(t_lp1_t_tilde *x, t_floatarg f_time_const) { double d_time_const; - if(f_time_const < 0.0f) - f_time_const = 0.0f; + if(f_time_const < 0.0) + f_time_const = 0.0; d_time_const = (double)f_time_const; if(d_time_const != x->cur_t) { @@ -150,12 +150,12 @@ static void lp1_t_tilde_dsp(t_lp1_t_tilde *x, t_signal **sp) int i, n=(int)sp[0]->s_n; x->sr = -1000.0 / (double)(sp[0]->s_sr); - x->ticks_per_interpol_time = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n; + x->ticks_per_interpol_time = 0.001 * (t_float)(sp[0]->s_sr) / (t_float)n; i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); if(i <= 0) i = 1; x->ticks = i; - x->rcp_ticks = 1.0f / (t_float)i; + x->rcp_ticks = 1.0 / (t_float)i; if(x->cur_t == 0.0) x->c1 = 0.0; else @@ -171,16 +171,16 @@ static void *lp1_t_tilde_new(t_symbol *s, int argc, t_atom *argv) { t_lp1_t_tilde *x = (t_lp1_t_tilde *)pd_new(lp1_t_tilde_class); int i; - t_float interpol=0.0f; + t_float interpol=0.0; double time_const=0.0; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); outlet_new(&x->x_obj, &s_signal); - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; x->counter_t = 1; x->delta_t = 0.0; - x->interpol_time = 0.0f; + x->interpol_time = 0.0; x->yn1 = 0.0; x->sr = -1.0 / 44.1; if((argc >= 1)&&IS_A_FLOAT(argv,0)) @@ -195,15 +195,15 @@ static void *lp1_t_tilde_new(t_symbol *s, int argc, t_atom *argv) else x->c1 = exp((x->sr)/time_const); x->c0 = 1.0 - x->c1; - if(interpol < 0.0f) - interpol = 0.0f; + if(interpol < 0.0) + interpol = 0.0; x->interpol_time = interpol; - x->ticks_per_interpol_time = 0.5f; + x->ticks_per_interpol_time = 0.5; i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); if(i <= 0) i = 1; x->ticks = i; - x->rcp_ticks = 1.0f / (t_float)i; + x->rcp_ticks = 1.0 / (t_float)i; x->end_t = x->cur_t; return (x); } diff --git a/iemlib1/src/mov_avrg_kern~.c b/iemlib1/src/mov_avrg_kern~.c index dbd680f..20a6f85 100644 --- a/iemlib1/src/mov_avrg_kern~.c +++ b/iemlib1/src/mov_avrg_kern~.c @@ -26,9 +26,9 @@ static t_class *mov_avrg_kern_tilde_class; static t_int *mov_avrg_kern_tilde_perform(t_int *w) { - t_float *in_direct = (t_float *)(w[1]); - t_float *in_delayed = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); + t_sample *in_direct = (t_sample *)(w[1]); + t_sample *in_delayed = (t_sample *)(w[2]); + t_sample *out = (t_sample *)(w[3]); t_mov_avrg_kern_tilde *x = (t_mov_avrg_kern_tilde *)(w[4]); int i, n = (int)(w[5]); double wn0, wn1=x->x_wn1, a0=x->x_a0; @@ -43,7 +43,7 @@ static t_int *mov_avrg_kern_tilde_perform(t_int *w) for(i=0; ix_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); outlet_new(&x->x_obj, &s_signal); - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; return(x); } diff --git a/iemlib1/src/para_bp2~.c b/iemlib1/src/para_bp2~.c index ffeb41d..9ee17e8 100644 --- a/iemlib1/src/para_bp2~.c +++ b/iemlib1/src/para_bp2~.c @@ -51,12 +51,12 @@ static void para_bp2_tilde_calc(t_para_bp2_tilde *x) t_float l, al, gal, l2, rcp; l = x->cur_l; - l2 = l*l + 1.0f; + l2 = l*l + 1.0; al = l*x->cur_a; gal = al*x->cur_g; - rcp = 1.0f/(al + l2); + rcp = 1.0/(al + l2); x->a0 = rcp*(l2 + gal); - x->a1 = rcp*2.0f*(2.0f - l2); + x->a1 = rcp*2.0*(2.0 - l2); x->a2 = rcp*(l2 - gal); x->b1 = -x->a1; x->b2 = rcp*(al - l2); @@ -84,10 +84,10 @@ static void para_bp2_tilde_dsp_tick(t_para_bp2_tilde *x) x->cur_f *= x->delta_f; } l = x->cur_f * x->sr; - if(l < 1.0e-20f) - x->cur_l = 1.0e20f; - else if(l > 1.57079632f) - x->cur_l = 0.0f; + if(l < 1.0e-20) + x->cur_l = 1.0e20; + else if(l > 1.57079632) + x->cur_l = 0.0; else { si = sin(l); @@ -128,31 +128,31 @@ static void para_bp2_tilde_dsp_tick(t_para_bp2_tilde *x) /* stability check */ - discriminant = x->b1 * x->b1 + 4.0f * x->b2; - if(x->b1 <= -1.9999996f) - x->b1 = -1.9999996f; - else if(x->b1 >= 1.9999996f) - x->b1 = 1.9999996f; + discriminant = x->b1 * x->b1 + 4.0 * x->b2; + if(x->b1 <= -1.9999996) + x->b1 = -1.9999996; + else if(x->b1 >= 1.9999996) + x->b1 = 1.9999996; - if(x->b2 <= -0.9999998f) - x->b2 = -0.9999998f; - else if(x->b2 >= 0.9999998f) - x->b2 = 0.9999998f; + if(x->b2 <= -0.9999998) + x->b2 = -0.9999998; + else if(x->b2 >= 0.9999998) + x->b2 = 0.9999998; - if(discriminant >= 0.0f) + if(discriminant >= 0.0) { - if(0.9999998f - x->b1 - x->b2 < 0.0f) - x->b2 = 0.9999998f - x->b1; - if(0.9999998f + x->b1 - x->b2 < 0.0f) - x->b2 = 0.9999998f + x->b1; + if(0.9999998 - x->b1 - x->b2 < 0.0) + x->b2 = 0.9999998 - x->b1; + if(0.9999998 + x->b1 - x->b2 < 0.0) + x->b2 = 0.9999998 + x->b1; } } } static t_int *para_bp2_tilde_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[2]); + t_sample *in = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[2]); t_para_bp2_tilde *x = (t_para_bp2_tilde *)(w[3]); int i, n = (t_int)(w[4]); t_float wn0, wn1=x->wn1, wn2=x->wn2; @@ -162,16 +162,16 @@ static t_int *para_bp2_tilde_perform(t_int *w) para_bp2_tilde_dsp_tick(x); for(i=0; iwn1 = wn1; x->wn2 = wn2; @@ -190,8 +190,8 @@ y/x = (a0 + a1*z-1 + a2*z-2)/(1 - b1*z-1 - b2*z-2);*/ static t_int *para_bp2_tilde_perf8(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[2]); + t_sample *in = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[2]); t_para_bp2_tilde *x = (t_para_bp2_tilde *)(w[3]); int i, n = (t_int)(w[4]); t_float wn[10]; @@ -203,22 +203,22 @@ static t_int *para_bp2_tilde_perf8(t_int *w) wn[1] = x->wn1; for(i=0; icur_a) { x->end_a = a; @@ -275,8 +275,8 @@ static void para_bp2_tilde_ft2(t_para_bp2_tilde *x, t_floatarg q) static void para_bp2_tilde_ft1(t_para_bp2_tilde *x, t_floatarg f) { - if(f <= 0.0f) - f = 0.000001f; + if(f <= 0.0) + f = 0.000001; if(f != x->cur_f) { x->end_f = f; @@ -311,18 +311,18 @@ static void para_bp2_tilde_dsp(t_para_bp2_tilde *x, t_signal **sp) t_float si, co, f; int i, n=(int)sp[0]->s_n; - x->sr = 3.14159265358979323846f / (t_float)(sp[0]->s_sr); - x->ticks_per_interpol_time = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n; + x->sr = 3.14159265358979323846 / (t_float)(sp[0]->s_sr); + x->ticks_per_interpol_time = 0.001 * (t_float)(sp[0]->s_sr) / (t_float)n; i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); if(i <= 0) i = 1; x->ticks = i; - x->rcp_ticks = 1.0f / (t_float)i; + x->rcp_ticks = 1.0 / (t_float)i; f = x->cur_f * x->sr; - if(f < 1.0e-20f) - x->cur_l = 1.0e20f; - else if(f > 1.57079632f) - x->cur_l = 0.0f; + if(f < 1.0e-20) + x->cur_l = 1.0e20; + else if(f > 1.57079632) + x->cur_l = 0.0; else { si = sin(f); @@ -339,7 +339,7 @@ static void *para_bp2_tilde_new(t_symbol *s, int argc, t_atom *argv) { t_para_bp2_tilde *x = (t_para_bp2_tilde *)pd_new(para_bp2_tilde_class); int i; - t_float si, co, f=0.0f, q=1.0f, l=0.0f, interpol=0.0f; + t_float si, co, f=0.0, q=1.0, l=0.0, interpol=0.0; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); @@ -347,7 +347,7 @@ static void *para_bp2_tilde_new(t_symbol *s, int argc, t_atom *argv) inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft4")); outlet_new(&x->x_obj, &s_signal); x->x_debug_outlet = outlet_new(&x->x_obj, &s_list); - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; x->x_at[0].a_type = A_FLOAT; x->x_at[1].a_type = A_FLOAT; @@ -359,19 +359,19 @@ static void *para_bp2_tilde_new(t_symbol *s, int argc, t_atom *argv) x->counter_f = 1; x->counter_a = 0; x->counter_g = 0; - x->delta_f = 0.0f; - x->delta_a = 0.0f; - x->delta_g = 0.0f; - x->interpol_time = 500.0f; - x->wn1 = 0.0f; - x->wn2 = 0.0f; - x->a0 = 0.0f; - x->a1 = 0.0f; - x->a2 = 0.0f; - x->b1 = 0.0f; - x->b2 = 0.0f; - x->sr = 3.14159265358979323846f / 44100.0f; - x->cur_a = 1.0f; + x->delta_f = 0.0; + x->delta_a = 0.0; + x->delta_g = 0.0; + x->interpol_time = 500.0; + x->wn1 = 0.0; + x->wn2 = 0.0; + x->a0 = 0.0; + x->a1 = 0.0; + x->a2 = 0.0; + x->b1 = 0.0; + x->b2 = 0.0; + x->sr = 3.14159265358979323846 / 44100.0; + x->cur_a = 1.0; if((argc == 4)&&IS_A_FLOAT(argv,3)&&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,0)) { f = (t_float)atom_getfloatarg(0, argc, argv); @@ -379,33 +379,33 @@ static void *para_bp2_tilde_new(t_symbol *s, int argc, t_atom *argv) l = (t_float)atom_getfloatarg(2, argc, argv); interpol = (t_float)atom_getfloatarg(3, argc, argv); } - if(f <= 0.0f) - f = 0.000001f; + if(f <= 0.0) + f = 0.000001; x->cur_f = f; f *= x->sr; - if(f < 1.0e-20f) - x->cur_l = 1.0e20f; - else if(f > 1.57079632f) - x->cur_l = 0.0f; + if(f < 1.0e-20) + x->cur_l = 1.0e20; + else if(f > 1.57079632) + x->cur_l = 0.0; else { si = sin(f); co = cos(f); x->cur_l = co/si; } - if(q <= 0.0f) - q = 0.000001f; - x->cur_a = 1.0f/q; + if(q <= 0.0) + q = 0.000001; + x->cur_a = 1.0/q; x->cur_g = exp(0.11512925465 * l); - if(interpol <= 0.0f) - interpol = 0.0f; + if(interpol <= 0.0) + interpol = 0.0; x->interpol_time = interpol; - x->ticks_per_interpol_time = 0.5f; + x->ticks_per_interpol_time = 0.5; i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); if(i <= 0) i = 1; x->ticks = i; - x->rcp_ticks = 1.0f / (t_float)i; + x->rcp_ticks = 1.0 / (t_float)i; x->end_f = x->cur_f; x->end_a = x->cur_a; x->end_g = x->cur_g; diff --git a/iemlib1/src/peakenv_hold~.c b/iemlib1/src/peakenv_hold~.c index 3e9b09a..f21a8d2 100644 --- a/iemlib1/src/peakenv_hold~.c +++ b/iemlib1/src/peakenv_hold~.c @@ -35,8 +35,8 @@ static void peakenv_hold_tilde_ft1(t_peakenv_hold_tilde *x, t_float t_hold)/* ho { double dhold; - if(t_hold < 0.0f) - t_hold = 0.0f; + if(t_hold < 0.0) + t_hold = 0.0; x->x_holdtime = (double)t_hold; dhold = x->x_sr*0.001*x->x_holdtime; if(dhold > 2147483647.0) @@ -46,16 +46,16 @@ static void peakenv_hold_tilde_ft1(t_peakenv_hold_tilde *x, t_float t_hold)/* ho static void peakenv_hold_tilde_ft2(t_peakenv_hold_tilde *x, t_float t_rel)/* release-time in ms */ { - if(t_rel < 0.0f) - t_rel = 0.0f; + if(t_rel < 0.0) + t_rel = 0.0; x->x_releasetime = (double)t_rel; x->x_c1 = exp(-1.0/(x->x_sr*0.001*x->x_releasetime)); } static t_int *peakenv_hold_tilde_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[2]); + t_sample *in = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[2]); t_peakenv_hold_tilde *x = (t_peakenv_hold_tilde *)(w[3]); int n = (int)(w[4]); double peak = x->x_old_peak; @@ -66,7 +66,7 @@ static t_int *peakenv_hold_tilde_perform(t_int *w) counter = x->x_counter; for(i=0; i 0) counter--;// hold peride else @@ -76,7 +76,7 @@ static t_int *peakenv_hold_tilde_perform(t_int *w) peak = absolute; counter = x->x_n_hold;// new hold initialisation } - *out++ = (t_float)peak; + *out++ = (t_sample)peak; } /* NAN protect */ //if(IEM_DENORMAL(peak)) @@ -106,7 +106,7 @@ static void *peakenv_hold_tilde_new(t_float t_hold, t_float t_rel) inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); outlet_new(&x->x_obj, &s_signal); - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; return(x); } diff --git a/iemlib1/src/peakenv~.c b/iemlib1/src/peakenv~.c index 9937bcb..9e25e2c 100644 --- a/iemlib1/src/peakenv~.c +++ b/iemlib1/src/peakenv~.c @@ -30,16 +30,16 @@ static void peakenv_tilde_reset(t_peakenv_tilde *x) static void peakenv_tilde_ft1(t_peakenv_tilde *x, t_floatarg f)/* release-time in ms */ { - if(f < 0.0f) - f = 0.0f; + if(f < 0.0) + f = 0.0; x->x_releasetime = (double)f; x->x_c1 = exp(-1.0/(x->x_sr*0.001*x->x_releasetime)); } static t_int *peakenv_tilde_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[2]); + t_sample *in = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[2]); t_peakenv_tilde *x = (t_peakenv_tilde *)(w[3]); int n = (int)(w[4]); double peak = x->x_old_peak; @@ -49,11 +49,11 @@ static t_int *peakenv_tilde_perform(t_int *w) for(i=0; i peak) peak = absolute; - *out++ = (t_float)peak; + *out++ = (t_sample)peak; } /* NAN protect */ //if(IEM_DENORMAL(peak)) @@ -73,14 +73,14 @@ static void *peakenv_tilde_new(t_floatarg f) { t_peakenv_tilde *x = (t_peakenv_tilde *)pd_new(peakenv_tilde_class); - if(f <= 0.0f) - f = 0.0f; + if(f <= 0.0) + f = 0.0; x->x_sr = 44100.0; peakenv_tilde_ft1(x, f); x->x_old_peak = 0.0; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); outlet_new(&x->x_obj, &s_signal); - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; return(x); } diff --git a/iemlib1/src/prvu~.c b/iemlib1/src/prvu~.c index 591c01e..0f2e6a4 100644 --- a/iemlib1/src/prvu~.c +++ b/iemlib1/src/prvu~.c @@ -39,16 +39,16 @@ static void prvu_tilde_tick_hold(t_prvu_tilde *x); static void prvu_tilde_reset(t_prvu_tilde *x) { - x->x_at[0].a_w.w_float = -99.9f; - x->x_at[1].a_w.w_float = -99.9f; - x->x_at[2].a_w.w_float = 0.0f; + x->x_at[0].a_w.w_float = -99.9; + x->x_at[1].a_w.w_float = -99.9; + x->x_at[2].a_w.w_float = 0.0; outlet_list(x->x_obj.ob_outlet, &s_list, 3, x->x_at); x->x_overflow_counter = 0; - x->x_cur_peak = 0.0f; - x->x_old_peak = 0.0f; - x->x_hold_peak = 0.0f; - x->x_sum_rms = 0.0f; - x->x_old_rms = 0.0f; + x->x_cur_peak = 0.0; + x->x_old_peak = 0.0; + x->x_hold_peak = 0.0; + x->x_sum_rms = 0.0; + x->x_old_rms = 0.0; x->x_hold = 0; clock_unset(x->x_clock_hold); clock_delay(x->x_clock_metro, x->x_metro_time); @@ -82,25 +82,25 @@ static void prvu_tilde_float(t_prvu_tilde *x, t_floatarg f) static void prvu_tilde_t_release(t_prvu_tilde *x, t_floatarg release_time) { - if(release_time <= 5.0f) - release_time = 5.0f; + if(release_time <= 5.0) + release_time = 5.0; x->x_release_time = release_time; - x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); + x->x_c1 = exp(-2.0*x->x_metro_time/x->x_release_time); } static void prvu_tilde_t_metro(t_prvu_tilde *x, t_floatarg metro_time) { - if(metro_time <= 5.0f) - metro_time = 5.0f; + if(metro_time <= 5.0) + metro_time = 5.0; x->x_metro_time = metro_time; - x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); - x->x_rcp = 1.0f/(x->x_sr*(t_float)x->x_metro_time); + x->x_c1 = exp(-2.0*x->x_metro_time/x->x_release_time); + x->x_rcp = 1.0/(x->x_sr*(t_float)x->x_metro_time); } static void prvu_tilde_t_hold(t_prvu_tilde *x, t_floatarg hold_time) { - if(hold_time <= 5.0f) - hold_time = 5.0f; + if(hold_time <= 5.0) + hold_time = 5.0; x->x_hold_time = hold_time; } @@ -111,7 +111,7 @@ static void prvu_tilde_threshold(t_prvu_tilde *x, t_floatarg thresh) static t_int *prvu_tilde_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); + t_sample *in = (t_sample *)(w[1]); t_prvu_tilde *x = (t_prvu_tilde *)(w[2]); int n = (int)(w[3]); t_float peak = x->x_cur_peak, power, sum=x->x_sum_rms; @@ -121,7 +121,7 @@ static t_int *prvu_tilde_perform(t_int *w) { for(i=0; i peak) peak = power; sum += power; @@ -135,7 +135,7 @@ static t_int *prvu_tilde_perform(t_int *w) static void prvu_tilde_dsp(t_prvu_tilde *x, t_signal **sp) { x->x_sr = 0.001*(t_float)sp[0]->s_sr; - x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); + x->x_rcp = 1.0/(x->x_sr*x->x_metro_time); dsp_add(prvu_tilde_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); clock_delay(x->x_clock_metro, x->x_metro_time); } @@ -153,7 +153,7 @@ static void prvu_tilde_tick_metro(t_prvu_tilde *x) x->x_old_peak *= c1; /* NAN protect */ if(IEM_DENORMAL(x->x_old_peak)) - x->x_old_peak = 0.0f; + x->x_old_peak = 0.0; if(x->x_cur_peak > x->x_old_peak) x->x_old_peak = x->x_cur_peak; @@ -165,37 +165,37 @@ static void prvu_tilde_tick_metro(t_prvu_tilde *x) } if(!x->x_hold) x->x_hold_peak = x->x_old_peak; - if(x->x_hold_peak <= 0.0000000001f) - dbp = -99.9f; - else if(x->x_hold_peak > 1000000.0f) + if(x->x_hold_peak <= 0.0000000001) + dbp = -99.9; + else if(x->x_hold_peak > 1000000.0) { - dbp = 60.0f; - x->x_hold_peak = 1000000.0f; - x->x_old_peak = 1000000.0f; + dbp = 60.0; + x->x_hold_peak = 1000000.0; + x->x_old_peak = 1000000.0; } else - dbp = 4.3429448195f*log(x->x_hold_peak); - x->x_cur_peak = 0.0f; + dbp = 4.3429448195*log(x->x_hold_peak); + x->x_cur_peak = 0.0; if(dbp >= x->x_threshold_over) x->x_overflow_counter++; x->x_at[1].a_w.w_float = dbp; x->x_at[2].a_w.w_float = (t_float)x->x_overflow_counter; - cur_rms = (1.0f - c1)*x->x_sum_rms*x->x_rcp + c1*x->x_old_rms; + cur_rms = (1.0 - c1)*x->x_sum_rms*x->x_rcp + c1*x->x_old_rms; /* NAN protect */ if(IEM_DENORMAL(cur_rms)) - cur_rms = 0.0f; + cur_rms = 0.0; - if(cur_rms <= 0.0000000001f) - dbr = -99.9f; - else if(cur_rms > 1000000.0f) + if(cur_rms <= 0.0000000001) + dbr = -99.9; + else if(cur_rms > 1000000.0) { - dbr = 60.0f; - x->x_old_rms = 1000000.0f; + dbr = 60.0; + x->x_old_rms = 1000000.0; } else - dbr = 4.3429448195f*log(cur_rms); - x->x_sum_rms = 0.0f; + dbr = 4.3429448195*log(cur_rms); + x->x_sum_rms = 0.0; x->x_old_rms = cur_rms; x->x_at[0].a_w.w_float = dbr; outlet_list(x->x_obj.ob_outlet, &s_list, 3, x->x_at); @@ -216,33 +216,33 @@ static void *prvu_tilde_new(t_floatarg metro_time, t_floatarg hold_time, int i; x = (t_prvu_tilde *)pd_new(prvu_tilde_class); - if(metro_time <= 0.0f) - metro_time = 300.0f; - if(metro_time <= 5.0f) - metro_time = 5.0f; - if(release_time <= 0.0f) - release_time = 300.0f; - if(release_time <= 5.0f) - release_time = 5.0f; - if(hold_time <= 0.0f) - hold_time = 1000.0f; - if(hold_time <= 5.0f) - hold_time = 5.0f; - if(threshold == 0.0f) - threshold = -0.01f; + if(metro_time <= 0.0) + metro_time = 300.0; + if(metro_time <= 5.0) + metro_time = 5.0; + if(release_time <= 0.0) + release_time = 300.0; + if(release_time <= 5.0) + release_time = 5.0; + if(hold_time <= 0.0) + hold_time = 1000.0; + if(hold_time <= 5.0) + hold_time = 5.0; + if(threshold == 0.0) + threshold = -0.01; x->x_metro_time = metro_time; x->x_release_time = release_time; x->x_hold_time = hold_time; x->x_threshold_over = threshold; - x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); - x->x_cur_peak = 0.0f; - x->x_old_peak = 0.0f; - x->x_hold_peak = 0.0f; + x->x_c1 = exp(-2.0*x->x_metro_time/x->x_release_time); + x->x_cur_peak = 0.0; + x->x_old_peak = 0.0; + x->x_hold_peak = 0.0; x->x_hold = 0; - x->x_sum_rms = 0.0f; - x->x_old_rms = 0.0f; - x->x_sr = 44.1f; - x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); + x->x_sum_rms = 0.0; + x->x_old_rms = 0.0; + x->x_sr = 44.1; + x->x_rcp = 1.0/(x->x_sr*x->x_metro_time); x->x_overflow_counter = 0; x->x_clock_metro = clock_new(x, (t_method)prvu_tilde_tick_metro); x->x_clock_hold = clock_new(x, (t_method)prvu_tilde_tick_hold); @@ -251,7 +251,7 @@ static void *prvu_tilde_new(t_floatarg metro_time, t_floatarg hold_time, x->x_at[0].a_type = A_FLOAT; x->x_at[1].a_type = A_FLOAT; x->x_at[2].a_type = A_FLOAT; - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; return(x); } @@ -270,5 +270,4 @@ void prvu_tilde_setup(void) class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_t_metro, gensym("t_metro"), A_FLOAT, 0); class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_t_hold, gensym("t_hold"), A_FLOAT, 0); class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_threshold, gensym("threshold"), A_FLOAT, 0); -// class_sethelpsymbol(prvu_tilde_class, gensym("iemhelp/help-prvu~")); } diff --git a/iemlib1/src/pvu~.c b/iemlib1/src/pvu~.c index 1576b79..e1d4053 100644 --- a/iemlib1/src/pvu~.c +++ b/iemlib1/src/pvu~.c @@ -31,11 +31,11 @@ static void pvu_tilde_tick(t_pvu_tilde *x); static void pvu_tilde_reset(t_pvu_tilde *x) { - outlet_float(x->x_outlet_over, 0.0f); - outlet_float(x->x_outlet_meter, -199.9f); + outlet_float(x->x_outlet_over, 0.0); + outlet_float(x->x_outlet_meter, -199.9); x->x_overflow_counter = 0; - x->x_cur_peak = 0.0f; - x->x_old_peak = 0.0f; + x->x_cur_peak = 0.0; + x->x_old_peak = 0.0; clock_delay(x->x_clock, x->x_metro_time); } @@ -67,16 +67,16 @@ static void pvu_tilde_float(t_pvu_tilde *x, t_floatarg f) static void pvu_tilde_t_release(t_pvu_tilde *x, t_floatarg release_time) { - if(release_time <= 5.0f) - release_time = 5.0f; + if(release_time <= 5.0) + release_time = 5.0; x->x_release_time = release_time; x->x_c1 = exp(-x->x_metro_time/release_time); } static void pvu_tilde_t_metro(t_pvu_tilde *x, t_floatarg metro_time) { - if(metro_time <= 5.0f) - metro_time = 5.0f; + if(metro_time <= 5.0) + metro_time = 5.0; x->x_metro_time = (int)metro_time; x->x_c1 = exp(-metro_time/x->x_release_time); } @@ -88,7 +88,7 @@ static void pvu_tilde_threshold(t_pvu_tilde *x, t_floatarg thresh) static t_int *pvu_tilde_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); + t_sample *in = (t_sample *)(w[1]); t_pvu_tilde *x = (t_pvu_tilde *)(w[2]); int n = (int)(w[3]); t_float peak = x->x_cur_peak; @@ -99,7 +99,7 @@ static t_int *pvu_tilde_perform(t_int *w) { for(i=0; i peak) peak = absolute; } @@ -122,26 +122,26 @@ static void pvu_tilde_tick(t_pvu_tilde *x) x->x_old_peak *= x->x_c1; /* NAN protect */ if(IEM_DENORMAL(x->x_old_peak)) - x->x_old_peak = 0.0f; + x->x_old_peak = 0.0; if(x->x_cur_peak > x->x_old_peak) x->x_old_peak = x->x_cur_peak; - if(x->x_old_peak <= 0.0000000001f) - db = -199.9f; - else if(x->x_old_peak > 1000000.0f) + if(x->x_old_peak <= 0.0000000001) + db = -199.9; + else if(x->x_old_peak > 1000000.0) { - db = 120.0f; - x->x_old_peak = 1000000.0f; + db = 120.0; + x->x_old_peak = 1000000.0; } else - db = 8.6858896381f*log(x->x_old_peak); + db = 8.6858896381*log(x->x_old_peak); if(db >= x->x_threshold_over) { x->x_overflow_counter++; outlet_float(x->x_outlet_over, (t_float)x->x_overflow_counter); } outlet_float(x->x_outlet_meter, db); - x->x_cur_peak = 0.0f; + x->x_cur_peak = 0.0; clock_delay(x->x_clock, x->x_metro_time); } @@ -151,28 +151,28 @@ static void *pvu_tilde_new(t_floatarg metro_time, t_floatarg release_time, t_flo t_float t; x = (t_pvu_tilde *)pd_new(pvu_tilde_class); - if(metro_time <= 0.0f) - metro_time = 300.0f; - if(metro_time <= 5.0f) - metro_time = 5.0f; - if(release_time <= 0.0f) - release_time = 300.0f; - if(release_time <= 5.0f) - release_time = 5.0f; - if(threshold == 0.0f) - threshold = -0.01f; + if(metro_time <= 0.0) + metro_time = 300.0; + if(metro_time <= 5.0) + metro_time = 5.0; + if(release_time <= 0.0) + release_time = 300.0; + if(release_time <= 5.0) + release_time = 5.0; + if(threshold == 0.0) + threshold = -0.01; x->x_threshold_over = threshold; x->x_overflow_counter = 0; x->x_metro_time = metro_time; x->x_release_time = release_time; x->x_c1 = exp(-metro_time/release_time); - x->x_cur_peak = 0.0f; - x->x_old_peak = 0.0f; + x->x_cur_peak = 0.0; + x->x_old_peak = 0.0; x->x_clock = clock_new(x, (t_method)pvu_tilde_tick); x->x_outlet_meter = outlet_new(&x->x_obj, &s_float);/* left */ x->x_outlet_over = outlet_new(&x->x_obj, &s_float); /* right */ x->x_started = 1; - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; return(x); } @@ -194,5 +194,4 @@ void pvu_tilde_setup(void ) class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_t_release, gensym("t_release"), A_FLOAT, 0); class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_t_metro, gensym("t_metro"), A_FLOAT, 0); class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_threshold, gensym("threshold"), A_FLOAT, 0); -// class_sethelpsymbol(pvu_tilde_class, gensym("iemhelp/help-pvu~")); } diff --git a/iemlib1/src/rvu~.c b/iemlib1/src/rvu~.c index 059a064..e93e420 100644 --- a/iemlib1/src/rvu~.c +++ b/iemlib1/src/rvu~.c @@ -30,9 +30,9 @@ static void rvu_tilde_tick_metro(t_rvu_tilde *x); static void rvu_tilde_reset(t_rvu_tilde *x) { - outlet_float(x->x_obj.ob_outlet, -99.9f); - x->x_sum_rms = 0.0f; - x->x_old_rms = 0.0f; + outlet_float(x->x_obj.ob_outlet, -99.9); + x->x_sum_rms = 0.0; + x->x_old_rms = 0.0; clock_delay(x->x_clock_metro, x->x_metro_time); } @@ -50,7 +50,7 @@ static void rvu_tilde_start(t_rvu_tilde *x) static void rvu_tilde_float(t_rvu_tilde *x, t_floatarg f) { - if(f == 0.0f) + if(f == 0.0) { clock_unset(x->x_clock_metro); x->x_started = 0; @@ -64,24 +64,24 @@ static void rvu_tilde_float(t_rvu_tilde *x, t_floatarg f) static void rvu_tilde_t_release(t_rvu_tilde *x, t_floatarg release_time) { - if(release_time <= 5.0f) - release_time = 5.0f; + if(release_time <= 5.0) + release_time = 5.0; x->x_release_time = release_time; - x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); + x->x_c1 = exp(-2.0*x->x_metro_time/x->x_release_time); } static void rvu_tilde_t_metro(t_rvu_tilde *x, t_floatarg metro_time) { - if(metro_time <= 5.0f) - metro_time = 5.0f; + if(metro_time <= 5.0) + metro_time = 5.0; x->x_metro_time = metro_time; - x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); - x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); + x->x_c1 = exp(-2.0*x->x_metro_time/x->x_release_time); + x->x_rcp = 1.0/(x->x_sr*x->x_metro_time); } static t_int *rvu_tilde_perform(t_int *w) { - t_float *in = (t_float *)(w[1]); + t_sample *in = (t_sample *)(w[1]); t_rvu_tilde *x = (t_rvu_tilde *)(w[2]); int n = (int)(w[3]); t_float sum=x->x_sum_rms; @@ -91,7 +91,7 @@ static t_int *rvu_tilde_perform(t_int *w) { for(i=0; ix_sum_rms = sum; } @@ -101,7 +101,7 @@ static t_int *rvu_tilde_perform(t_int *w) static void rvu_tilde_dsp(t_rvu_tilde *x, t_signal **sp) { x->x_sr = 0.001*(t_float)sp[0]->s_sr; - x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); + x->x_rcp = 1.0/(x->x_sr*x->x_metro_time); dsp_add(rvu_tilde_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); clock_delay(x->x_clock_metro, x->x_metro_time); } @@ -110,21 +110,21 @@ static void rvu_tilde_tick_metro(t_rvu_tilde *x) { t_float dbr, cur_rms, c1=x->x_c1; - cur_rms = (1.0f - c1)*x->x_sum_rms*x->x_rcp + c1*x->x_old_rms; + cur_rms = (1.0 - c1)*x->x_sum_rms*x->x_rcp + c1*x->x_old_rms; /* NAN protect */ if(IEM_DENORMAL(cur_rms)) - cur_rms = 0.0f; + cur_rms = 0.0; - if(cur_rms <= 0.0000000001f) - dbr = -99.9f; - else if(cur_rms > 1000000.0f) + if(cur_rms <= 0.0000000001) + dbr = -99.9; + else if(cur_rms > 1000000.0) { - dbr = 60.0f; - x->x_old_rms = 1000000.0f; + dbr = 60.0; + x->x_old_rms = 1000000.0; } else - dbr = 4.3429448195f*log(cur_rms); - x->x_sum_rms = 0.0f; + dbr = 4.3429448195*log(cur_rms); + x->x_sum_rms = 0.0; x->x_old_rms = cur_rms; outlet_float(x->x_obj.ob_outlet, dbr); clock_delay(x->x_clock_metro, x->x_metro_time); @@ -139,25 +139,25 @@ static void *rvu_tilde_new(t_floatarg metro_time, t_floatarg release_time) { t_rvu_tilde *x=(t_rvu_tilde *)pd_new(rvu_tilde_class); - if(metro_time <= 0.0f) - metro_time = 300.0f; - if(metro_time <= 5.0f) - metro_time = 5.0f; - if(release_time <= 0.0f) - release_time = 300.0f; - if(release_time <= 5.0f) - release_time = 5.0f; + if(metro_time <= 0.0) + metro_time = 300.0; + if(metro_time <= 5.0) + metro_time = 5.0; + if(release_time <= 0.0) + release_time = 300.0; + if(release_time <= 5.0) + release_time = 5.0; x->x_metro_time = metro_time; x->x_release_time = release_time; - x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); - x->x_sum_rms = 0.0f; - x->x_old_rms = 0.0f; - x->x_sr = 44.1f; - x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); + x->x_c1 = exp(-2.0*x->x_metro_time/x->x_release_time); + x->x_sum_rms = 0.0; + x->x_old_rms = 0.0; + x->x_sr = 44.1; + x->x_rcp = 1.0/(x->x_sr*x->x_metro_time); x->x_clock_metro = clock_new(x, (t_method)rvu_tilde_tick_metro); x->x_started = 1; outlet_new(&x->x_obj, &s_float); - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; return(x); } @@ -174,5 +174,4 @@ void rvu_tilde_setup(void) class_addmethod(rvu_tilde_class, (t_method)rvu_tilde_stop, gensym("stop"), 0); class_addmethod(rvu_tilde_class, (t_method)rvu_tilde_t_release, gensym("t_release"), A_FLOAT, 0); class_addmethod(rvu_tilde_class, (t_method)rvu_tilde_t_metro, gensym("t_metro"), A_FLOAT, 0); -// class_sethelpsymbol(rvu_tilde_class, gensym("iemhelp/help-rvu~")); } diff --git a/iemlib1/src/sin_phase~.c b/iemlib1/src/sin_phase~.c index 0707758..e99f3a7 100644 --- a/iemlib1/src/sin_phase~.c +++ b/iemlib1/src/sin_phase~.c @@ -13,11 +13,11 @@ iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 typedef struct _sin_phase_tilde { t_object x_obj; - t_float x_prev1; - t_float x_prev2; - t_float x_cur_out; - int x_counter1; - int x_counter2; + t_sample x_prev1; + t_sample x_prev2; + t_sample x_cur_out; + t_sample x_counter1; + t_sample x_counter2; int x_state1; int x_state2; t_float x_float_sig_in; @@ -27,49 +27,49 @@ static t_class *sin_phase_tilde_class; static t_int *sin_phase_tilde_perform(t_int *w) { - t_float *in1 = (t_float *)(w[1]); - t_float *in2 = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); + t_sample *in1 = (t_sample *)(w[1]); + t_sample *in2 = (t_sample *)(w[2]); + t_sample *out = (t_sample *)(w[3]); t_sin_phase_tilde *x = (t_sin_phase_tilde *)(w[4]); int i, n = (t_int)(w[5]); - t_float prev1=x->x_prev1; - t_float prev2=x->x_prev2; - t_float cur_out=x->x_cur_out; - int counter1=x->x_counter1; - int counter2=x->x_counter2; + t_sample prev1=x->x_prev1; + t_sample prev2=x->x_prev2; + t_sample cur_out=x->x_cur_out; + t_sample counter1=x->x_counter1; + t_sample counter2=x->x_counter2; int state1=x->x_state1; int state2=x->x_state2; for(i=0; i= 0.0f) && (prev1 < 0.0f)) + if((in1[i] >= 0.0) && (prev1 < 0.0)) {/* pos. zero cross of sig_in_1 */ state1 = 1; - counter1 = 0; + counter1 = prev1 / (prev1 - in1[i]); /* x = y1 / (y1 - y2) */ } - else if((in1[i] < 0.0f) && (prev1 >= 0.0f)) + else if((in1[i] < 0.0) && (prev1 >= 0.0)) {/* neg. zero cross of sig_in_1 */ state2 = 1; - counter2 = 0; + counter2 = prev1 / (prev1 - in1[i]); /* x = y1 / (y1 - y2) */ } - if((in2[i] >= 0.0f) && (prev2 < 0.0f)) + if((in2[i] >= 0.0) && (prev2 < 0.0)) {/* pos. zero cross of sig_in_2 */ state1 = 0; - cur_out = (t_float)(counter1); - counter1 = 0; + cur_out = counter1 + prev2 / (prev2 - in2[i]) - 1.0; + counter1 = 0.0; } - else if((in2[i] < 0.0f) && (prev2 >= 0.0f)) + else if((in2[i] < 0.0) && (prev2 >= 0.0)) {/* neg. zero cross of sig_in_2 */ state2 = 0; - cur_out = (t_float)(counter2); - counter2 = 0; + cur_out = counter2 + prev2 / (prev2 - in2[i]) - 1.0; + counter2 = 0.0; } if(state1) - counter1++; + counter1 += 1.0; if(state2) - counter2++; + counter2 += 1.0; prev1 = in1[i]; prev2 = in2[i]; @@ -99,14 +99,14 @@ static void *sin_phase_tilde_new(void) inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); outlet_new(&x->x_obj, &s_signal); - x->x_prev1 = 0.0f; - x->x_prev2 = 0.0f; - x->x_cur_out = 0.0f; - x->x_counter1 = 0; - x->x_counter2 = 0; + x->x_prev1 = 0.0; + x->x_prev2 = 0.0; + x->x_cur_out = 0.0; + x->x_counter1 = 0.0; + x->x_counter2 = 0.0; x->x_state1 = 0; x->x_state2 = 0; - x->x_float_sig_in = 0.0f; + x->x_float_sig_in = 0.0; return (x); } @@ -117,5 +117,16 @@ void sin_phase_tilde_setup(void) 0, sizeof(t_sin_phase_tilde), 0, 0); CLASS_MAINSIGNALIN(sin_phase_tilde_class, t_sin_phase_tilde, x_float_sig_in); class_addmethod(sin_phase_tilde_class, (t_method)sin_phase_tilde_dsp, gensym("dsp"), 0); -// class_sethelpsymbol(sin_phase_tilde_class, gensym("iemhelp/help-sin_phase~")); } + +/* +geradengleichung: + +y - y1 = ((y2 - y1) / (x2 - x1)) * (x - x1) +y = ((y2 - y1) / (x2 - x1)) * (x - x1) + y1 = 0 +x1 = 0 +x2 = 1 +0 = ((y2 - y1) / 1) * (x) + y1 +-y1 = (y2 - y1) * x +x = y1 / (y1 - y2) +*/ diff --git a/iemlib1/src/soundfile_info.c b/iemlib1/src/soundfile_info.c index 654f71a..f018370 100644 --- a/iemlib1/src/soundfile_info.c +++ b/iemlib1/src/soundfile_info.c @@ -61,6 +61,186 @@ static unsigned long soundfile_info_string_to_uint32(char *cvec) return(ul); } +static void soundfile_info_uint32_to_string(char *cvec, unsigned long ul) +{ + unsigned char *uc=(unsigned char *)cvec; + + *uc = (unsigned char)(0x000000ff & ul); + *(uc+1) = (unsigned char)(0x000000ff & (ul/256)); + *(uc+2) = (unsigned char)(0x000000ff & (ul/65536)); + *(uc+3) = (unsigned char)(0x000000ff & (ul/16777216)); + return; +} + +static void soundfile_info_overwrite_sr(t_soundfile_info *x, t_symbol *filename, t_floatarg new_sr) +{ + char completefilename[400]; + int i, n, n2, n4, filesize, read_chars, header_size=0, ch, bytesperframe, sr, n_frames; + FILE *fh; + t_atom *at; + char *cvec; + unsigned long ul_chunk_size, ul_sr; + short ss_format, ss_ch, ss_bytesperframe; + + if(filename->s_name[0] == '/')/*make complete path + filename*/ + { + strcpy(completefilename, filename->s_name); + } + else if(((filename->s_name[0] >= 'A')&&(filename->s_name[0] <= 'Z')|| + (filename->s_name[0] >= 'a')&&(filename->s_name[0] <= 'z'))&& + (filename->s_name[1] == ':')&&(filename->s_name[2] == '/')) + { + strcpy(completefilename, filename->s_name); + } + else + { + strcpy(completefilename, canvas_getdir(x->x_canvas)->s_name); + strcat(completefilename, "/"); + strcat(completefilename, filename->s_name); + } + + fh = fopen(completefilename,"r+b"); + if(!fh) + { + post("soundfile_info_read: cannot open %s !!\n", completefilename); + } + else + { + n = x->x_mem_size; // 10000 bytes + n2 = sizeof(short) * x->x_mem_size; + n4 = sizeof(long) * x->x_mem_size; + fseek(fh, 0, SEEK_END); + filesize = ftell(fh); + fseek(fh,0,SEEK_SET); + read_chars = (int)fread(x->x_begmem, sizeof(char), n4, fh) / 2; + // post("read chars = %d", read_chars); + cvec = (char *)x->x_begmem; + if(read_chars > 4) + { + if(strncmp(cvec, "RIFF", 4)) + { + post("soundfile_info_read-error: %s is no RIFF-WAVE-file", completefilename); + goto sr_soundfile_info_end; + } + header_size += 8; // jump over RIFF chunk size + cvec += 8; + if(strncmp(cvec, "WAVE", 4)) + { + post("soundfile_info_read-error: %s is no RIFF-WAVE-file", completefilename); + goto sr_soundfile_info_end; + } + header_size += 4; + cvec += 4; + + for(i=header_size/2; i 32000)) + { + post("soundfile_info_read-error: %s has no common channel-number", completefilename); + goto sr_soundfile_info_end; + } + SETFLOAT(x->x_at_header+SFI_HEADER_CHANNELS, (t_float)ss_ch); + ch = (int)ss_ch; + header_size += 2; + cvec += 2; + + ul_sr = soundfile_info_string_to_uint32(cvec); /* samplerate */ + if((ul_sr > 2000000000) || (ul_sr < 1)) + { + post("soundfile_info_read-error: %s has no common samplerate", completefilename); + goto sr_soundfile_info_end; + } + ul_sr = (unsigned long)new_sr; + soundfile_info_uint32_to_string(cvec, ul_sr); + + fseek(fh,0,SEEK_SET); + read_chars = (int)fwrite (x->x_begmem, sizeof(char), n4, fh); + fclose(fh); + post("written"); + + sr = (int)ul_sr; + header_size += 4; + cvec += 4; + + header_size += 4; /* jump over bytes_per_sec */ + cvec += 4; + + ss_bytesperframe = soundfile_info_string_to_int16(cvec); /* bytes_per_frame */ + if((ss_bytesperframe < 1) || (ss_bytesperframe > 32000)) + { + post("soundfile_info_read-error: %s has no common number of bytes per frame", completefilename); + goto sr_soundfile_info_end; + } + + bytesperframe = (int)ss_bytesperframe; + header_size += 2; + cvec += 2; + + header_size += 2; /* jump over bits_per_sample */ + cvec += 2; + + for(i=header_size/2; ix_rw_index; @@ -39,15 +39,15 @@ static t_int *sparse_FIR_tilde_perform(t_int *w) int order = x->x_n_order; int n_coef = x->x_n_coef_resp_order; int n_coef8; - t_float sum=0.0f; - t_float *coef = x->x_coef_beg; + t_sample sum=0.0; + t_sample *coef = x->x_coef_beg; int *index = x->x_index_beg; - t_float *write_hist1=x->x_history_beg; - t_float *write_hist2; - t_float *read_hist; - t_float *coef_vec; + t_sample *write_hist1=x->x_history_beg; + t_sample *write_hist2; + t_sample *read_hist; + t_sample *coef_vec; int *index_vec; - t_float *hist_vec; + t_sample *hist_vec; if((order < 1) || (n_coef < 1)) goto sparse_FIR_tilde_perf_zero; @@ -61,7 +61,7 @@ static t_int *sparse_FIR_tilde_perform(t_int *w) { write_hist1[rw_index] = in[i]; write_hist2[rw_index] = in[i]; - sum = 0.0f; + sum = 0.0; coef_vec = coef; index_vec = index; hist_vec = &read_hist[rw_index]; @@ -103,7 +103,7 @@ static t_int *sparse_FIR_tilde_perform(t_int *w) sparse_FIR_tilde_perf_zero: while(n--) - *out++ = 0.0f; + *out++ = 0.0; return(w+5); } diff --git a/iemlib1/src/vcf_filter~.c b/iemlib1/src/vcf_filter~.c index 7caa68d..3771ecc 100644 --- a/iemlib1/src/vcf_filter~.c +++ b/iemlib1/src/vcf_filter~.c @@ -13,8 +13,8 @@ iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 typedef struct _vcf_filter_tilde { t_object x_obj; - t_float x_wn1; - t_float x_wn2; + t_sample x_wn1; + t_sample x_wn2; t_float x_float_sig_in1; char x_filtname[6]; } t_vcf_filter_tilde; @@ -23,8 +23,8 @@ static t_class *vcf_filter_tilde_class; static t_int *vcf_filter_tilde_perform_snafu(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[4]); + t_sample *in = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[4]); int n = (t_int)(w[6]); while(n--) @@ -61,52 +61,52 @@ wn1 = wn0; static t_int *vcf_filter_tilde_perform_lp2(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *lp = (t_float *)(w[2]); - t_float *q = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); + t_sample *in = (t_sample *)(w[1]); + t_sample *lp = (t_sample *)(w[2]); + t_sample *q = (t_sample *)(w[3]); + t_sample *out = (t_sample *)(w[4]); t_vcf_filter_tilde *x = (t_vcf_filter_tilde *)(w[5]); int i, n = (t_int)(w[6]); - t_float wn0, wn1=x->x_wn1, wn2=x->x_wn2; - t_float l, al, l2, rcp; + t_sample wn0, wn1=x->x_wn1, wn2=x->x_wn2; + t_sample l, al, l2, rcp; for(i=0; i 1000000.0f) - al = 0.000001f*l; + if(q[i] < 0.000001) + al = 1000000.0*l; + else if(q[i] > 1000000.0) + al = 0.000001*l; else al = l/q[i]; - l2 = l*l + 1.0f; - rcp = 1.0f/(al + l2); + l2 = l*l + 1.0; + rcp = 1.0/(al + l2); - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); - *out++ = rcp*(wn0 + 2.0f*wn1 + wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*(wn0 + 2.0*wn1 + wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); - *out++ = rcp*(wn0 + 2.0f*wn1 + wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*(wn0 + 2.0*wn1 + wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); - *out++ = rcp*(wn0 + 2.0f*wn1 + wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*(wn0 + 2.0*wn1 + wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); - *out++ = rcp*(wn0 + 2.0f*wn1 + wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*(wn0 + 2.0*wn1 + wn2); wn2 = wn1; wn1 = wn0; } /* NAN protect */ if(IEM_DENORMAL(wn2)) - wn2 = 0.0f; + wn2 = 0.0; if(IEM_DENORMAL(wn1)) - wn1 = 0.0f; + wn1 = 0.0; x->x_wn1 = wn1; x->x_wn2 = wn2; @@ -115,53 +115,53 @@ static t_int *vcf_filter_tilde_perform_lp2(t_int *w) static t_int *vcf_filter_tilde_perform_bp2(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *lp = (t_float *)(w[2]); - t_float *q = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); + t_sample *in = (t_sample *)(w[1]); + t_sample *lp = (t_sample *)(w[2]); + t_sample *q = (t_sample *)(w[3]); + t_sample *out = (t_sample *)(w[4]); t_vcf_filter_tilde *x = (t_vcf_filter_tilde *)(w[5]); int i, n = (t_int)(w[6]); - t_float wn0, wn1=x->x_wn1, wn2=x->x_wn2; - t_float l, al, l2, rcp; + t_sample wn0, wn1=x->x_wn1, wn2=x->x_wn2; + t_sample l, al, l2, rcp; for(i=0; i 1000000.0f) - al = 0.000001f*l; + if(q[i] < 0.000001) + al = 1000000.0*l; + else if(q[i] > 1000000.0) + al = 0.000001*l; else al = l/q[i]; - l2 = l*l + 1.0f; - rcp = 1.0f/(al + l2); + l2 = l*l + 1.0; + rcp = 1.0/(al + l2); - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); *out++ = rcp*al*(wn0 - wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); *out++ = rcp*al*(wn0 - wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); *out++ = rcp*al*(wn0 - wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); *out++ = rcp*al*(wn0 - wn2); wn2 = wn1; wn1 = wn0; } /* NAN protect */ if(IEM_DENORMAL(wn2)) - wn2 = 0.0f; + wn2 = 0.0; if(IEM_DENORMAL(wn1)) - wn1 = 0.0f; + wn1 = 0.0; x->x_wn1 = wn1; x->x_wn2 = wn2; @@ -170,53 +170,53 @@ static t_int *vcf_filter_tilde_perform_bp2(t_int *w) static t_int *vcf_filter_tilde_perform_rbp2(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *lp = (t_float *)(w[2]); - t_float *q = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); + t_sample *in = (t_sample *)(w[1]); + t_sample *lp = (t_sample *)(w[2]); + t_sample *q = (t_sample *)(w[3]); + t_sample *out = (t_sample *)(w[4]); t_vcf_filter_tilde *x = (t_vcf_filter_tilde *)(w[5]); int i, n = (t_int)(w[6]); - t_float wn0, wn1=x->x_wn1, wn2=x->x_wn2; - t_float al, l, l2, rcp; + t_sample wn0, wn1=x->x_wn1, wn2=x->x_wn2; + t_sample al, l, l2, rcp; for(i=0; i 1000000.0f) - al = 0.000001f*l; + if(q[i] < 0.000001) + al = 1000000.0*l; + else if(q[i] > 1000000.0) + al = 0.000001*l; else al = l/q[i]; - l2 = l*l + 1.0f; - rcp = 1.0f/(al + l2); + l2 = l*l + 1.0; + rcp = 1.0/(al + l2); - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); *out++ = rcp*l*(wn0 - wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); *out++ = rcp*l*(wn0 - wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); *out++ = rcp*l*(wn0 - wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); *out++ = rcp*l*(wn0 - wn2); wn2 = wn1; wn1 = wn0; } /* NAN protect */ if(IEM_DENORMAL(wn2)) - wn2 = 0.0f; + wn2 = 0.0; if(IEM_DENORMAL(wn1)) - wn1 = 0.0f; + wn1 = 0.0; x->x_wn1 = wn1; x->x_wn2 = wn2; @@ -225,53 +225,53 @@ static t_int *vcf_filter_tilde_perform_rbp2(t_int *w) static t_int *vcf_filter_tilde_perform_hp2(t_int *w) { - t_float *in = (t_float *)(w[1]); - t_float *lp = (t_float *)(w[2]); - t_float *q = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); + t_sample *in = (t_sample *)(w[1]); + t_sample *lp = (t_sample *)(w[2]); + t_sample *q = (t_sample *)(w[3]); + t_sample *out = (t_sample *)(w[4]); t_vcf_filter_tilde *x = (t_vcf_filter_tilde *)(w[5]); int i, n = (t_int)(w[6]); - t_float wn0, wn1=x->x_wn1, wn2=x->x_wn2; - t_float l, al, l2, rcp, forw; + t_sample wn0, wn1=x->x_wn1, wn2=x->x_wn2; + t_sample l, al, l2, rcp, forw; for(i=0; i 1000000.0f) - al = 0.000001f*l; + if(q[i] < 0.000001) + al = 1000000.0*l; + else if(q[i] > 1000000.0) + al = 0.000001*l; else al = l/q[i]; - l2 = l*l + 1.0f; - rcp = 1.0f/(al + l2); - forw = rcp * (l2 - 1.0f); + l2 = l*l + 1.0; + rcp = 1.0/(al + l2); + forw = rcp * (l2 - 1.0); - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); - *out++ = forw*(wn0 - 2.0f*wn1 + wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); + *out++ = forw*(wn0 - 2.0*wn1 + wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); - *out++ = forw*(wn0 - 2.0f*wn1 + wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); + *out++ = forw*(wn0 - 2.0*wn1 + wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); - *out++ = forw*(wn0 - 2.0f*wn1 + wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); + *out++ = forw*(wn0 - 2.0*wn1 + wn2); wn2 = wn1; wn1 = wn0; - wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); - *out++ = forw*(wn0 - 2.0f*wn1 + wn2); + wn0 = *in++ - rcp*(2.0*(2.0 - l2)*wn1 + (l2 - al)*wn2); + *out++ = forw*(wn0 - 2.0*wn1 + wn2); wn2 = wn1; wn1 = wn0; } /* NAN protect */ if(IEM_DENORMAL(wn2)) - wn2 = 0.0f; + wn2 = 0.0; if(IEM_DENORMAL(wn1)) - wn1 = 0.0f; + wn1 = 0.0; x->x_wn1 = wn1; x->x_wn2 = wn2; @@ -318,8 +318,8 @@ static void *vcf_filter_tilde_new(t_symbol *filt_typ) inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); outlet_new(&x->x_obj, &s_signal); x->x_float_sig_in1 = 0; - x->x_wn1 = 0.0f; - x->x_wn2 = 0.0f; + x->x_wn1 = 0.0; + x->x_wn2 = 0.0; c = (char *)filt_typ->s_name; c[5] = 0; strcpy(x->x_filtname, c); -- cgit v1.2.1