diff options
author | Cyrille Henry <nusmuk@users.sourceforge.net> | 2014-01-23 15:11:46 +0000 |
---|---|---|
committer | Cyrille Henry <nusmuk@users.sourceforge.net> | 2014-01-23 15:11:46 +0000 |
commit | 50ba42ea6e9d51a90fd5d68e21b0021b2fcaa228 (patch) | |
tree | 4c38ba91e2afd99b242fa791c3dd195af040b88d | |
parent | b9498ede7b3191523ab34caed48602a5d4ce10de (diff) |
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
-rw-r--r-- | pmpd2d_set.c | 150 | ||||
-rw-r--r-- | pmpd3d_set.c | 140 | ||||
-rw-r--r-- | pmpd_set.c | 105 |
3 files changed, 384 insertions, 11 deletions
diff --git a/pmpd2d_set.c b/pmpd2d_set.c index 1e1c9fc..65ffc5f 100644 --- a/pmpd2d_set.c +++ b/pmpd2d_set.c @@ -1,7 +1,10 @@ void pmpd2d_setK(t_pmpd2d *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,35 @@ void pmpd2d_setK(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) } } } + else 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; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd2d_setD(t_pmpd2d *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 +66,35 @@ void pmpd2d_setD(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) } } } + else 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; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd2d_setDEnv(t_pmpd2d *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,12 +118,35 @@ void pmpd2d_setDEnv(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) x->mass[i].D2 = atom_getfloatarg(0, argc, argv); } } + else 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_mass; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) + { + x->mass[i].D2 = vec[n].w_float; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd2d_setDEnvOffset(t_pmpd2d *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); @@ -98,12 +170,35 @@ void pmpd2d_setDEnvOffset(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) x->mass[i].D2offset = atom_getfloatarg(0, argc, argv); } } + else 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_mass; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) + { + x->mass[i].D2offset = vec[n].w_float; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd2d_setL(t_pmpd2d *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 ) ) { // set a link to a specific length tmp = atom_getfloatarg(0, argc, argv); @@ -136,6 +231,26 @@ void pmpd2d_setL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) } } } + else 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; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd2d_setLCurrent(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) @@ -608,7 +723,10 @@ void pmpd2d_overdamp(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { // set the overdamped factor to a mass t_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); @@ -625,6 +743,26 @@ void pmpd2d_overdamp(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) } } } + else 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_mass; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) + { + x->mass[i].overdamp = vec[n].w_float; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd2d_setConnection1i(t_pmpd2d *x, int i, int j) diff --git a/pmpd3d_set.c b/pmpd3d_set.c index 769a1b9..ba2b3e4 100644 --- a/pmpd3d_set.c +++ b/pmpd3d_set.c @@ -1,7 +1,10 @@ void pmpd3d_setK(t_pmpd3d *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,11 +21,34 @@ void pmpd3d_setK(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } } + else 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; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd3d_setD(t_pmpd3d *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 ) ) { @@ -40,11 +66,34 @@ void pmpd3d_setD(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } } + else 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; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd3d_setDEnv(t_pmpd3d *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 ) ) { @@ -69,11 +118,34 @@ void pmpd3d_setDEnv(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) x->mass[i].D2 = atom_getfloatarg(0, argc, argv); } } + else 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_mass; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) + { + x->mass[i].D2 = vec[n].w_float; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd3d_setDEnvOffset(t_pmpd3d *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 ) ) { @@ -98,11 +170,34 @@ void pmpd3d_setDEnvOffset(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) x->mass[i].D2offset = atom_getfloatarg(0, argc, argv); } } + else 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_mass; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) + { + x->mass[i].D2offset = vec[n].w_float; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd3d_setL(t_pmpd3d *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 ) ) { // set a link to a specific size @@ -136,6 +231,26 @@ void pmpd3d_setL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } } + else 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; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd3d_setLCurrent(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) @@ -691,6 +806,9 @@ void pmpd3d_overdamp(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { // set the overdamped factor to a mass t_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 ) ) { @@ -708,6 +826,26 @@ void pmpd3d_overdamp(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } } + else 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_mass; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) + { + x->mass[i].overdamp = vec[n].w_float; + n++; + if (n >= npoints) break; + } + } + } + } } void pmpd3d_setConnection1i(t_pmpd3d *x, int i, int j) @@ -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) |