From d3af2d2474bfff3a987d54bc58d96c97cea1ec11 Mon Sep 17 00:00:00 2001 From: musil Date: Wed, 8 Nov 2006 10:49:48 +0000 Subject: changed sig*.c to *~.c svn path=/trunk/externals/iemlib/; revision=6230 --- src/iemlib2/sigfade.c | 188 -------------------------------------------------- 1 file changed, 188 deletions(-) delete mode 100644 src/iemlib2/sigfade.c (limited to 'src/iemlib2/sigfade.c') diff --git a/src/iemlib2/sigfade.c b/src/iemlib2/sigfade.c deleted file mode 100644 index a73a3a7..0000000 --- a/src/iemlib2/sigfade.c +++ /dev/null @@ -1,188 +0,0 @@ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL -* WARRANTIES, see the file, "LICENSE.txt," in this distribution. - -iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */ - -#include "m_pd.h" -#include "iemlib.h" -#include - -/* ------------------------- fade~ ----------------------------- */ -/* --- signal lookup tabel object with input range of 0 to 1 --- */ -/* ---- converts a linear signal ramp to the half of a : ------ */ -/* -- sine-wave, hanning-wave, squareroot-wave or mixes of it -- */ - -float *iem_fade_table_lin=(float *)0L; -float *iem_fade_table_linsqrt=(float *)0L; -float *iem_fade_table_sqrt=(float *)0L; -float *iem_fade_table_sin=(float *)0L; -float *iem_fade_table_sinhann=(float *)0L; -float *iem_fade_table_hann=(float *)0L; - -static t_class *sigfade_class; - -typedef struct _sigfade -{ - t_object x_obj; - t_float *x_table; - t_float x_f; -} t_sigfade; - -static void sigfade_set(t_sigfade *x, t_symbol *s) -{ - /*if(!strcmp(s->s_name, "_lin")) - x->x_table = iem_fade_table_lin; - else if(!strcmp(s->s_name, "_linsqrt")) - x->x_table = iem_fade_table_linsqrt; - else if(!strcmp(s->s_name, "_sqrt")) - x->x_table = iem_fade_table_sqrt; - else if(!strcmp(s->s_name, "_sin")) - x->x_table = iem_fade_table_sin; - else if(!strcmp(s->s_name, "_sinhann")) - x->x_table = iem_fade_table_sinhann; - else if(!strcmp(s->s_name, "_hann")) - x->x_table = iem_fade_table_hann;*/ - if(s == gensym("_lin")) - x->x_table = iem_fade_table_lin; - else if(s == gensym("_linsqrt")) - x->x_table = iem_fade_table_linsqrt; - else if(s == gensym("_sqrt")) - x->x_table = iem_fade_table_sqrt; - else if(s == gensym("_sin")) - x->x_table = iem_fade_table_sin; - else if(s == gensym("_sinhann")) - x->x_table = iem_fade_table_sinhann; - else if(s == gensym("_hann")) - x->x_table = iem_fade_table_hann; -} - -static void *sigfade_new(t_symbol *s) -{ - t_sigfade *x = (t_sigfade *)pd_new(sigfade_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - x->x_table = iem_fade_table_lin; - sigfade_set(x, s); - return (x); -} - -static t_int *sigfade_perform(t_int *w) -{ - t_float *in = (t_float *)(w[1]); - t_float *out = (t_float *)(w[2]); - t_sigfade *x = (t_sigfade *)(w[3]); - int n = (int)(w[4]); - t_float *tab = x->x_table, *addr, f1, f2, frac; - double dphase; - int normhipart; - union tabfudge tf; - - tf.tf_d = UNITBIT32; - normhipart = tf.tf_i[HIOFFSET]; - -#if 0 /* this is the readable version of the code. */ - while (n--) - { - dphase = (double)(*in++ * (t_float)(COSTABSIZE) * 0.99999) + UNITBIT32; - tf.tf_d = dphase; - addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1)); - tf.tf_i[HIOFFSET] = normhipart; - frac = tf.tf_d - UNITBIT32; - f1 = addr[0]; - f2 = addr[1]; - *out++ = f1 + frac * (f2 - f1); - } -#endif -#if 1 /* this is the same, unwrapped by hand. */ - dphase = (double)(*in++ * (t_float)(COSTABSIZE) * 0.99999) + UNITBIT32; - tf.tf_d = dphase; - addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1)); - tf.tf_i[HIOFFSET] = normhipart; - while (--n) - { - dphase = (double)(*in++ * (t_float)(COSTABSIZE) * 0.99999) + UNITBIT32; - frac = tf.tf_d - UNITBIT32; - tf.tf_d = dphase; - f1 = addr[0]; - f2 = addr[1]; - addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1)); - *out++ = f1 + frac * (f2 - f1); - tf.tf_i[HIOFFSET] = normhipart; - } - frac = tf.tf_d - UNITBIT32; - f1 = addr[0]; - f2 = addr[1]; - *out++ = f1 + frac * (f2 - f1); -#endif - return (w+5); -} - -static void sigfade_dsp(t_sigfade *x, t_signal **sp) -{ - dsp_add(sigfade_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); -} - -static void sigfade_maketable(void) -{ - int i; - t_float *fp, phase, fff,phsinc = 0.5*3.141592653 / ((t_float)COSTABSIZE*0.99999); - union tabfudge tf; - - if(!iem_fade_table_sin) - { - iem_fade_table_sin = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1)); - for(i=COSTABSIZE+1, fp=iem_fade_table_sin, phase=0; i--; fp++, phase+=phsinc) - *fp = sin(phase); - } - if(!iem_fade_table_sinhann) - { - iem_fade_table_sinhann = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1)); - for(i=COSTABSIZE+1, fp=iem_fade_table_sinhann, phase=0; i--; fp++, phase+=phsinc) - { - fff = sin(phase); - *fp = fff*sqrt(fff); - } - } - if(!iem_fade_table_hann) - { - iem_fade_table_hann = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1)); - for(i=COSTABSIZE+1, fp=iem_fade_table_hann, phase=0; i--; fp++, phase+=phsinc) - { - fff = sin(phase); - *fp = fff*fff; - } - } - phsinc = 1.0 / ((t_float)COSTABSIZE*0.99999); - if(!iem_fade_table_lin) - { - iem_fade_table_lin = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1)); - for(i=COSTABSIZE+1, fp=iem_fade_table_lin, phase=0; i--; fp++, phase+=phsinc) - *fp = phase; - } - if(!iem_fade_table_linsqrt) - { - iem_fade_table_linsqrt = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1)); - for(i=COSTABSIZE+1, fp=iem_fade_table_linsqrt, phase=0; i--; fp++, phase+=phsinc) - *fp = pow(phase, 0.75); - } - if(!iem_fade_table_sqrt) - { - iem_fade_table_sqrt = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1)); - for(i=COSTABSIZE+1, fp=iem_fade_table_sqrt, phase=0; i--; fp++, phase+=phsinc) - *fp = sqrt(phase); - } - tf.tf_d = UNITBIT32 + 0.5; - if((unsigned)tf.tf_i[LOWOFFSET] != 0x80000000) - bug("fade~: unexpected machine alignment"); -} - -void sigfade_setup(void) -{ - sigfade_class = class_new(gensym("fade~"), (t_newmethod)sigfade_new, 0, - sizeof(t_sigfade), 0, A_DEFSYM, 0); - CLASS_MAINSIGNALIN(sigfade_class, t_sigfade, x_f); - class_addmethod(sigfade_class, (t_method)sigfade_dsp, gensym("dsp"), 0); - class_addmethod(sigfade_class, (t_method)sigfade_set, gensym("set"), A_DEFSYM, 0); - class_sethelpsymbol(sigfade_class, gensym("iemhelp/help-fade~")); - sigfade_maketable(); -} -- cgit v1.2.1