From 50ba42ea6e9d51a90fd5d68e21b0021b2fcaa228 Mon Sep 17 00:00:00 2001 From: Cyrille Henry Date: Thu, 23 Jan 2014 15:11:46 +0000 Subject: add possibility to change few parametter with table, so that many parametter are set at diferent value with the same message. svn path=/trunk/externals/pmpd/; revision=17247 --- pmpd_set.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 4 deletions(-) (limited to 'pmpd_set.c') diff --git a/pmpd_set.c b/pmpd_set.c index ae166ac..830cb87 100644 --- a/pmpd_set.c +++ b/pmpd_set.c @@ -1,7 +1,10 @@ void pmpd_setK(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) { int tmp, i; - + t_garray *a; + int npoints, n; + t_word *vec; + if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) { tmp = atom_getfloatarg(0, argc, argv); @@ -18,12 +21,37 @@ void pmpd_setK(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) } } } + if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) ) + { + if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class))) + pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name); + else if (!garray_getfloatwords(a, &npoints, &vec)) + pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name); + else + { + n=0; + for (i=0; i < x->nb_link; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + x->link[i].K = vec[n].w_float; + // post("linkK %d = table %d : %f", i, n, vec[n].w_float); + n++; + if (n >= npoints) break; + } + } + } + } } + void pmpd_setD(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) { int tmp, i; - + t_garray *a; + int npoints, n; + t_word *vec; + if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) { tmp = atom_getfloatarg(0, argc, argv); @@ -40,12 +68,36 @@ void pmpd_setD(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) } } } + if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) ) + { + if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class))) + pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name); + else if (!garray_getfloatwords(a, &npoints, &vec)) + pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name); + else + { + n=0; + for (i=0; i < x->nb_link; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + x->link[i].D = vec[n].w_float; + // post("linkD %d = table %d : %f", i, n, vec[n].w_float); + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd_setD2(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) { int tmp, i; - + t_garray *a; + int npoints, n; + t_word *vec; + if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) { tmp = atom_getfloatarg(0, argc, argv); @@ -69,13 +121,37 @@ void pmpd_setD2(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) x->mass[i].D2 = atom_getfloatarg(0, argc, argv); } } + if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) ) + { + if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class))) + pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name); + else if (!garray_getfloatwords(a, &npoints, &vec)) + pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name); + else + { + n=0; + for (i=0; i < x->nb_link; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + x->link[i].K = vec[n].w_float; + // post("linkD2 %d = table %d : %f", i, n, vec[n].w_float); + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd_setL(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) { int tmp, i; - + t_garray *a; + int npoints, n; + t_word *vec; + if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) { tmp = atom_getfloatarg(0, argc, argv); @@ -108,6 +184,27 @@ void pmpd_setL(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) } } } + if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) ) + { + if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class))) + pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name); + else if (!garray_getfloatwords(a, &npoints, &vec)) + pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name); + else + { + n=0; + for (i=0; i < x->nb_link; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + x->link[i].L = vec[n].w_float; + // post("linkL %d = table %d : %f", i, n, vec[n].w_float); + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd_setLCurrent(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) -- cgit v1.2.1