From 7d41c2213b5070d444fa17cdb04eeb9fdc955309 Mon Sep 17 00:00:00 2001 From: Katja Date: Sun, 6 Nov 2011 15:38:24 +0000 Subject: made smlib compliant with double precision svn path=/trunk/externals/smlib/; revision=15707 --- bp.c | 52 ++++++++++++++++++++++++++-------------------------- defines.h | 7 ++++--- deltas.c | 23 ++++++++++++----------- hip.c | 18 +++++++++--------- hist.c | 20 ++++++++++---------- itov.c | 10 +++++----- lavg.c | 12 ++++++------ lhist.c | 30 +++++++++++++++--------------- lhisti.c | 30 +++++++++++++++--------------- linspace.c | 8 ++++---- lmax.c | 10 +++++----- lmin.c | 8 ++++---- lrange.c | 10 +++++----- lstd.c | 16 ++++++++-------- prevl.c | 21 +++++++++++---------- threshold.c | 10 +++++----- vabs.c | 2 +- vclip.c | 8 ++++---- vcog.c | 8 ++++---- vdbtorms.c | 6 +++--- vdelta.c | 16 ++++++++-------- vfmod.c | 6 +++--- vftom.c | 4 ++-- vlavg.c | 18 +++++++++--------- vlmax.c | 22 +++++++++++----------- vlmin.c | 22 +++++++++++----------- vlrange.c | 26 +++++++++++++------------- vmax.c | 6 +++--- vmin.c | 6 +++--- vmtof.c | 4 ++-- vnmax.c | 6 +++--- vpow.c | 8 ++++---- vrms.c | 6 +++--- vrmstodb.c | 6 +++--- vstd.c | 8 ++++---- vsum.c | 2 +- vthreshold.c | 14 +++++++------- vvconv.c | 2 +- 38 files changed, 247 insertions(+), 244 deletions(-) diff --git a/bp.c b/bp.c index d21bc19..c18b5f7 100644 --- a/bp.c +++ b/bp.c @@ -4,21 +4,21 @@ typedef struct bpctl { - float c_x1; - float c_x2; - float c_coef1; - float c_coef2; - float c_gain; + t_float c_x1; + t_float c_x2; + t_float c_coef1; + t_float c_coef2; + t_float c_gain; } t_bpctl; typedef struct bp { t_object x_obj; - float x_freq; - float x_q; + t_float x_freq; + t_float x_q; t_bpctl x_cspace; t_bpctl *x_ctl; - float x_f; + t_float x_f; } t_bp; t_class *bp_class; @@ -39,29 +39,29 @@ static void *bp_new(t_floatarg f, t_floatarg q) return (x); } -static float bp_qcos(float f) +static t_float bp_qcos(t_float f) { - if (f >= -(0.5f*3.14159f) && f <= 0.5f*3.14159f) + if (f >= -(0.5*3.141592653589793) && f <= 0.5*3.141592653589793) { - float g = f*f; - return (((g*g*g * (-1.0f/720.0f) + g*g*(1.0f/24.0f)) - g*0.5f) + 1); + t_float g = f*f; + return (((g*g*g * (-1.0/720.0) + g*g*(1.0/24.0)) - g*0.5) + 1); } else return (0); } static void bp_docoef(t_bp *x, t_floatarg f, t_floatarg q) { - float r, oneminusr, omega; - if (f < 0.0001f) f = 0.0001f; + t_float r, oneminusr, omega; + if (f < 0.0001) f = 0.0001; if (q < 0) q = 0; x->x_freq = f; x->x_q = q; - omega = f * (2.0f * 3.14159f); - if (q < 0.001) oneminusr = 1.0f; + omega = f * (2.0 * 3.141592653589793); + if (q < 0.001) oneminusr = 1.0; else oneminusr = omega/q; - if (oneminusr > 1.0f) oneminusr = 1.0f; - r = 1.0f - oneminusr; - x->x_ctl->c_coef1 = 2.0f * bp_qcos(omega) * r; + if (oneminusr > 1.0) oneminusr = 1.0; + r = 1.0 - oneminusr; + x->x_ctl->c_coef1 = 2.0 * bp_qcos(omega) * r; x->x_ctl->c_coef2 = - r * r; x->x_ctl->c_gain = 2 * oneminusr * (oneminusr + r * omega); /* post("r %f, omega %f, coef1 %f, coef2 %f", @@ -85,15 +85,15 @@ static void bp_clear(t_bp *x, t_floatarg q) static void bp_perform(t_bp *x, t_float in) { - float out; + t_float out; t_bpctl *c = x->x_ctl; - float last = c->c_x1; - float prev = c->c_x2; - float coef1 = c->c_coef1; - float coef2 = c->c_coef2; - float gain = c->c_gain; + t_float last = c->c_x1; + t_float prev = c->c_x2; + t_float coef1 = c->c_coef1; + t_float coef2 = c->c_coef2; + t_float gain = c->c_gain; - float output = in + coef1 * last + coef2 * prev; + t_float output = in + coef1 * last + coef2 * prev; out = gain * output; prev = last; diff --git a/defines.h b/defines.h index 093a477..b92efa6 100644 --- a/defines.h +++ b/defines.h @@ -1,10 +1,11 @@ #include #include -#define MAXFLOAT 1e18f; +#ifndef MAXFLOAT +#define MAXFLOAT 1e18; +#endif #define LOGTEN 2.302585092994 -/* NT and OSX don't appear to have single-precision ANSI math */ -#if defined(_WIN32) || defined(__APPLE__) +#if PD_FLOAT_PRECISION == 64 #define sinf sin #define cosf cos #define atanf atan diff --git a/deltas.c b/deltas.c index 178d59e..d79faa8 100644 --- a/deltas.c +++ b/deltas.c @@ -7,11 +7,11 @@ static t_class *deltas_class; typedef struct _deltas { t_object x_obj; - float m_lo; - float m_hi; + t_float m_lo; + t_float m_hi; int m_buffer_size; int m_buffer_index; - float *m_buffer; // circular buffer + t_float *m_buffer; // circular buffer } t_deltas; static void deltas_set(t_deltas *x, t_float lo, t_float hi, t_float size); @@ -29,8 +29,8 @@ static void deltas_bang(t_deltas *x) { int lo,hi,n,index,size; t_atom *ap,*app; - float last; - float *buffer, *bp; + t_float last; + t_float *buffer, *bp; deltas_set(x, x->m_lo, x->m_hi, x->m_buffer_size); lo=(int)x->m_lo; @@ -104,11 +104,11 @@ static void deltas_bang(t_deltas *x) static void deltas_clear(t_deltas *x) { int i,s; - float *f; + t_float *f; f=x->m_buffer; s=x->m_buffer_size; for (i=0;im_hi=(float)((int)hi); - x->m_lo=(float)((int)lo); + x->m_hi=(t_float)((int)hi); + x->m_lo=(t_float)((int)lo); + if (x->m_buffer_size != size) { freebytes(x->m_buffer, x->m_buffer_size); x->m_buffer_size = (int)size; - x->m_buffer = (float*)getbytes(sizeof(float)*x->m_buffer_size); + x->m_buffer = (t_float*)getbytes(sizeof(t_float)*x->m_buffer_size); deltas_clear(x); x->m_buffer_index=0; } diff --git a/hip.c b/hip.c index b1425c1..fc9a5ee 100644 --- a/hip.c +++ b/hip.c @@ -4,18 +4,18 @@ typedef struct hipctl { - float c_x; - float c_coef; + t_float c_x; + t_float c_coef; } t_hipctl; typedef struct hip { t_object x_obj; - float x_sr; - float x_hz; + t_float x_sr; + t_float x_hz; t_hipctl x_cspace; t_hipctl *x_ctl; - float x_f; + t_float x_f; } t_hip; t_class *hip_class; @@ -45,11 +45,11 @@ static void hip_ft1(t_hip *x, t_floatarg f) static void hip_perform(t_hip *x, t_float in) { t_hipctl *c = x->x_ctl; - float last = c->c_x; - float coef = c->c_coef; - float out; + t_float last = c->c_x; + t_float coef = c->c_coef; + t_float out; - float new = in + coef * last; + t_float new = in + coef * last; out = new - last; last = new; diff --git a/hist.c b/hist.c index 32bf5b7..fdfaf8f 100644 --- a/hist.c +++ b/hist.c @@ -8,12 +8,12 @@ static t_class *hist_class; typedef struct _hist { t_object x_obj; - float m_lo; - float m_hi; - float m_scale; + t_float m_lo; + t_float m_hi; + t_float m_scale; int m_nbins; int m_n_observations; - float *m_hist; + t_float *m_hist; } t_hist; @@ -41,7 +41,7 @@ static void hist_perform_list(t_hist *x, t_symbol *s, int argc, t_atom *argv) static void hist_bang(t_hist *x) { int i,n; - float *f; + t_float *f; t_atom *ap,*app; n=x->m_nbins; @@ -63,8 +63,8 @@ static void hist_bang(t_hist *x) static void hist_relative(t_hist *x) { int i,n; - float *f; - float invn; + t_float *f; + t_float invn; t_atom *ap,*app; n=x->m_nbins; ap = (t_atom *)getbytes(sizeof(t_atom)*n); @@ -87,7 +87,7 @@ static void hist_relative(t_hist *x) static void hist_clear(t_hist *x) { int i; - float *f; + t_float *f; f=x->m_hist; for (i=0;im_nbins;i++) *f++=0.0f; @@ -114,8 +114,8 @@ static void hist_set(t_hist *x, t_float lo, t_float hi, t_float nbins) x->m_hi=hi; x->m_lo=lo; x->m_nbins=(int)nbins; - x->m_scale=(float)x->m_nbins/(hi-lo); - x->m_hist = (float*)getbytes(sizeof(float)*x->m_nbins); + x->m_scale=(t_float)x->m_nbins/(hi-lo); + x->m_hist = (t_float*)getbytes(sizeof(t_float)*x->m_nbins); hist_clear(x); } diff --git a/itov.c b/itov.c index 97f5280..c2c027b 100644 --- a/itov.c +++ b/itov.c @@ -11,16 +11,16 @@ typedef struct _itov t_outlet *f_out1; t_outlet *f_out2; t_outlet *f_out3; - float m_lo; - float m_hi; - float m_scale; + t_float m_lo; + t_float m_hi; + t_float m_scale; int m_nbins; } t_itov; static void itov_perform_float(t_itov *x, t_float j) { - float i; + t_float i; j-=1.0f; j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF @@ -54,7 +54,7 @@ static void itov_set(t_itov *x, t_float lo, t_float hi, t_float nbins) x->m_hi=hi; x->m_lo=lo; x->m_nbins=(int)nbins; - x->m_scale=(float)x->m_nbins/(hi-lo); + x->m_scale=(t_float)x->m_nbins/(hi-lo); } static void *itov_new(t_float lo, t_float hi, t_float nbins) diff --git a/lavg.c b/lavg.c index fce0015..081ce9e 100644 --- a/lavg.c +++ b/lavg.c @@ -7,9 +7,9 @@ static t_class *lavg_class; typedef struct _lavg { t_object x_obj; - float m_avg; - float m_c_leak; - float m_leak; + t_float m_avg; + t_float m_c_leak; + t_float m_leak; } t_lavg; @@ -21,13 +21,13 @@ static void lavg_perform(t_lavg *x, t_float in) static void lavg_clear(t_lavg *x) { - x->m_avg=0.0f; + x->m_avg=0.0; } static void lavg_setHalfDecay(t_lavg *x, t_float halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; + x->m_c_leak=(t_float)powf(.5,(1.0/halfDecayTime)); + x->m_leak=1.0-x->m_c_leak; } static void *lavg_new( t_float halfDecayTime) diff --git a/lhist.c b/lhist.c index 5f27b9b..1210e0e 100644 --- a/lhist.c +++ b/lhist.c @@ -7,19 +7,19 @@ static t_class *lhist_class; typedef struct _lhist { t_object x_obj; - float m_lo; - float m_hi; - float m_scale; - float m_c_leak; - float m_leak; + t_float m_lo; + t_float m_hi; + t_float m_scale; + t_float m_c_leak; + t_float m_leak; int m_nbins; // int m_n_observations; - float *m_lhist; + t_float *m_lhist; } t_lhist; static void lhist_setHalfDecay(t_lhist *x, t_float halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_c_leak=(t_float)powf(.5,(1.0f/halfDecayTime)); x->m_leak=1.0f-x->m_c_leak; } @@ -47,8 +47,8 @@ static void lhist_perform_list(t_lhist *x, t_symbol *s, int argc, t_atom *argv) static void lhist_leak(t_lhist *x) { int i; - float *f; - float sc; + t_float *f; + t_float sc; f=x->m_lhist; sc=x->m_c_leak; i=x->m_nbins; @@ -59,7 +59,7 @@ static void lhist_leak(t_lhist *x) static void lhist_bang(t_lhist *x) { int i,n; - float *f; + t_float *f; t_atom *ap,*app; n=x->m_nbins; ap = (t_atom *)getbytes(sizeof(t_atom)*n); @@ -79,8 +79,8 @@ static void lhist_bang(t_lhist *x) static void lhist_relative(t_lhist *x) { int i,n; - float *f; - float invn,sum; + t_float *f; + t_float invn,sum; t_atom *ap,*app; n=x->m_nbins; @@ -107,7 +107,7 @@ static void lhist_relative(t_lhist *x) static void lhist_clear(t_lhist *x) { int i; - float *f; + t_float *f; f=x->m_lhist; for (i=0;im_nbins;i++) *f++=0.0f; @@ -131,8 +131,8 @@ static void lhist_set(t_lhist *x, t_float lo, t_float hi, t_float nbins) x->m_hi=hi; x->m_lo=lo; x->m_nbins=(int)nbins; - x->m_scale=(float)x->m_nbins/(hi-lo); - x->m_lhist = (float*)getbytes(sizeof(float)*x->m_nbins); + x->m_scale=(t_float)x->m_nbins/(hi-lo); + x->m_lhist = (t_float*)getbytes(sizeof(t_float)*x->m_nbins); lhist_clear(x); } diff --git a/lhisti.c b/lhisti.c index f6433c0..3baf04e 100644 --- a/lhisti.c +++ b/lhisti.c @@ -8,19 +8,19 @@ static t_class *lhisti_class; typedef struct _lhisti { t_object x_obj; - float m_lo; - float m_hi; - float m_scale; - float m_c_leak; - float m_leak; + t_float m_lo; + t_float m_hi; + t_float m_scale; + t_float m_c_leak; + t_float m_leak; int m_nbins; // int m_n_observations; - float *m_lhisti; + t_float *m_lhisti; } t_lhisti; static void lhisti_setHalfDecay(t_lhisti *x, t_float halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_c_leak=(t_float)powf(.5,(1.0f/halfDecayTime)); x->m_leak=1.0f-x->m_c_leak; } @@ -47,8 +47,8 @@ static void lhisti_perform_list(t_lhisti *x, t_symbol *s, int argc, t_atom *argv static void lhisti_leak(t_lhisti *x) { int i; - float *f; - float sc; + t_float *f; + t_float sc; f=x->m_lhisti; sc=x->m_c_leak; i=x->m_nbins; @@ -59,7 +59,7 @@ static void lhisti_leak(t_lhisti *x) static void lhisti_bang(t_lhisti *x) { int i,n; - float *f; + t_float *f; t_atom *ap,*app; n=x->m_nbins; ap = (t_atom *)getbytes(sizeof(t_atom)*n); @@ -79,8 +79,8 @@ static void lhisti_bang(t_lhisti *x) static void lhisti_relative(t_lhisti *x) { int i,n; - float *f; - float invn,sum; + t_float *f; + t_float invn,sum; t_atom *ap,*app; n=x->m_nbins; @@ -107,7 +107,7 @@ static void lhisti_relative(t_lhisti *x) static void lhisti_clear(t_lhisti *x) { int i; - float *f; + t_float *f; f=x->m_lhisti; for (i=0;im_nbins;i++) *f++=0.0f; @@ -131,8 +131,8 @@ static void lhisti_set(t_lhisti *x, t_float lo, t_float hi, t_float nbins) x->m_hi=hi; x->m_lo=lo; x->m_nbins=(int)nbins; - x->m_scale=(float)x->m_nbins/(hi-lo); - x->m_lhisti = (float*)getbytes(sizeof(float)*x->m_nbins); + x->m_scale=(t_float)x->m_nbins/(hi-lo); + x->m_lhisti = (t_float*)getbytes(sizeof(t_float)*x->m_nbins); lhisti_clear(x); } diff --git a/linspace.c b/linspace.c index c3af9c2..f593ffd 100644 --- a/linspace.c +++ b/linspace.c @@ -9,9 +9,9 @@ static t_class *linspace_class; typedef struct _linspace { t_object x_obj; - float m_lo; - float m_hi; - float m_n; + t_float m_lo; + t_float m_hi; + t_float m_n; } t_linspace; @@ -22,7 +22,7 @@ static void linspace_bang(t_linspace *x) if ((n<256)&&(n>1)) { int i; - float lo,step; + t_float lo,step; t_atom *ap,*app; ap = (t_atom *)getbytes(sizeof(t_atom)*n); diff --git a/lmax.c b/lmax.c index 911304f..723b1ac 100644 --- a/lmax.c +++ b/lmax.c @@ -7,9 +7,9 @@ static t_class *lmax_class; typedef struct _lmax { t_object x_obj; - float m_max; - float m_leak; - float m_c_leak; + t_float m_max; + t_float m_leak; + t_float m_c_leak; } t_lmax; @@ -21,8 +21,8 @@ static void lmax_perform(t_lmax *x, t_float in) static void lmax_setHalfDecay(t_lmax *x, t_float halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; + x->m_c_leak=(t_float)powf(.5,(1.0/halfDecayTime)); + x->m_leak=1.0-x->m_c_leak; } static void lmax_clear(t_lmax *x) diff --git a/lmin.c b/lmin.c index 51b333a..54ea855 100644 --- a/lmin.c +++ b/lmin.c @@ -7,9 +7,9 @@ static t_class *lmin_class; typedef struct _lmin { t_object x_obj; - float m_min; - float m_leak; - float m_c_leak; + t_float m_min; + t_float m_leak; + t_float m_c_leak; } t_lmin; @@ -21,7 +21,7 @@ static void lmin_perform(t_lmin *x, t_float in) static void lmin_setHalfDecay(t_lmin *x, t_float halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_c_leak=(t_float)powf(.5,(1.0f/halfDecayTime)); x->m_leak=1.0f-x->m_c_leak; } diff --git a/lrange.c b/lrange.c index 8f5b296..be13207 100644 --- a/lrange.c +++ b/lrange.c @@ -7,10 +7,10 @@ static t_class *lrange_class; typedef struct _lrange { t_object x_obj; - float m_min; - float m_max; - float m_c_leak; - float m_leak; + t_float m_min; + t_float m_max; + t_float m_c_leak; + t_float m_leak; } t_lrange; @@ -23,7 +23,7 @@ static void lrange_perform(t_lrange *x, t_float in) static void lrange_setHalfDecay(t_lrange *x, t_float halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_c_leak=(t_float)powf(.5,(1.0f/halfDecayTime)); x->m_leak=1.0f-x->m_c_leak; } diff --git a/lstd.c b/lstd.c index 1873bda..538e6b4 100644 --- a/lstd.c +++ b/lstd.c @@ -7,26 +7,26 @@ static t_class *lstd_class; typedef struct _lstd { t_object x_obj; - float m_avg; - float m_sum_squares; - float m_std; - float m_c_leak; - float m_leak; + t_float m_avg; + t_float m_sum_squares; + t_float m_std; + t_float m_c_leak; + t_float m_leak; } t_lstd; static void lstd_perform(t_lstd *x, t_float in) { - float tmp=x->m_avg-in; + t_float tmp=x->m_avg-in; x->m_avg= x->m_avg * x->m_c_leak + in * x->m_leak; x->m_sum_squares=x->m_sum_squares * x->m_c_leak + x->m_leak*tmp*tmp; - x->m_std=(float)sqrtf(x->m_sum_squares); + x->m_std=(t_float)sqrtf(x->m_sum_squares); outlet_float(x->x_obj.ob_outlet, x->m_std); } static void lstd_setHalfDecay(t_lstd *x, t_float halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_c_leak=(t_float)powf(.5,(1.0f/halfDecayTime)); x->m_leak=1.0f-x->m_c_leak; } diff --git a/prevl.c b/prevl.c index d43a2df..e061a93 100644 --- a/prevl.c +++ b/prevl.c @@ -7,11 +7,11 @@ static t_class *prevl_class; typedef struct _prevl { t_object x_obj; - float m_lo; - float m_hi; + t_float m_lo; + t_float m_hi; int m_buffer_size; int m_buffer_index; - float *m_buffer; // circular buffer + t_float *m_buffer; // circular buffer } t_prevl; static void prevl_set(t_prevl *x, t_float lo, t_float hi, t_float size); @@ -29,7 +29,7 @@ static void prevl_bang(t_prevl *x) { int lo,hi,n,index,size; t_atom *ap,*app; - float *buffer, *bp; + t_float *buffer, *bp; prevl_set(x, x->m_lo, x->m_hi, x->m_buffer_size); lo=(int)x->m_lo; @@ -84,11 +84,11 @@ static void prevl_bang(t_prevl *x) static void prevl_clear(t_prevl *x) { int i,s; - float *f; + t_float *f; f=x->m_buffer; s=x->m_buffer_size; for (i=0;im_hi=(float)((int)hi); - x->m_lo=(float)((int)lo); + x->m_hi=(t_float)((int)hi); + x->m_lo=(t_float)((int)lo); + if (x->m_buffer_size != size) { x->m_buffer_size=(int)size; freebytes(x->m_buffer, x->m_buffer_size); - x->m_buffer = (float*)getbytes(sizeof(float)*x->m_buffer_size); + x->m_buffer = (t_float*)getbytes(sizeof(t_float)*x->m_buffer_size); prevl_clear(x); x->m_buffer_index=0; } diff --git a/threshold.c b/threshold.c index 2d99e03..e031234 100644 --- a/threshold.c +++ b/threshold.c @@ -11,11 +11,11 @@ typedef struct _threshold t_outlet *x_outlet2; /* bang out for low thresh */ t_clock *x_clock; /* wakeup for message output */ int x_state; /* 1 = high, 0 = low */ - float x_hithresh; /* value of high threshold */ - float x_lothresh; /* value of low threshold */ - float x_deadwait; /* msec remaining in dead period */ - float x_hideadtime; /* hi dead */ - float x_lodeadtime; /* lo dead */ + t_float x_hithresh; /* value of high threshold */ + t_float x_lothresh; /* value of low threshold */ + t_float x_deadwait; /* msec remaining in dead period */ + t_float x_hideadtime; /* hi dead */ + t_float x_lodeadtime; /* lo dead */ } t_threshold; static void threshold_tick(t_threshold *x); diff --git a/vabs.c b/vabs.c index c928c5e..8c2a3b1 100644 --- a/vabs.c +++ b/vabs.c @@ -21,7 +21,7 @@ static void vabs_perform(t_vabs *x, t_symbol *s, int argc, t_atom *argv) for (i = 0; i < argc; i++) { - float f=atom_getfloat(argv++); + t_float f=atom_getfloat(argv++); SETFLOAT(app, f>0?f:-f); app++; } diff --git a/vclip.c b/vclip.c index 4a11ef5..dfda2fd 100644 --- a/vclip.c +++ b/vclip.c @@ -9,15 +9,15 @@ static t_class *vclip_class; typedef struct _vclip { t_object x_obj; - float m_lo; - float m_hi; + t_float m_lo; + t_float m_hi; } t_vclip; static void vclip_perform(t_vclip *x, t_symbol *s, int argc, t_atom *argv) { int i; - float lo,hi; + t_float lo,hi; t_atom *ap,*app; ap = (t_atom *)getbytes(sizeof(t_atom)*argc); app=ap; @@ -25,7 +25,7 @@ static void vclip_perform(t_vclip *x, t_symbol *s, int argc, t_atom *argv) hi=x->m_hi; for (i = 0; i < argc; i++) { - float f=atom_getfloat(argv++); + t_float f=atom_getfloat(argv++); SETFLOAT(app, (fhi?hi:f))); app++; } diff --git a/vcog.c b/vcog.c index 1dd68a4..211e817 100644 --- a/vcog.c +++ b/vcog.c @@ -12,16 +12,16 @@ typedef struct _vcog static void vcog_perform(t_vcog *x, t_symbol *s, int argc, t_atom *argv) { - float sum=0.f; - float wsum=0.0f; + t_float sum=0.; + t_float wsum=0.0; int i; for (i = 0; i < argc; i++) { - float tmp=atom_getfloat(&argv[i]); + t_float tmp=atom_getfloat(&argv[i]); sum+= tmp; wsum+= tmp*i; } - if (sum!=0.0f) outlet_float(x->x_obj.ob_outlet, 1.0f+(wsum/sum)); + if (sum!=0.0f) outlet_float(x->x_obj.ob_outlet, 1.0+(wsum/sum)); } static void *vcog_new( t_float halfDecayTime) diff --git a/vdbtorms.c b/vdbtorms.c index ab954f6..962452e 100644 --- a/vdbtorms.c +++ b/vdbtorms.c @@ -9,7 +9,7 @@ typedef struct _vdbtorms t_object x_obj; } t_vdbtorms; -float dbtorms(float f) +static t_float decibelbtorms(t_float f) { if (f <= 0) return(0); @@ -18,7 +18,7 @@ float dbtorms(float f) if (f > 485) f = 485; } - return (float)(exp((LOGTEN * 0.05) * (f-100.))); + return (t_float)(exp((LOGTEN * 0.05) * (f-100.))); } static void vdbtorms_perform(t_vdbtorms *x, t_symbol *s, int argc, t_atom *argv) @@ -30,7 +30,7 @@ static void vdbtorms_perform(t_vdbtorms *x, t_symbol *s, int argc, t_atom *argv) for (i = 0; i < argc; i++) { - SETFLOAT(app, dbtorms(atom_getfloat(argv++))); + SETFLOAT(app, decibelbtorms(atom_getfloat(argv++))); app++; } outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); diff --git a/vdelta.c b/vdelta.c index cc809db..e61e01f 100644 --- a/vdelta.c +++ b/vdelta.c @@ -8,9 +8,9 @@ static t_class *vdelta_class; typedef struct _vdelta { t_object x_obj; - float m_c_leak; - float m_leak; - float *m_prev; + t_float m_c_leak; + t_float m_leak; + t_float *m_prev; int m_n; } t_vdelta; @@ -19,9 +19,9 @@ static void vdelta_perform(t_vdelta *x, t_symbol *s, int argc, t_atom *argv) { int i; t_atom *ap,*app; - float *fp; - float m_leak; - float m_c_leak; + t_float *fp; + t_float m_leak; + t_float m_c_leak; m_leak=x->m_leak; m_c_leak=x->m_c_leak; @@ -30,7 +30,7 @@ static void vdelta_perform(t_vdelta *x, t_symbol *s, int argc, t_atom *argv) int i; if (x->m_prev) freebytes(x->m_prev,x->m_n); - x->m_prev=(float*)getbytes(argc*sizeof(float)); + x->m_prev=(t_float*)getbytes(argc*sizeof(t_float)); for(i=0;im_prev[i]=0.0f; x->m_n=argc; @@ -41,7 +41,7 @@ static void vdelta_perform(t_vdelta *x, t_symbol *s, int argc, t_atom *argv) app=ap; for (i = 0; i < argc; i++) { - float f=atom_getfloat(argv++); + t_float f=atom_getfloat(argv++); SETFLOAT(app, f-*fp); app++; *fp++=f; diff --git a/vfmod.c b/vfmod.c index 7b7d1af..9f23fc5 100644 --- a/vfmod.c +++ b/vfmod.c @@ -9,14 +9,14 @@ static t_class *vfmod_class; typedef struct _vfmod { t_object x_obj; - float m_y; + t_float m_y; } t_vfmod; static void vfmod_perform(t_vfmod *x, t_symbol *s, int argc, t_atom *argv) { int i; - float y; + t_float y; t_atom *ap,*app; ap = (t_atom *)getbytes(sizeof(t_atom)*argc); app=ap; @@ -25,7 +25,7 @@ static void vfmod_perform(t_vfmod *x, t_symbol *s, int argc, t_atom *argv) y=1.0f; for (i = 0; i < argc; i++) { - SETFLOAT(app, (float)fmod(atom_getfloat(argv++),y)); + SETFLOAT(app, (t_float)fmod(atom_getfloat(argv++),y)); app++; } outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); diff --git a/vftom.c b/vftom.c index 6355006..99acc0b 100644 --- a/vftom.c +++ b/vftom.c @@ -9,9 +9,9 @@ typedef struct _vftom t_object x_obj; } t_vftom; -float ftom(float f) +t_float ftom(t_float f) { - return (float)(f > 0 ? 17.3123405046 * log(.12231220585 * f) : -1500); + return (t_float)(f > 0 ? 17.3123405046 * log(.12231220585 * f) : -1500); } static void vftom_perform(t_vftom *x, t_symbol *s, int argc, t_atom *argv) diff --git a/vlavg.c b/vlavg.c index 1e6ba98..ff590e9 100644 --- a/vlavg.c +++ b/vlavg.c @@ -9,9 +9,9 @@ static t_class *vlavg_class; typedef struct _vlavg { t_object x_obj; - float m_c_leak; - float m_leak; - float *m_avg; + t_float m_c_leak; + t_float m_leak; + t_float *m_avg; int m_n; } t_vlavg; @@ -20,9 +20,9 @@ static void vlavg_perform(t_vlavg *x, t_symbol *s, int argc, t_atom *argv) { int i; t_atom *ap,*app; - float *fp; - float m_leak; - float m_c_leak; + t_float *fp; + t_float m_leak; + t_float m_c_leak; m_leak=x->m_leak; m_c_leak=x->m_c_leak; @@ -31,7 +31,7 @@ static void vlavg_perform(t_vlavg *x, t_symbol *s, int argc, t_atom *argv) int i; if (x->m_avg) freebytes(x->m_avg,x->m_n); - x->m_avg=(float*)getbytes(argc*sizeof(float)); + x->m_avg=(t_float*)getbytes(argc*sizeof(t_float)); for(i=0;im_avg[i]=0.0f; x->m_n=argc; @@ -42,7 +42,7 @@ static void vlavg_perform(t_vlavg *x, t_symbol *s, int argc, t_atom *argv) app=ap; for (i = 0; i < argc; i++) { - float f=atom_getfloat(argv++); + t_float f=atom_getfloat(argv++); *fp = *fp * m_c_leak + f * m_leak; SETFLOAT(app, *fp); app++; @@ -54,7 +54,7 @@ static void vlavg_perform(t_vlavg *x, t_symbol *s, int argc, t_atom *argv) static void vlavg_setHalfDecay(t_vlavg *x, t_floatarg halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_c_leak=(t_float)powf(.5,(1.0f/halfDecayTime)); x->m_leak=1.0f-x->m_c_leak; } diff --git a/vlmax.c b/vlmax.c index a566f49..83b3c37 100644 --- a/vlmax.c +++ b/vlmax.c @@ -9,9 +9,9 @@ static t_class *vlmax_class; typedef struct _vlmax { t_object x_obj; - float m_c_leak; - float m_leak; - float *m_max; + t_float m_c_leak; + t_float m_leak; + t_float *m_max; int m_n; } t_vlmax; @@ -20,9 +20,9 @@ static void vlmax_perform(t_vlmax *x, t_symbol *s, int argc, t_atom *argv) { int i; t_atom *ap,*app; - float *fp; - float m_leak; - float m_c_leak; + t_float *fp; + t_float m_leak; + t_float m_c_leak; m_leak=x->m_leak; m_c_leak=x->m_c_leak; @@ -31,9 +31,9 @@ static void vlmax_perform(t_vlmax *x, t_symbol *s, int argc, t_atom *argv) int i; if (x->m_max) freebytes(x->m_max,x->m_n); - x->m_max=(float*)getbytes(argc*sizeof(float)); + x->m_max=(t_float*)getbytes(argc*sizeof(t_float)); for(i=0;im_max[i]=0.0f; + x->m_max[i]=0.0; x->m_n=argc; } @@ -42,7 +42,7 @@ static void vlmax_perform(t_vlmax *x, t_symbol *s, int argc, t_atom *argv) app=ap; for (i = 0; i < argc; i++) { - float f=atom_getfloat(argv++); + t_float f=atom_getfloat(argv++); *fp =(f > *fp ) ? f : *fp *m_c_leak + f*m_leak; SETFLOAT(app, *fp); app++; @@ -54,8 +54,8 @@ static void vlmax_perform(t_vlmax *x, t_symbol *s, int argc, t_atom *argv) static void vlmax_setHalfDecay(t_vlmax *x, t_floatarg halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; + x->m_c_leak=(t_float)powf(.5,(1.0/halfDecayTime)); + x->m_leak=1.0-x->m_c_leak; } static void *vlmax_new(t_float halfDecayTime) diff --git a/vlmin.c b/vlmin.c index b839826..9d708d2 100644 --- a/vlmin.c +++ b/vlmin.c @@ -9,9 +9,9 @@ static t_class *vlmin_class; typedef struct _vlmin { t_object x_obj; - float m_c_leak; - float m_leak; - float *m_min; + t_float m_c_leak; + t_float m_leak; + t_float *m_min; int m_n; } t_vlmin; @@ -20,9 +20,9 @@ static void vlmin_perform(t_vlmin *x, t_symbol *s, int argc, t_atom *argv) { int i; t_atom *ap,*app; - float *fp; - float m_leak; - float m_c_leak; + t_float *fp; + t_float m_leak; + t_float m_c_leak; m_leak=x->m_leak; m_c_leak=x->m_c_leak; @@ -31,9 +31,9 @@ static void vlmin_perform(t_vlmin *x, t_symbol *s, int argc, t_atom *argv) int i; if (x->m_min) freebytes(x->m_min,x->m_n); - x->m_min=(float*)getbytes(argc*sizeof(float)); + x->m_min=(t_float*)getbytes(argc*sizeof(t_float)); for(i=0;im_min[i]=0.0f; + x->m_min[i]=0.0; x->m_n=argc; } @@ -42,7 +42,7 @@ static void vlmin_perform(t_vlmin *x, t_symbol *s, int argc, t_atom *argv) app=ap; for (i = 0; i < argc; i++) { - float f=atom_getfloat(argv++); + t_float f=atom_getfloat(argv++); *fp =(f < *fp ) ? f : *fp *m_c_leak + f*m_leak; SETFLOAT(app, *fp); app++; @@ -54,8 +54,8 @@ static void vlmin_perform(t_vlmin *x, t_symbol *s, int argc, t_atom *argv) static void vlmin_setHalfDecay(t_vlmin *x, t_floatarg halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; + x->m_c_leak=(t_float)powf(.5,(1.0/halfDecayTime)); + x->m_leak=1.0-x->m_c_leak; } static void *vlmin_new(t_float halfDecayTime) diff --git a/vlrange.c b/vlrange.c index 07b383f..81f32ff 100644 --- a/vlrange.c +++ b/vlrange.c @@ -9,10 +9,10 @@ static t_class *vlrange_class; typedef struct _vlrange { t_object x_obj; - float m_c_leak; - float m_leak; - float *m_min; - float *m_max; + t_float m_c_leak; + t_float m_leak; + t_float *m_min; + t_float *m_max; int m_n; } t_vlrange; @@ -21,9 +21,9 @@ static void vlrange_perform(t_vlrange *x, t_symbol *s, int argc, t_atom *argv) { int i; t_atom *ap,*app; - float *fmin, *fmax; - float m_leak; - float m_c_leak; + t_float *fmin, *fmax; + t_float m_leak; + t_float m_c_leak; m_leak=x->m_leak; m_c_leak=x->m_c_leak; @@ -35,12 +35,12 @@ static void vlrange_perform(t_vlrange *x, t_symbol *s, int argc, t_atom *argv) freebytes(x->m_min,x->m_n); freebytes(x->m_max,x->m_n); } - x->m_min=(float*)getbytes(argc*sizeof(float)); - x->m_max=(float*)getbytes(argc*sizeof(float)); + x->m_min=(t_float*)getbytes(argc*sizeof(t_float)); + x->m_max=(t_float*)getbytes(argc*sizeof(t_float)); for(i=0;im_min[i]=0.0f; - x->m_max[i]=0.0f; + x->m_min[i]=0.0; + x->m_max[i]=0.0; } x->m_n=argc; } @@ -51,7 +51,7 @@ static void vlrange_perform(t_vlrange *x, t_symbol *s, int argc, t_atom *argv) app=ap; for (i = 0; i < argc; i++) { - float f=atom_getfloat(argv++); + t_float f=atom_getfloat(argv++); *fmax =(f > *fmax ) ? f : *fmax *m_c_leak + f*m_leak; *fmin =(f < *fmin ) ? f : *fmin *m_c_leak + f*m_leak; SETFLOAT(app, *fmax-*fmin); @@ -65,7 +65,7 @@ static void vlrange_perform(t_vlrange *x, t_symbol *s, int argc, t_atom *argv) static void vlrange_setHalfDecay(t_vlrange *x, t_floatarg halfDecayTime) { - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_c_leak=(t_float)powf(.5,(1.0/halfDecayTime)); x->m_leak=1.0f-x->m_c_leak; } diff --git a/vmax.c b/vmax.c index ac56423..2326a14 100644 --- a/vmax.c +++ b/vmax.c @@ -18,10 +18,10 @@ static void vmax_perform(t_vmax *x, t_symbol *s, int argc, t_atom *argv) { int i; int maxi; - float max=-MAXFLOAT; + t_float max=-MAXFLOAT; for (i = 0; i < argc; i++) { - float f=atom_getfloat(&argv[i]); + t_float f=atom_getfloat(&argv[i]); if (f>max) { max=f; @@ -29,7 +29,7 @@ static void vmax_perform(t_vmax *x, t_symbol *s, int argc, t_atom *argv) } } outlet_float(x->x_obj.ob_outlet, max); - outlet_float(x->m_out_maxi, (float)(maxi+1)); + outlet_float(x->m_out_maxi, (t_float)(maxi+1)); } static void *vmax_new( t_float halfDecayTime) diff --git a/vmin.c b/vmin.c index a0b578e..559659e 100644 --- a/vmin.c +++ b/vmin.c @@ -18,10 +18,10 @@ static void vmin_perform(t_vmin *x, t_symbol *s, int argc, t_atom *argv) { int i; int mini; - float min=MAXFLOAT; + t_float min=MAXFLOAT; for (i = 0; i < argc; i++) { - float f=atom_getfloat(&argv[i]); + t_float f=atom_getfloat(&argv[i]); if (fx_obj.ob_outlet, min); - outlet_float(x->m_out_maxi, (float)(mini+1)); + outlet_float(x->m_out_maxi, (t_float)(mini+1)); } static void *vmin_new( t_float halfDecayTime) diff --git a/vmtof.c b/vmtof.c index 828dcb6..5cfe7a6 100644 --- a/vmtof.c +++ b/vmtof.c @@ -9,11 +9,11 @@ typedef struct _vmtof t_object x_obj; } t_vmtof; -float mtof(float f) +t_float mtof(t_float f) { if (f <= -1500) return(0); else if (f > 1499) return(mtof(1499)); - else return (float)(8.17579891564 * exp(.0577622650 * f)); + else return (t_float)(8.17579891564 * exp(.0577622650 * f)); } static void vmtof_perform(t_vmtof *x, t_symbol *s, int argc, t_atom *argv) diff --git a/vnmax.c b/vnmax.c index 7003f6d..ad8c97f 100644 --- a/vnmax.c +++ b/vnmax.c @@ -21,10 +21,10 @@ static void vnmax_perform(t_vnmax *x, t_symbol *s, int argc, t_atom *argv) { int i; int maxi; - float max=-MAXFLOAT; + t_float max=-MAXFLOAT; for (i = 0; i < argc; i++) { - float f=atom_getfloat(&argv[i]); + t_float f=atom_getfloat(&argv[i]); if (f>max) { max=f; @@ -32,7 +32,7 @@ static void vnmax_perform(t_vnmax *x, t_symbol *s, int argc, t_atom *argv) } } outlet_float(x->x_obj.ob_outlet, max); - outlet_float(x->m_out_maxi, (float)(maxi+1)); + outlet_float(x->m_out_maxi, (t_float)(maxi+1)); } static void *vnmax_new( t_float halfDecayTime) diff --git a/vpow.c b/vpow.c index 6859859..d8a9bcf 100644 --- a/vpow.c +++ b/vpow.c @@ -7,14 +7,14 @@ static t_class *vpow_class; typedef struct _vpow { t_object x_obj; - float m_y; + t_float m_y; } t_vpow; static void vpow_perform(t_vpow *x, t_symbol *s, int argc, t_atom *argv) { int i; - float y; + t_float y; t_atom *ap,*app; ap = (t_atom *)getbytes(sizeof(t_atom)*argc); app=ap; @@ -23,9 +23,9 @@ static void vpow_perform(t_vpow *x, t_symbol *s, int argc, t_atom *argv) y=1.0f; for (i = 0; i < argc; i++) { - float x=atom_getfloat(argv++); + t_float x=atom_getfloat(argv++); if (x>0) - x=(float)powf(x,y); + x=(t_float)powf(x,y); else x=-1000.; SETFLOAT(app, x); diff --git a/vrms.c b/vrms.c index 52b8d6d..ff7f33e 100644 --- a/vrms.c +++ b/vrms.c @@ -12,14 +12,14 @@ typedef struct _vrms static void vrms_perform(t_vrms *x, t_symbol *s, int argc, t_atom *argv) { - float sum=0.f; + t_float sum=0.; int i; for (i = 0; i < argc; i++) { - float tmp=atom_getfloat(&argv[i]); + t_float tmp=atom_getfloat(&argv[i]); sum+= tmp*tmp; } - outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sum/argc)); + outlet_float(x->x_obj.ob_outlet, (t_float)sqrtf(sum/argc)); } static void *vrms_new( t_float halfDecayTime) diff --git a/vrmstodb.c b/vrmstodb.c index d375bf9..25e3cf9 100644 --- a/vrmstodb.c +++ b/vrmstodb.c @@ -9,12 +9,12 @@ typedef struct _vrmstodb t_object x_obj; } t_vrmstodb; -float rmstodb(float f) +static t_float rmstodecibel(t_float f) { if (f <= 0) return (0); else { - float val = (float)(100 + 20./LOGTEN * log(f)); + t_float val = (t_float)(100 + 20./LOGTEN * log(f)); return (val < 0 ? 0 : val); } } @@ -28,7 +28,7 @@ static void vrmstodb_perform(t_vrmstodb *x, t_symbol *s, int argc, t_atom *argv) for (i = 0; i < argc; i++) { - SETFLOAT(app, rmstodb(atom_getfloat(argv++))); + SETFLOAT(app, rmstodecibel(atom_getfloat(argv++))); app++; } outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); diff --git a/vstd.c b/vstd.c index 538cb94..c88807c 100644 --- a/vstd.c +++ b/vstd.c @@ -12,18 +12,18 @@ typedef struct _vstd static void vstd_perform(t_vstd *x, t_symbol *s, int argc, t_atom *argv) { - float sumsq=0.0f; - float sum=0.0f; + t_float sumsq=0.0f; + t_float sum=0.0f; int i; for (i = 0; i < argc; i++) { - float tmp=atom_getfloat(&argv[i]); + t_float tmp=atom_getfloat(&argv[i]); sumsq+= tmp*tmp; sum+=tmp; } sumsq/=argc; sum/=argc; - outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sumsq-sum*sum)); + outlet_float(x->x_obj.ob_outlet, (t_float)sqrtf(sumsq-sum*sum)); } static void *vstd_new( t_float halfDecayTime) diff --git a/vsum.c b/vsum.c index dd49f4c..d32db9a 100644 --- a/vsum.c +++ b/vsum.c @@ -12,7 +12,7 @@ typedef struct _vsum static void vsum_perform(t_vsum *x, t_symbol *s, int argc, t_atom *argv) { - float sum=0.f; + t_float sum=0.; int i; for (i = 0; i < argc; i++) { diff --git a/vthreshold.c b/vthreshold.c index 106cf72..5e0bef4 100644 --- a/vthreshold.c +++ b/vthreshold.c @@ -12,10 +12,10 @@ typedef struct _vthreshold t_outlet *x_outlet2; /* bang out for low thresh */ int *x_state; /* 1 = high, 0 = low */ int x_n; - float x_hithresh; /* value of high vthreshold */ - float x_lothresh; /* value of low vthreshold */ - float x_hideadtime; /* hi dead */ - float x_lodeadtime; /* lo dead */ + t_float x_hithresh; /* value of high vthreshold */ + t_float x_lothresh; /* value of low vthreshold */ + t_float x_hideadtime; /* hi dead */ + t_float x_lodeadtime; /* lo dead */ } t_vthreshold; /* "set" message to specify vthresholds and dead times */ @@ -62,14 +62,14 @@ static void vthreshold_perform(t_vthreshold *x, t_symbol *s, int argc, t_atom *a if (argc>x->x_n) argc=x->x_n; for (i=0;ix->x_hithresh) { - outlet_float(x->x_outlet1, (float)i); // on + outlet_float(x->x_outlet1, (t_float)i); // on *state=1; } } @@ -77,7 +77,7 @@ static void vthreshold_perform(t_vthreshold *x, t_symbol *s, int argc, t_atom *a { if (fx_lothresh) { - outlet_float(x->x_outlet2, (float)i); // off + outlet_float(x->x_outlet2, (t_float)i); // off *state=-1; } } diff --git a/vvconv.c b/vvconv.c index 5541705..1e107f0 100644 --- a/vvconv.c +++ b/vvconv.c @@ -101,7 +101,7 @@ static void vvconv_lst(t_vvconv *x, t_symbol *s, int argc, t_atom *argv) SETFLOAT(a, *g++); a++; } - freebytes(f,sizeof(float)*n); + freebytes(f,sizeof(t_float)*n); } outlet_list(x->x_obj.ob_outlet, gensym("list"), n, ap); freebytes(ap, sizeof(t_atom)*n); -- cgit v1.2.1