aboutsummaryrefslogtreecommitdiff
path: root/iemlib1
diff options
context:
space:
mode:
Diffstat (limited to 'iemlib1')
-rw-r--r--iemlib1/src/lp1_t~.c125
-rw-r--r--iemlib1/src/peakenv_hold~.c42
-rw-r--r--iemlib1/src/peakenv~.c35
3 files changed, 102 insertions, 100 deletions
diff --git a/iemlib1/src/lp1_t~.c b/iemlib1/src/lp1_t~.c
index 5eb86a4..96e4a4e 100644
--- a/iemlib1/src/lp1_t~.c
+++ b/iemlib1/src/lp1_t~.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 - 2010 */
#include "m_pd.h"
#include "iemlib.h"
@@ -12,13 +12,13 @@ iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006
typedef struct _lp1_t_tilde
{
t_object x_obj;
- t_float yn1;
- t_float c0;
- t_float c1;
- t_float sr;
- t_float cur_t;
- t_float delta_t;
- t_float end_t;
+ double yn1;
+ double c0;
+ double c1;
+ double sr;
+ double cur_t;
+ double delta_t;
+ double end_t;
t_float ticks_per_interpol_time;
t_float rcp_ticks;
t_float interpol_time;
@@ -43,11 +43,11 @@ static void lp1_t_tilde_dsp_tick(t_lp1_t_tilde *x)
x->counter_t--;
x->cur_t += x->delta_t;
}
- if(x->cur_t == 0.0f)
- x->c1 = 0.0f;
+ if(x->cur_t == 0.0)
+ x->c1 = 0.0;
else
x->c1 = exp((x->sr)/x->cur_t);
- x->c0 = 1.0f - x->c1;
+ x->c0 = 1.0 - x->c1;
}
}
@@ -57,19 +57,19 @@ static t_int *lp1_t_tilde_perform(t_int *w)
t_float *out = (t_float *)(w[2]);
t_lp1_t_tilde *x = (t_lp1_t_tilde *)(w[3]);
int i, n = (t_int)(w[4]);
- t_float yn0, yn1=x->yn1;
- t_float c0=x->c0, c1=x->c1;
+ double yn0, yn1=x->yn1;
+ double c0=x->c0, c1=x->c1;
lp1_t_tilde_dsp_tick(x);
for(i=0; i<n; i++)
{
- yn0 = (*in++)*c0 + yn1*c1;
- *out++ = yn0;
+ yn0 = (double)(*in++)*c0 + yn1*c1;
+ *out++ = (t_float)yn0;
yn1 = yn0;
}
/* NAN protect */
- if(IEM_DENORMAL(yn1))
- yn1 = 0.0f;
+ //if(IEM_DENORMAL(yn1))
+ // yn1 = 0.0;
x->yn1 = yn1;
return(w+5);
}
@@ -80,59 +80,62 @@ static t_int *lp1_t_tilde_perf8(t_int *w)
t_float *out = (t_float *)(w[2]);
t_lp1_t_tilde *x = (t_lp1_t_tilde *)(w[3]);
int i, n = (t_int)(w[4]);
- t_float ynn[9];
- t_float c0=x->c0, c1=x->c1;
+ double ynn[9];
+ double c0=x->c0, c1=x->c1;
lp1_t_tilde_dsp_tick(x);
ynn[0] = x->yn1;
for(i=0; i<n; i+=8, in+=8, out+=8)
{
- ynn[1] = in[0]*c0 + ynn[0]*c1;
- out[0] = ynn[1];
- ynn[2] = in[1]*c0 + ynn[1]*c1;
- out[1] = ynn[2];
- ynn[3] = in[2]*c0 + ynn[2]*c1;
- out[2] = ynn[3];
- ynn[4] = in[3]*c0 + ynn[3]*c1;
- out[3] = ynn[4];
- ynn[5] = in[4]*c0 + ynn[4]*c1;
- out[4] = ynn[5];
- ynn[6] = in[5]*c0 + ynn[5]*c1;
- out[5] = ynn[6];
- ynn[7] = in[6]*c0 + ynn[6]*c1;
- out[6] = ynn[7];
- ynn[8] = in[7]*c0 + ynn[7]*c1;
- out[7] = ynn[8];
+ ynn[1] = (double)in[0]*c0 + ynn[0]*c1;
+ out[0] = (t_float)ynn[1];
+ ynn[2] = (double)in[1]*c0 + ynn[1]*c1;
+ out[1] = (t_float)ynn[2];
+ ynn[3] = (double)in[2]*c0 + ynn[2]*c1;
+ out[2] = (t_float)ynn[3];
+ ynn[4] = (double)in[3]*c0 + ynn[3]*c1;
+ out[3] = (t_float)ynn[4];
+ ynn[5] = (double)in[4]*c0 + ynn[4]*c1;
+ out[4] = (t_float)ynn[5];
+ ynn[6] = (double)in[5]*c0 + ynn[5]*c1;
+ out[5] = (t_float)ynn[6];
+ ynn[7] = (double)in[6]*c0 + ynn[6]*c1;
+ out[6] = (t_float)ynn[7];
+ ynn[8] = (double)in[7]*c0 + ynn[7]*c1;
+ out[7] = (t_float)ynn[8];
ynn[0] = ynn[8];
}
/* NAN protect */
- if(IEM_DENORMAL(ynn[0]))
- ynn[0] = 0.0f;
+ //if(IEM_DENORMAL(ynn[0]))
+ // ynn[0] = 0.0f;
x->yn1 = ynn[0];
return(w+5);
}
-static void lp1_t_tilde_ft2(t_lp1_t_tilde *x, t_floatarg t)
+static void lp1_t_tilde_ft2(t_lp1_t_tilde *x, t_floatarg interpol)
{
- int i = (int)((x->ticks_per_interpol_time)*t);
+ int i = (int)((x->ticks_per_interpol_time)*interpol);
- x->interpol_time = t;
+ x->interpol_time = interpol;
if(i <= 0)
i = 1;
x->ticks = i;
x->rcp_ticks = 1.0f / (t_float)i;
}
-static void lp1_t_tilde_ft1(t_lp1_t_tilde *x, t_floatarg time_const)
+static void lp1_t_tilde_ft1(t_lp1_t_tilde *x, t_floatarg f_time_const)
{
- if(time_const < 0.0f)
- time_const = 0.0f;
- if(time_const != x->cur_t)
+ double d_time_const;
+
+ if(f_time_const < 0.0f)
+ f_time_const = 0.0f;
+ d_time_const = (double)f_time_const;
+ if(d_time_const != x->cur_t)
{
- x->end_t = time_const;
+ x->end_t = d_time_const;
x->counter_t = x->ticks;
- x->delta_t = (time_const - x->cur_t) * x->rcp_ticks;
+ x->delta_t = (d_time_const - x->cur_t) * (double)x->rcp_ticks;
}
}
@@ -140,18 +143,18 @@ 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.0f / (t_float)(sp[0]->s_sr);
+ 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;
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;
- if(x->cur_t == 0.0f)
- x->c1 = 0.0f;
+ if(x->cur_t == 0.0)
+ x->c1 = 0.0;
else
x->c1 = exp((x->sr)/x->cur_t);
- x->c0 = 1.0f - x->c1;
+ x->c0 = 1.0 - x->c1;
if(n&7)
dsp_add(lp1_t_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, n);
else
@@ -162,29 +165,30 @@ 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 time_const=0.0f, interpol=0.0f;
+ t_float interpol=0.0f;
+ 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_msi = 0;
x->counter_t = 1;
- x->delta_t = 0.0f;
+ x->delta_t = 0.0;
x->interpol_time = 0.0f;
- x->yn1 = 0.0f;
- x->sr = -1.0f / 44.1f;
+ x->yn1 = 0.0;
+ x->sr = -1.0 / 44.1;
if((argc >= 1)&&IS_A_FLOAT(argv,0))
- time_const = (t_float)atom_getfloatarg(0, argc, argv);
+ time_const = (double)atom_getfloatarg(0, argc, argv);
if((argc >= 2)&&IS_A_FLOAT(argv,1))
interpol = (t_float)atom_getfloatarg(1, argc, argv);
- if(time_const < 0.0f)
- time_const = 0.0f;
+ if(time_const < 0.0)
+ time_const = 0.0;
x->cur_t = time_const;
- if(time_const == 0.0f)
- x->c1 = 0.0f;
+ if(time_const == 0.0)
+ x->c1 = 0.0;
else
x->c1 = exp((x->sr)/time_const);
- x->c0 = 1.0f - x->c1;
+ x->c0 = 1.0 - x->c1;
if(interpol < 0.0f)
interpol = 0.0f;
x->interpol_time = interpol;
@@ -206,5 +210,4 @@ void lp1_t_tilde_setup(void)
class_addmethod(lp1_t_tilde_class, (t_method)lp1_t_tilde_dsp, gensym("dsp"), 0);
class_addmethod(lp1_t_tilde_class, (t_method)lp1_t_tilde_ft1, gensym("ft1"), A_FLOAT, 0);
class_addmethod(lp1_t_tilde_class, (t_method)lp1_t_tilde_ft2, gensym("ft2"), A_FLOAT, 0);
-// class_sethelpsymbol(lp1_t_tilde_class, gensym("iemhelp/help-lp1_t~"));
}
diff --git a/iemlib1/src/peakenv_hold~.c b/iemlib1/src/peakenv_hold~.c
index 9019527..715bed9 100644
--- a/iemlib1/src/peakenv_hold~.c
+++ b/iemlib1/src/peakenv_hold~.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 - 2008 */
+iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2010 */
#include "m_pd.h"
@@ -13,11 +13,11 @@ iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2008
typedef struct _peakenv_hold_tilde
{
t_object x_obj;
- t_float x_sr;
- t_float x_old_peak;
- t_float x_c1;
- t_float x_releasetime;
- t_float x_holdtime;
+ double x_sr;
+ double x_old_peak;
+ double x_c1;
+ double x_releasetime;
+ double x_holdtime;
t_int x_n_hold;
t_int x_counter;
t_float x_msi;
@@ -27,7 +27,7 @@ static t_class *peakenv_hold_tilde_class;
static void peakenv_hold_tilde_reset(t_peakenv_hold_tilde *x)
{
- x->x_old_peak = 0.0f;
+ x->x_old_peak = 0.0;
}
static void peakenv_hold_tilde_ft1(t_peakenv_hold_tilde *x, t_float t_hold)/* hold-time in ms */
@@ -36,18 +36,18 @@ static void peakenv_hold_tilde_ft1(t_peakenv_hold_tilde *x, t_float t_hold)/* ho
if(t_hold < 0.0f)
t_hold = 0.0f;
- x->x_holdtime = t_hold;
- dhold = (double)x->x_sr*(double)0.001*(double)x->x_holdtime;
+ x->x_holdtime = (double)t_hold;
+ dhold = x->x_sr*0.001*x->x_holdtime;
if(dhold > 2147483647.0)
dhold = 2147483647.0;
- x->x_n_hold = (t_int)(dhold + (double)0.5);
+ x->x_n_hold = (t_int)(dhold + 0.5);
}
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;
- x->x_releasetime = t_rel;
+ x->x_releasetime = (double)t_rel;
x->x_c1 = exp(-1.0/(x->x_sr*0.001*x->x_releasetime));
}
@@ -57,15 +57,15 @@ static t_int *peakenv_hold_tilde_perform(t_int *w)
t_float *out = (t_float *)(w[2]);
t_peakenv_hold_tilde *x = (t_peakenv_hold_tilde *)(w[3]);
int n = (int)(w[4]);
- t_float peak = x->x_old_peak;
- t_float c1 = x->x_c1;
- t_float absolute;
+ double peak = x->x_old_peak;
+ double c1 = x->x_c1;
+ double absolute;
t_int i, counter;
counter = x->x_counter;
for(i=0; i<n; i++)
{
- absolute = fabs(*in++);
+ absolute = (double)fabs(*in++);
if(counter > 0)
counter--;// hold peride
else
@@ -75,11 +75,11 @@ static t_int *peakenv_hold_tilde_perform(t_int *w)
peak = absolute;
counter = x->x_n_hold;// new hold initialisation
}
- *out++ = peak;
+ *out++ = (t_float)peak;
}
/* NAN protect */
- if(IEM_DENORMAL(peak))
- peak = 0.0f;
+ //if(IEM_DENORMAL(peak))
+ // peak = 0.0f;
x->x_old_peak = peak;
x->x_counter = counter;
return(w+5);
@@ -87,7 +87,7 @@ static t_int *peakenv_hold_tilde_perform(t_int *w)
static void peakenv_hold_tilde_dsp(t_peakenv_hold_tilde *x, t_signal **sp)
{
- x->x_sr = (t_float)sp[0]->s_sr;
+ x->x_sr = (double)sp[0]->s_sr;
peakenv_hold_tilde_ft1(x, x->x_holdtime);
peakenv_hold_tilde_ft2(x, x->x_releasetime);
dsp_add(peakenv_hold_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n);
@@ -97,10 +97,10 @@ static void *peakenv_hold_tilde_new(t_float t_hold, t_float t_rel)
{
t_peakenv_hold_tilde *x = (t_peakenv_hold_tilde *)pd_new(peakenv_hold_tilde_class);
- x->x_sr = 44100.0f;
+ x->x_sr = 44100.0;
peakenv_hold_tilde_ft1(x, t_hold);
peakenv_hold_tilde_ft2(x, t_rel);
- x->x_old_peak = 0.0f;
+ x->x_old_peak = 0.0;
x->x_counter = 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"));
diff --git a/iemlib1/src/peakenv~.c b/iemlib1/src/peakenv~.c
index 0625205..d9ebeff 100644
--- a/iemlib1/src/peakenv~.c
+++ b/iemlib1/src/peakenv~.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 - 2010 */
#include "m_pd.h"
@@ -13,10 +13,10 @@ iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006
typedef struct _peakenv_tilde
{
t_object x_obj;
- t_float x_sr;
- t_float x_old_peak;
- t_float x_c1;
- t_float x_releasetime;
+ double x_sr;
+ double x_old_peak;
+ double x_c1;
+ double x_releasetime;
t_float x_msi;
} t_peakenv_tilde;
@@ -24,14 +24,14 @@ static t_class *peakenv_tilde_class;
static void peakenv_tilde_reset(t_peakenv_tilde *x)
{
- x->x_old_peak = 0.0f;
+ x->x_old_peak = 0.0;
}
static void peakenv_tilde_ft1(t_peakenv_tilde *x, t_floatarg f)/* release-time in ms */
{
if(f < 0.0f)
f = 0.0f;
- x->x_releasetime = f;
+ x->x_releasetime = (double)f;
x->x_c1 = exp(-1.0/(x->x_sr*0.001*x->x_releasetime));
}
@@ -41,29 +41,29 @@ static t_int *peakenv_tilde_perform(t_int *w)
t_float *out = (t_float *)(w[2]);
t_peakenv_tilde *x = (t_peakenv_tilde *)(w[3]);
int n = (int)(w[4]);
- t_float peak = x->x_old_peak;
- t_float c1 = x->x_c1;
- t_float absolute;
+ double peak = x->x_old_peak;
+ double c1 = x->x_c1;
+ double absolute;
int i;
for(i=0; i<n; i++)
{
- absolute = fabs(*in++);
+ absolute = (double)fabs(*in++);
peak *= c1;
if(absolute > peak)
peak = absolute;
- *out++ = peak;
+ *out++ = (t_float)peak;
}
/* NAN protect */
- if(IEM_DENORMAL(peak))
- peak = 0.0f;
+ //if(IEM_DENORMAL(peak))
+ // peak = 0.0f;
x->x_old_peak = peak;
return(w+5);
}
static void peakenv_tilde_dsp(t_peakenv_tilde *x, t_signal **sp)
{
- x->x_sr = (t_float)sp[0]->s_sr;
+ x->x_sr = (double)sp[0]->s_sr;
peakenv_tilde_ft1(x, x->x_releasetime);
dsp_add(peakenv_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n);
}
@@ -74,9 +74,9 @@ static void *peakenv_tilde_new(t_floatarg f)
if(f <= 0.0f)
f = 0.0f;
- x->x_sr = 44100.0f;
+ x->x_sr = 44100.0;
peakenv_tilde_ft1(x, f);
- x->x_old_peak = 0.0f;
+ 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_msi = 0;
@@ -91,5 +91,4 @@ void peakenv_tilde_setup(void)
class_addmethod(peakenv_tilde_class, (t_method)peakenv_tilde_dsp, gensym("dsp"), 0);
class_addmethod(peakenv_tilde_class, (t_method)peakenv_tilde_ft1, gensym("ft1"), A_FLOAT, 0);
class_addmethod(peakenv_tilde_class, (t_method)peakenv_tilde_reset, gensym("reset"), 0);
-// class_sethelpsymbol(peakenv_tilde_class, gensym("iemhelp/help-peakenv~"));
}