Update of /cvsroot/pure-data/externals/postlude/flib/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24308
Modified Files: clean~.c Log Message: Added features to bang right output when dirty values found, and set replacement value via first argument
Index: clean~.c =================================================================== RCS file: /cvsroot/pure-data/externals/postlude/flib/src/clean~.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** clean~.c 10 Jan 2006 11:49:01 -0000 1.1.1.1 --- clean~.c 20 Jan 2006 12:58:38 -0000 1.2 *************** *** 19,25 ****
! /* cleans 'nan' 'inf' '-inf' from an audio vector */
#include "flib.h" static t_class *clean_class;
--- 19,29 ----
! /* cleans 'nan' 'inf' '-inf' from an audio vector or control value ! * If no argument is given 'dirty' values will be replaced by 0, otherwise values are replaced by the argument value. If an audio vector is given as input, a bang is sent to the right output if 'dirty' values are found */
#include "flib.h" + + #define CLEAN (x->outval == x->inf ? 0 : x->outval) + static t_class *clean_class;
*************** *** 28,31 **** --- 32,36 ---- t_float f; t_outlet *out_r; + t_float outval, inf; } t_clean;
*************** *** 36,47 **** t_int N = (t_int)(w[3]); t_clean *x = (t_clean *)(w[4]); ! while(N--){ ! if(finite(*in)) ! *out++ = *in++; else ! *out++ = 0; } return (w+5); } --- 41,58 ---- t_int N = (t_int)(w[3]); t_clean *x = (t_clean *)(w[4]); ! t_int dirty = 0; while(N--){ ! if(!finite(*in)){ ! dirty = 1; ! *out++ = CLEAN; ! ! } else ! *out++ = *in++; } + if(dirty) + outlet_bang(x->out_r); + return (w+5); } *************** *** 56,61 **** { x->f = f; ! if(!x->f || !finite(x->f)) ! outlet_float(x->out_r, 0); else outlet_float(x->out_r, x->f); --- 67,72 ---- { x->f = f; ! if(!finite(x->f)) ! outlet_float(x->out_r, CLEAN); else outlet_float(x->out_r, x->f); *************** *** 65,73 ****
! static void *clean_new(void) { t_clean *x = (t_clean *)pd_new(clean_class); outlet_new(&x->x_obj, &s_signal); x->out_r = outlet_new(&x->x_obj, &s_float); return (void *)x; } --- 76,92 ----
! static void *clean_new(t_symbol *s, t_int argc, t_atom *argv) { t_clean *x = (t_clean *)pd_new(clean_class); outlet_new(&x->x_obj, &s_signal); x->out_r = outlet_new(&x->x_obj, &s_float); + x->inf = (t_float)HUGE_VAL; + + if(argc) + x->outval = atom_getfloatarg(0, argc, argv); + else + x->outval = x->inf; + + post("%.2f", x->outval); return (void *)x; } *************** *** 78,82 **** (t_newmethod)clean_new, 0, sizeof(t_clean), ! CLASS_DEFAULT, 0);
CLASS_MAINSIGNALIN(clean_class, t_clean,f); --- 97,101 ---- (t_newmethod)clean_new, 0, sizeof(t_clean), ! CLASS_DEFAULT, A_GIMME, 0);
CLASS_MAINSIGNALIN(clean_class, t_clean,f);