From c66a55dd1ba88e5e8a280dd24c31d593522cd769 Mon Sep 17 00:00:00 2001 From: Cyrille Henry Date: Sun, 11 Oct 2009 09:13:05 +0000 Subject: make few change in pmpd~, update examples. svn path=/trunk/externals/pmpd/; revision=12576 --- src/makefile | 2 +- src/pmpd~.c | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/makefile b/src/makefile index e0043c9..45f07bf 100644 --- a/src/makefile +++ b/src/makefile @@ -63,7 +63,7 @@ pd_linux: pmpd.pd_linux mass.pd_linux link.pd_linux mass2D.pd_linux link2D.pd_li LINUXCFLAGS = -fPIC -DPD -O2 -funroll-loops -fomit-frame-pointer \ -Wall -W -Wshadow -Wstrict-prototypes -Werror \ - -Wno-unused -Wno-parentheses -Wno-switch + -Wno-unused -Wno-parentheses -Wno-switch LINUXINCLUDE = -I../../src diff --git a/src/pmpd~.c b/src/pmpd~.c index 33cfe28..ce8f02d 100644 --- a/src/pmpd~.c +++ b/src/pmpd~.c @@ -268,7 +268,8 @@ void pmpd_tilde_mass(t_pmpd_tilde *x, t_float M, t_float posX) x->mass[x->nb_mass].posX = posX; x->mass[x->nb_mass].forceX = 0; - x->nb_mass++ ; + x->nb_mass++ ; + if (x->nb_mass == nb_max_mass) error("to many mass"); x->nb_mass = min ( nb_max_mass -1, x->nb_mass ); } @@ -281,7 +282,8 @@ void pmpd_tilde_link(t_pmpd_tilde *x, t_float mass_1, t_float mass_2, t_float K1 x->link[x->nb_link].K1 = K1; x->link[x->nb_link].D1 = D1; - x->nb_link++ ; + x->nb_link++ ; + if (x->nb_link == nb_max_link) error("to many link"); x->nb_link = min ( nb_max_link -1, x->nb_link ); } @@ -300,7 +302,8 @@ void pmpd_tilde_NLlink(t_pmpd_tilde *x, t_symbol *s, int argc, t_atom *argv) x->NLlink[x->nb_NLlink].Lmin = atom_getfloatarg(6, argc, argv); x->NLlink[x->nb_NLlink].Lmax = atom_getfloatarg(7, argc, argv); - x->nb_NLlink++ ; + x->nb_NLlink++ ; + if (x->nb_NLlink == nb_max_link) error("to many NLlink"); x->nb_NLlink = min ( nb_max_link -1, x->nb_NLlink ); } else @@ -315,7 +318,8 @@ void pmpd_tilde_inPos(t_pmpd_tilde *x, t_float nb_inlet, t_float mass_1, t_float x->inPos[x->nb_inPos].mass1 = &x->mass[max(0, min ( x->nb_mass, (int)mass_1))]; x->inPos[x->nb_inPos].influence = influence; - x->nb_inPos++; + x->nb_inPos++; + if (x->nb_inPos == nb_max_in) error("to many inPos"); x->nb_inPos = min ( nb_max_in - 1, x->nb_inPos ); } void pmpd_tilde_inForce(t_pmpd_tilde *x, t_float nb_inlet, t_float mass_1, t_float influence) @@ -326,7 +330,8 @@ void pmpd_tilde_inForce(t_pmpd_tilde *x, t_float nb_inlet, t_float mass_1, t_flo x->inForce[x->nb_inForce].mass1 = &x->mass[max(0, min ( x->nb_mass, (int)mass_1))]; x->inForce[x->nb_inForce].influence = influence; - x->nb_inForce++; + x->nb_inForce++; + if (x->nb_inForce == nb_max_in) error("to many inForce"); x->nb_inForce = min ( nb_max_in - 1, x->nb_inForce ); } @@ -338,7 +343,8 @@ void pmpd_tilde_outPos(t_pmpd_tilde *x, t_float nb_outlet, t_float mass_1, t_flo x->outPos[x->nb_outPos].mass1 = &x->mass[max(0, min ( x->nb_mass, (int)mass_1))]; x->outPos[x->nb_outPos].influence = influence; - x->nb_outPos++ ; + x->nb_outPos++ ; + if (x->nb_outPos == nb_max_out) error("to many outPos"); x->nb_outPos = min ( nb_max_out - 1, x->nb_outPos ); } @@ -350,7 +356,8 @@ void pmpd_tilde_outSpeed(t_pmpd_tilde *x, t_float nb_outlet, t_float mass_1, t_f x->outSpeed[x->nb_outSpeed].mass1 = &x->mass[max(0, min ( x->nb_mass, (int)mass_1))]; x->outSpeed[x->nb_outSpeed].influence = influence; - x->nb_outSpeed++ ; + x->nb_outSpeed++ ; + if (x->nb_outSpeed == nb_max_out) error("to many outSpeed"); x->nb_outSpeed = min ( nb_max_out - 1, x->nb_outSpeed ); } @@ -395,14 +402,14 @@ void pmpd_tilde_setup(void) { CLASS_MAINSIGNALIN(pmpd_tilde_class, t_pmpd_tilde, f); class_addbang(pmpd_tilde_class, pmpd_tilde_bang); - class_addfloat(pmpd_tilde_class, (t_method)pmpd_tilde_float); + class_addfloat(pmpd_tilde_class, (t_method)pmpd_tilde_float); class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_mass, gensym("mass"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_link, gensym("link"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_NLlink, gensym("NLlink"), A_GIMME, 0); - class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_inPos, gensym("inPos"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_inForce, gensym("inForce"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_outPos, gensym("outPos"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_outSpeed, gensym("outSpeed"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_inPos, gensym("inPos"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_inForce, gensym("inForce"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_outPos, gensym("outPos"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_outSpeed, gensym("outSpeed"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_posX, gensym("posX"), A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_forceX, gensym("forceX"), A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(pmpd_tilde_class, (t_method)pmpd_tilde_reset, gensym("reset"), 0); -- cgit v1.2.1