diff options
Diffstat (limited to 'pmpd2d_set.c')
-rw-r--r-- | pmpd2d_set.c | 213 |
1 files changed, 196 insertions, 17 deletions
diff --git a/pmpd2d_set.c b/pmpd2d_set.c index d958bda..eecf730 100644 --- a/pmpd2d_set.c +++ b/pmpd2d_set.c @@ -1,6 +1,7 @@ void pmpd2d_setK(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i, offset; + int tmp, end, i, offset; + t_float valeur; t_garray *a; int npoints, n; t_word *vec; @@ -12,6 +13,16 @@ void pmpd2d_setK(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].K = atom_getfloatarg(1, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + for (i=tmp; i<=end; i++) + x->link[i].K = valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_link; i++) @@ -66,7 +77,8 @@ void pmpd2d_setK(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setD(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i, offset; + int tmp, end, i, offset; + t_float valeur; t_garray *a; int npoints, n; t_word *vec; @@ -78,6 +90,16 @@ void pmpd2d_setD(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].D = atom_getfloatarg(1, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + for (i=tmp; i<=end; i++) + x->link[i].D = valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_link; i++) @@ -133,7 +155,8 @@ void pmpd2d_setD(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setPow(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i, offset; + int tmp, end, i, offset; + t_float valeur; t_garray *a; int npoints, n; t_word *vec; @@ -145,6 +168,16 @@ void pmpd2d_setPow(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].Pow = atom_getfloatarg(1, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + for (i=tmp; i<=end; i++) + x->link[i].Pow = valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_link; i++) @@ -199,7 +232,8 @@ void pmpd2d_setPow(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setDEnv(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i, offset; + int tmp, end, i, offset; + t_float valeur; t_garray *a; int npoints, n; t_word *vec; @@ -211,6 +245,16 @@ void pmpd2d_setDEnv(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_mass-1, tmp)); x->mass[tmp].D2 = atom_getfloatarg(1, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_mass-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_mass-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + for (i=tmp; i<=end; i++) + x->mass[i].D2 = valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_mass; i++) @@ -272,7 +316,8 @@ void pmpd2d_setDEnv(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setDEnvOffset(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i, offset; + int tmp, end, i, offset; + t_float valeur; t_garray *a; int npoints, n; t_word *vec; @@ -284,6 +329,16 @@ void pmpd2d_setDEnvOffset(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_mass-1, tmp)); x->mass[tmp].D2offset = atom_getfloatarg(0, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_mass-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_mass-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + for (i=tmp; i<=end; i++) + x->mass[i].D2offset = valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_mass; i++) @@ -345,7 +400,8 @@ void pmpd2d_setDEnvOffset(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i, offset; + int tmp, end, i, offset; + t_float valeur; t_garray *a; int npoints, n; t_word *vec; @@ -357,6 +413,16 @@ void pmpd2d_setL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].L = atom_getfloatarg(1, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + for (i=tmp; i<=end; i++) + x->link[i].L = valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { // set a class of link to a specific length for (i=0; i< x->nb_link; i++) @@ -427,7 +493,8 @@ void pmpd2d_setL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_addL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i, offset; + int tmp, end, i, offset; + t_float valeur; t_garray *a; int npoints, n; t_word *vec; @@ -439,6 +506,16 @@ void pmpd2d_addL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].L += atom_getfloatarg(1, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + for (i=tmp; i<=end; i++) + x->link[i].L += valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { // set a class of link to a specific length for (i=0; i< x->nb_link; i++) @@ -509,7 +586,8 @@ void pmpd2d_addL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setLCurrent(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i; + int tmp, i, end; + t_float valeur; if ( ( argc == 1 ) && ( argv[0].a_type == A_FLOAT ) ) { // set a link to it's current length @@ -533,6 +611,16 @@ void pmpd2d_setLCurrent(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) i = max(0, min( x->nb_link-1, i)); x->link[i].L = mix(x->link[i].L,x->link[i].distance,atom_getfloatarg(1, argc, argv)); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + for (i=tmp; i<=end; i++) + x->link[i].L = mix(x->link[i].L,x->link[i].distance,valeur); + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { // set a class of link to a mix between it's curent length and it's size for (i=0; i< x->nb_link; i++) @@ -547,7 +635,9 @@ void pmpd2d_setLCurrent(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setLKTab(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i; + int tmp, end, i; + t_float valeur; + t_float K_l = atom_getfloatarg(1, argc, argv); if (K_l <= 0) K_l = 1; if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) @@ -556,6 +646,17 @@ void pmpd2d_setLKTab(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].K_L = K_l; } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + if (valeur <= 0) valeur = 1; + for (i=tmp; i<=end; i++) + x->link[i].K_L = valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_link; i++) @@ -570,7 +671,9 @@ void pmpd2d_setLKTab(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setLDTab(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i; + int tmp, end, i; + t_float valeur; + t_float D_l = atom_getfloatarg(1, argc, argv); if (D_l <= 0) D_l = 1; if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) @@ -579,6 +682,17 @@ void pmpd2d_setLDTab(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].D_L = D_l; } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + if (valeur <= 0) valeur = 1; + for (i=tmp; i<=end; i++) + x->link[i].D_L = valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_link; i++) @@ -593,7 +707,7 @@ void pmpd2d_setLDTab(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setLinkId(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i; + int tmp, end, i; if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_SYMBOL ) ) { @@ -601,6 +715,15 @@ void pmpd2d_setLinkId(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].Id = atom_getsymbolarg(1, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_SYMBOL ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + for (i=tmp; i<=end; i++) + x->link[i].Id = atom_getsymbolarg(1, argc, argv); + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) ) { for (i=0; i< x->nb_link; i++) @@ -615,7 +738,7 @@ void pmpd2d_setLinkId(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setMassId(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i; + int tmp, end, i; if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_SYMBOL ) ) { @@ -623,6 +746,15 @@ void pmpd2d_setMassId(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_mass-1, tmp)); x->mass[tmp].Id = atom_getsymbolarg(1, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_SYMBOL ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_mass-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_mass-1, end)); + for (i=tmp; i<=end; i++) + x->mass[i].Id = atom_getsymbolarg(1, argc, argv); + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) ) { for (i=0; i< x->nb_mass; i++) @@ -637,7 +769,7 @@ void pmpd2d_setMassId(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setFixed(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i; + int tmp, end, i; if ( (argc == 1) && (argv[0].a_type == A_FLOAT ) ) { @@ -645,6 +777,15 @@ void pmpd2d_setFixed(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_mass-1, tmp)); x->mass[tmp].mobile = 0; } + else if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_mass-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_mass-1, end)); + for (i=tmp; i<=end; i++) + x->mass[i].mobile = 0; + } else if ( (argc == 1) && (argv[0].a_type == A_SYMBOL ) ) { for (i=0; i< x->nb_mass; i++) @@ -659,7 +800,7 @@ void pmpd2d_setFixed(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setMobile(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i; + int tmp, end, i; if ( (argc == 1) && (argv[0].a_type == A_FLOAT ) ) { @@ -667,6 +808,15 @@ void pmpd2d_setMobile(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_mass-1, tmp)); x->mass[tmp].mobile = 1; } + else if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_mass-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_mass-1, end)); + for (i=tmp; i<=end; i++) + x->mass[i].mobile = 0; + } else if ( (argc == 1) && (argv[0].a_type == A_SYMBOL ) ) { for (i=0; i< x->nb_mass; i++) @@ -827,7 +977,7 @@ void pmpd2d_setActivei(t_pmpd2d *x, int i) void pmpd2d_setActive(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i; + int tmp, end, i; if ( (argc == 1) && ( argv[0].a_type == A_FLOAT ) ) { @@ -835,6 +985,15 @@ void pmpd2d_setActive(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); pmpd2d_setActivei(x,tmp); } + else if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + for (i=tmp; i<=end; i++) + pmpd2d_setActivei(x,i); + } else if ( (argc == 1) && ( argv[0].a_type == A_SYMBOL ) ) { for (i=0; i< x->nb_link; i++) @@ -856,7 +1015,7 @@ void pmpd2d_setActive(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) void pmpd2d_setInactive(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) { - int tmp, i; + int tmp, end, i; if ( (argc == 1) && ( argv[0].a_type == A_FLOAT ) ) { @@ -864,6 +1023,15 @@ void pmpd2d_setInactive(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].active = 0; } + else if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_link-1, end)); + for (i=tmp; i<=end; i++) + x->link[i].active = 0; + } else if ( (argc == 1) && ( argv[0].a_type == A_SYMBOL ) ) { for (i=0; i< x->nb_link; i++) @@ -1127,7 +1295,8 @@ void pmpd2d_posY(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) 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_int tmp, end, i; + t_float valeur; t_garray *a; int npoints, n; t_word *vec; @@ -1139,6 +1308,16 @@ void pmpd2d_overdamp(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_mass-1, tmp)); x->mass[tmp].overdamp = atom_getfloatarg(1, argc, argv); } + else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_mass-1, tmp)); + end = atom_getfloatarg(1, argc, argv); + end = max(tmp, min( x->nb_mass-1, end)); + valeur = atom_getfloatarg(2, argc, argv); + for (i=tmp; i<=end; i++) + x->mass[i].overdamp = valeur; + } else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_mass; i++) |