From 4f1ee28d687d583601d41ff58e1618b381d2675f Mon Sep 17 00:00:00 2001 From: Katja Date: Sun, 6 Nov 2011 14:41:44 +0000 Subject: made creb compliant with double precision - changed float to t_float - adapted subnormal detection svn path=/trunk/externals/creb/; revision=15706 --- modules/sbosc~.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'modules/sbosc~.c') diff --git a/modules/sbosc~.c b/modules/sbosc~.c index 7b740b8..b337213 100644 --- a/modules/sbosc~.c +++ b/modules/sbosc~.c @@ -32,25 +32,25 @@ #define SHIFTTABSIZE ((sizeof(unsigned int) * 8) - LOGTABSIZE) #define FRACTABSIZE (1<> SHIFTTABSIZE; - float f2 = (t & MASKFRACTABSIZE) * INVFRACTABSIZE; + t_float f2 = (t & MASKFRACTABSIZE) * INVFRACTABSIZE; unsigned int i2 = (i1+1) & MASKTABSIZE; unsigned int i3 = (i1 - (TABSIZE>>2)) & MASKTABSIZE; unsigned int i4 = (i2 + 1 - (TABSIZE>>2)) & MASKTABSIZE; - float f1 = 1.0f - f2; - float a1 = f1 * costable[i1]; - float a2 = f2 * costable[i2]; - float b1 = f1 * costable[i3]; - float b2 = f2 * costable[i4]; + t_float f1 = 1.0 - f2; + t_float a1 = f1 * costable[i1]; + t_float a2 = f2 * costable[i2]; + t_float b1 = f1 * costable[i3]; + t_float b2 = f2 * costable[i4]; *real = a1 + a2; *imag = b1 + b2; } @@ -60,13 +60,13 @@ static t_class *sbosc_tilde_class; typedef struct _sbosc_tilde { t_object x_obj; - float x_f; + t_float x_f; /* state vars */ unsigned int x_phase; // phase of main pitch osc unsigned int x_phase_inc; // frequency of main pitch osc unsigned int x_harmonic; // first harmonic - float x_frac; // fraction of first harmonic + t_float x_frac; // fraction of first harmonic } t_sbosc_tilde; @@ -94,13 +94,13 @@ static t_int *sbosc_tilde_perform(t_int *w) int n = (int)(w[6]); int i; - t_float pitch_to_phase = 4294967295.0f / sys_getsr(); + t_float pitch_to_phase = 4294967295.0 / sys_getsr(); for (i = 0; i < n; i++) { - float p = *pitch++; - float c = *center++; - float r1,r2,i1,i2; + t_float p = *pitch++; + t_float c = *center++; + t_float r1,r2,i1,i2; /* compute harmonic mixture */ unsigned int h1 = x->x_phase * x->x_harmonic; @@ -109,8 +109,8 @@ static t_int *sbosc_tilde_perform(t_int *w) _exp_j2pi(h2, &r2, &i2); r1 *= x->x_frac; i1 *= x->x_frac; - r2 *= 1.0f - x->x_frac; - i2 *= 1.0f - x->x_frac; + r2 *= 1.0 - x->x_frac; + i2 *= 1.0 - x->x_frac; *out_real++ = r1 + r2; *out_imag++ = i1 + i2; @@ -121,13 +121,13 @@ static t_int *sbosc_tilde_perform(t_int *w) /* check for phase wrap & update osc */ if ((x->x_phase <= x->x_phase_inc)) { - float p_plus = (p < 0.0f) ? -p : p; - float p_limit = (p_plus < PITCHLIMIT) ? PITCHLIMIT : p_plus; - float c_plus = (c < 0.0f) ? -c : c; - float harmonic = c_plus/p_limit; + t_float p_plus = (p < 0.0) ? -p : p; + t_float p_limit = (p_plus < PITCHLIMIT) ? PITCHLIMIT : p_plus; + t_float c_plus = (c < 0.0) ? -c : c; + t_float harmonic = c_plus/p_limit; x->x_phase_inc = pitch_to_phase * p_limit; x->x_harmonic = harmonic; - x->x_frac = 1.0f - (harmonic - x->x_harmonic); + x->x_frac = 1.0 - (harmonic - x->x_harmonic); } @@ -149,7 +149,7 @@ static void sbosc_tilde_free(t_sbosc_tilde *x) static void sbosc_tilde_phase(t_sbosc_tilde *x, t_floatarg f) { - x->x_phase = f * (1.0f / 4294967295.0f); + x->x_phase = f * (1.0 / 4294967295.0); } void sbosc_tilde_setup(void) -- cgit v1.2.1