Update of /cvsroot/pure-data/externals/iemlib/iemlib2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16686/iemlib/iemlib2/src
Added Files: LFO_noise~.c add2_comma.c bpe.c dollarg.c exp_inc.c Log Message: // class_sethelpsymbol(); changed help-*.pd to *-help.pd chanded file structure to standard 1st step remove old
--- NEW FILE: add2_comma.c --- /* 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 - 2006 */
#include "m_pd.h" #include "iemlib.h"
/* --------------------------------- add2_comma ----------------------------------- */ /* -- a special add2-message for messageboxes, which append a comma to a message -- */
static t_class *add2_comma_class;
typedef struct _add2_comma { t_object x_obj; int x_size; t_atom *x_at; t_symbol *x_sym; t_atomtype x_type; } t_add2_comma;
static void add2_comma_bang(t_add2_comma *x) { SETCOMMA(x->x_at); outlet_anything(x->x_obj.ob_outlet, x->x_sym, 1, x->x_at); }
static void add2_comma_float(t_add2_comma *x, t_floatarg f) { SETCOMMA(x->x_at); SETFLOAT(x->x_at+1, f); outlet_anything(x->x_obj.ob_outlet, x->x_sym, 2, x->x_at); }
static void add2_comma_symbol(t_add2_comma *x, t_symbol *s) { SETCOMMA(x->x_at); SETSYMBOL(x->x_at+1, s); outlet_anything(x->x_obj.ob_outlet, x->x_sym, 2, x->x_at); }
/*static void add2_comma_pointer(t_add2_comma *x, t_gpointer *gp) { if(!x->x_at) { x->x_n = 1; x->x_at = (t_atom *)getbytes(sizeof(t_atom)); } x->x_ac = 1; SETPOINTER(x->x_at, gp); x->x_sym = &s_pointer; outlet_pointer(x->x_obj.ob_outlet, gp); }*/
static void add2_comma_list(t_add2_comma *x, t_symbol *s, int ac, t_atom *av) { int i;
if((ac+1) > x->x_size) { x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (ac+2)*sizeof(t_atom)); x->x_size = ac+2; } SETCOMMA(x->x_at); for(i=1; i<=ac; i++) x->x_at[i] = av[i-1]; outlet_anything(x->x_obj.ob_outlet, x->x_sym, ac+1, x->x_at); }
static void add2_comma_anything(t_add2_comma *x, t_symbol *s, int ac, t_atom *av) { int i;
if((ac+2) > x->x_size) { x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (ac+3)*sizeof(t_atom)); x->x_size = ac+3; } SETCOMMA(x->x_at); SETSYMBOL(x->x_at+1, s); for(i=1; i<=ac; i++) x->x_at[i+1] = av[i-1]; outlet_anything(x->x_obj.ob_outlet, x->x_sym, ac+2, x->x_at); }
static void add2_comma_free(t_add2_comma *x) { if(x->x_at) freebytes(x->x_at, x->x_size * sizeof(t_atom)); }
static void *add2_comma_new(void) { t_add2_comma *x = (t_add2_comma *)pd_new(add2_comma_class);
x->x_size = 10; x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom)); x->x_sym = gensym("add2"); outlet_new(&x->x_obj, &s_list); return(x); }
void add2_comma_setup(void) { add2_comma_class = class_new(gensym("add2_comma"), (t_newmethod)add2_comma_new, (t_method)add2_comma_free, sizeof(t_add2_comma), 0, 0); class_addbang(add2_comma_class, (t_method)add2_comma_bang); class_addanything(add2_comma_class, add2_comma_anything); class_addlist(add2_comma_class, add2_comma_list); /*class_addpointer(add2_comma_class, add2_comma_pointer);*/ class_addfloat(add2_comma_class, (t_method)add2_comma_float); class_addsymbol(add2_comma_class, add2_comma_symbol); // class_sethelpsymbol(add2_comma_class, gensym("iemhelp/help-add2_comma")); }
--- NEW FILE: LFO_noise~.c --- /* 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 - 2006 */
#include "m_pd.h" #include "iemlib.h"
/* -------------------- LFO_noise~ --------------------- */ /* ---- outputs a 2 point interpolated white noise ----- */ /* -- with lower cutoff frequency than 0.5 samplerate -- */
static t_class *LFO_noise_tilde_class;
typedef struct _LFO_noise_tilde { t_object x_obj; double x_range; double x_rcp_range; unsigned int x_state; t_float x_fact; t_float x_incr; t_float x_y1; t_float x_y2; t_float x_phase; } t_LFO_noise_tilde;
static int LFO_noise_tilde_makeseed(void) { static unsigned int LFO_noise_tilde_nextseed = 1489853723;
LFO_noise_tilde_nextseed = LFO_noise_tilde_nextseed * 435898247 + 938284287; return(LFO_noise_tilde_nextseed & 0x7fffffff); }
static float LFO_noise_tilde_new_rand(t_LFO_noise_tilde *x) { unsigned int state = x->x_state; double new_val, range = x->x_range;
x->x_state = state = state * 472940017 + 832416023; new_val = range * ((double)state) * (1./4294967296.); if(new_val >= range) new_val = range-1; new_val -= 32767.0; return(new_val*(1.0/32767.0)); }
static void *LFO_noise_tilde_new(t_float freq) { t_LFO_noise_tilde *x = (t_LFO_noise_tilde *)pd_new(LFO_noise_tilde_class);
x->x_range = 65535.0; x->x_rcp_range = (double)x->x_range * (1.0/4294967296.0); x->x_state = LFO_noise_tilde_makeseed(); x->x_fact = 2.0f / 44100.0f; x->x_incr = freq * x->x_fact; if(x->x_incr < 0.0f) x->x_incr = 0.0f; else if(x->x_incr > 0.1f) x->x_incr = 0.1f; x->x_y1 = LFO_noise_tilde_new_rand(x); x->x_y2 = LFO_noise_tilde_new_rand(x); x->x_phase = 0.0f; outlet_new(&x->x_obj, gensym("signal")); return (x); }
static t_int *LFO_noise_tilde_perform(t_int *w) { t_float *out = (t_float *)(w[1]); t_LFO_noise_tilde *x = (t_LFO_noise_tilde *)(w[2]); int n = (int)(w[3]); t_float phase = x->x_phase; t_float x_y1 = x->x_y1; t_float x_y2 = x->x_y2; t_float incr = x->x_incr;
while(n--) { if(phase > 1.0f) { x_y1 = x_y2; x_y2 = LFO_noise_tilde_new_rand(x); phase -= 1.0; } *out++ = (x_y2 - x_y1) * phase + x_y1; phase += incr; } x->x_phase = phase; x->x_y1 = x_y1; x->x_y2 = x_y2; return (w+4); }
static void LFO_noise_tilde_float(t_LFO_noise_tilde *x, t_floatarg freq) { x->x_incr = freq * x->x_fact; if(x->x_incr < 0.0f) x->x_incr = 0.0f; else if(x->x_incr > 0.1f) x->x_incr = 0.1f; }
static void LFO_noise_tilde_dsp(t_LFO_noise_tilde *x, t_signal **sp) { x->x_fact = 2.0f / sp[0]->s_sr; dsp_add(LFO_noise_tilde_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); }
void LFO_noise_tilde_setup(void) { LFO_noise_tilde_class = class_new(gensym("LFO_noise~"), (t_newmethod)LFO_noise_tilde_new, 0, sizeof(t_LFO_noise_tilde), 0, A_DEFFLOAT, 0); class_addmethod(LFO_noise_tilde_class, (t_method)LFO_noise_tilde_dsp, gensym("dsp"), 0); class_addfloat(LFO_noise_tilde_class, (t_method)LFO_noise_tilde_float); // class_sethelpsymbol(LFO_noise_tilde_class, gensym("iemhelp/help-LFO_noise~")); }
--- NEW FILE: exp_inc.c --- /* 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 - 2006 */
#include "m_pd.h" #include "iemlib.h"
/* ------------------------ exp_inc ---------------------------- */ /* ------- exponetial/linear-incremental-bang-counter ---------- */
static t_class *exp_inc_class;
typedef struct _exp_inc { t_object x_obj; t_float x_initialval; t_float x_currentval; t_float x_mulfactor; t_float x_addincrement; t_float x_min; t_float x_max; } t_exp_inc;
static void exp_inc_bang(t_exp_inc *x) { outlet_float(x->x_obj.ob_outlet, x->x_currentval); x->x_currentval = x->x_currentval * x->x_mulfactor + x->x_addincrement; if(x->x_currentval < x->x_min) x->x_currentval = x->x_min; if(x->x_currentval > x->x_max) x->x_currentval = x->x_max; }
static void exp_inc_reset(t_exp_inc *x) { x->x_currentval = x->x_initialval; if(x->x_currentval < x->x_min) x->x_currentval = x->x_min; if(x->x_currentval > x->x_max) x->x_currentval = x->x_max; }
static void exp_inc_float(t_exp_inc *x, t_floatarg f) { x->x_initialval = (t_float)f; x->x_currentval = x->x_initialval; if(x->x_currentval < x->x_min) x->x_currentval = x->x_min; if(x->x_currentval > x->x_max) x->x_currentval = x->x_max; }
static void exp_inc_ft1(t_exp_inc *x, t_floatarg f) { x->x_mulfactor = 1.0 + 0.01*(t_float)f; }
static void exp_inc_ft2(t_exp_inc *x, t_floatarg f) { x->x_addincrement = (t_float)f; }
static void exp_inc_ft3(t_exp_inc *x, t_floatarg f) { x->x_min = (t_float)f; if(x->x_currentval < x->x_min) x->x_currentval = x->x_min; }
static void exp_inc_ft4(t_exp_inc *x, t_floatarg f) { x->x_max = (t_float)f; if(x->x_currentval > x->x_max) x->x_currentval = x->x_max; }
static void exp_inc_list(t_exp_inc *x, t_symbol *s, int ac, t_atom *av) { if((ac == 5)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1)&&IS_A_FLOAT(av,2) &&IS_A_FLOAT(av,3)&&IS_A_FLOAT(av,4)) { exp_inc_ft4(x, atom_getfloatarg(4, ac, av)); exp_inc_ft3(x, atom_getfloatarg(3, ac, av)); exp_inc_ft2(x, atom_getfloatarg(2, ac, av)); exp_inc_ft1(x, atom_getfloatarg(1, ac, av)); exp_inc_float(x, atom_getfloatarg(0, ac, av)); } }
static void *exp_inc_new(t_symbol *s, int ac, t_atom *av) { t_exp_inc *x = (t_exp_inc *)pd_new(exp_inc_class);
x->x_currentval = 10.0; x->x_mulfactor = 1.0; x->x_addincrement = 0.0; x->x_min = 0.0; x->x_max = 1000.0; if((ac == 5)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1)&&IS_A_FLOAT(av,2) &&IS_A_FLOAT(av,3)&&IS_A_FLOAT(av,4)) { exp_inc_ft4(x, atom_getfloatarg(4, ac, av)); exp_inc_ft3(x, atom_getfloatarg(3, ac, av)); exp_inc_ft2(x, atom_getfloatarg(2, ac, av)); exp_inc_ft1(x, atom_getfloatarg(1, ac, av)); exp_inc_float(x, atom_getfloatarg(0, ac, av)); } outlet_new(&x->x_obj, &s_float); 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")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft3")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft4")); return (x); }
void exp_inc_setup(void) { exp_inc_class = class_new(gensym("exp_inc"), (t_newmethod)exp_inc_new, 0, sizeof(t_exp_inc), 0, A_GIMME, 0); class_addbang(exp_inc_class, exp_inc_bang); class_addlist(exp_inc_class, (t_method)exp_inc_list); class_addmethod(exp_inc_class, (t_method)exp_inc_reset, gensym("reset"), 0); class_addfloat(exp_inc_class, (t_method)exp_inc_float); class_addmethod(exp_inc_class, (t_method)exp_inc_ft1, gensym("ft1"), A_FLOAT, 0); class_addmethod(exp_inc_class, (t_method)exp_inc_ft2, gensym("ft2"), A_FLOAT, 0); class_addmethod(exp_inc_class, (t_method)exp_inc_ft3, gensym("ft3"), A_FLOAT, 0); class_addmethod(exp_inc_class, (t_method)exp_inc_ft4, gensym("ft4"), A_FLOAT, 0); // class_sethelpsymbol(exp_inc_class, gensym("iemhelp/help-exp_inc")); }
--- NEW FILE: dollarg.c --- /* 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 - 2006 */
#include "m_pd.h" #include "g_canvas.h" #include "iemlib.h"
/* ------------------------- dollarg ---------------------------- */ /* --- dollar-arguments, output the initial-arguments and the --- */ /* ------- number of them of the parent abstraction-patch ------- */
static t_class *dollarg_class;
typedef struct _dollarg { t_object x_obj; void *x_outlet_ac; t_atom *x_at; int x_ac; } t_dollarg;
static void dollarg_float(t_dollarg *x, t_floatarg f) { int i = (int)f;
if(!i) { outlet_float(x->x_outlet_ac, x->x_ac); if(x->x_ac) outlet_list(x->x_obj.ob_outlet, &s_list, x->x_ac, x->x_at); } else if(i > 0) { if(i <= x->x_ac) { outlet_float(x->x_outlet_ac, i); if(IS_A_FLOAT(x->x_at, i-1)) outlet_float(x->x_obj.ob_outlet, atom_getfloatarg(i-1, x->x_ac, x->x_at)); else if(IS_A_SYMBOL(x->x_at, i-1)) outlet_symbol(x->x_obj.ob_outlet, atom_getsymbolarg(i-1, x->x_ac, x->x_at)); } else outlet_float(x->x_outlet_ac, 0); } else { int j = x->x_ac + i;
if(j >= 0) { outlet_float(x->x_outlet_ac, j+1); if(IS_A_FLOAT(x->x_at, j)) outlet_float(x->x_obj.ob_outlet, atom_getfloatarg(j, x->x_ac, x->x_at)); else if(IS_A_SYMBOL(x->x_at, j)) outlet_symbol(x->x_obj.ob_outlet, atom_getsymbolarg(j, x->x_ac, x->x_at)); } else outlet_float(x->x_outlet_ac, 0); } }
static void dollarg_bang(t_dollarg *x) { dollarg_float(x, 0.0f); }
static void dollarg_free(t_dollarg *x) { if(x->x_ac) freebytes(x->x_at, x->x_ac * sizeof(t_atom)); }
static void *dollarg_new(void) { t_dollarg *x = (t_dollarg *)pd_new(dollarg_class); t_glist *glist=(t_glist *)canvas_getcurrent(); t_canvas *canvas=glist_getcanvas(glist); int pargc; t_atom *pargv, *at;
canvas_setcurrent(canvas); canvas_getargs(&pargc, &pargv); canvas_unsetcurrent(canvas); x->x_at = (t_atom *)getbytes(pargc*sizeof(t_atom)); x->x_ac = pargc; at = x->x_at; while(pargc--) *at++ = *pargv++; outlet_new(&x->x_obj, &s_list); x->x_outlet_ac = outlet_new(&x->x_obj, &s_float); return (x); }
void dollarg_setup(void) { dollarg_class = class_new(gensym("dollarg"), (t_newmethod)dollarg_new, (t_method)dollarg_free, sizeof(t_dollarg), 0, 0); class_addcreator((t_newmethod)dollarg_new, gensym("$n"), 0); class_addbang(dollarg_class, (t_method)dollarg_bang); class_addfloat(dollarg_class, (t_method)dollarg_float); // class_sethelpsymbol(dollarg_class, gensym("iemhelp/help-dollarg")); }
--- NEW FILE: bpe.c --- /* 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 - 2006 */
#include "m_pd.h" #include "iemlib.h"
/* --------------------------- bpe -------------------------------- */ /* -- break-point-envelope, convert a list of value-time-doubles -- */ /* ------- into a time-scheduled stream of value-time-pairs ------- */
static t_class *bpe_class;
typedef struct _bpe { t_object x_obj; t_clock *x_clock; int x_maxnum; int x_curnum; int x_curindex; t_atom *x_beg; void *x_out_val; void *x_out_time; void *x_out_finished; } t_bpe;
static void bpe_stop(t_bpe *x) { clock_unset(x->x_clock); }
static void bpe_tick(t_bpe *x) { t_atom *vec = x->x_beg; t_float val, time;
if(x->x_curindex >= x->x_curnum) { bpe_stop(x); outlet_bang(x->x_out_finished); } else { vec += x->x_curindex; val = atom_getfloat(vec++); time = atom_getfloat(vec); outlet_float(x->x_out_time, time); outlet_float(x->x_out_val, val); x->x_curindex += 2; clock_delay(x->x_clock, time); } }
static void bpe_bang(t_bpe *x) { t_atom *vec = x->x_beg; t_float val, time;
if(x->x_curnum) { x->x_curindex = 2; val = atom_getfloat(vec++); time = atom_getfloat(vec); outlet_float(x->x_out_time, time); outlet_float(x->x_out_val, val); clock_delay(x->x_clock, time); } }
static void bpe_list(t_bpe *x, t_symbol *s, int ac, t_atom *av) { int n = ac & 0xfffffffe, i; t_atom *vec = x->x_beg; if(n > x->x_maxnum) { freebytes(x->x_beg, x->x_maxnum*sizeof(t_atom)); x->x_maxnum = 2 + n; x->x_beg = (t_atom *)getbytes(x->x_maxnum*sizeof(t_atom)); vec = x->x_beg; } x->x_curnum = n; for(i=0; i<n; i++) { *vec++ = *av++; } }
static void bpe_free(t_bpe *x) { freebytes(x->x_beg, x->x_maxnum*sizeof(t_atom)); clock_free(x->x_clock); }
static void *bpe_new(void) { t_bpe *x = (t_bpe *)pd_new(bpe_class);
x->x_curindex = 0; x->x_maxnum = 20; x->x_curnum = 0; x->x_beg = (t_atom *)getbytes(x->x_maxnum*sizeof(t_atom)); x->x_clock = clock_new(x, (t_method)bpe_tick); x->x_out_val = outlet_new(&x->x_obj, &s_float); x->x_out_time = outlet_new(&x->x_obj, &s_float); x->x_out_finished = outlet_new(&x->x_obj, &s_bang); return (x); }
void bpe_setup(void) { bpe_class = class_new(gensym("bpe"), (t_newmethod)bpe_new, (t_method)bpe_free, sizeof(t_bpe), 0, 0); class_addmethod(bpe_class, (t_method)bpe_stop, gensym("stop"), 0); class_addbang(bpe_class, bpe_bang); class_addlist(bpe_class, (t_method)bpe_list); // class_sethelpsymbol(bpe_class, gensym("iemhelp/help-bpe")); }