aboutsummaryrefslogtreecommitdiff
path: root/pmpd_set.c
diff options
context:
space:
mode:
Diffstat (limited to 'pmpd_set.c')
-rw-r--r--pmpd_set.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/pmpd_set.c b/pmpd_set.c
index 4234345..03d3225 100644
--- a/pmpd_set.c
+++ b/pmpd_set.c
@@ -338,6 +338,71 @@ void pmpd_setL(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
+void pmpd_addL(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int tmp, i;
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+ t_float K;
+
+ 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));
+ x->link[tmp].L += atom_getfloatarg(1, argc, argv);
+ }
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
+ {
+ for (i=0; i< x->nb_link; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
+ {
+ x->link[i].L += atom_getfloatarg(1, argc, argv);
+ }
+ }
+ }
+ else if ( ( argv[0].a_type == A_FLOAT ) && ( argc == 1 ) )
+ {
+ tmp = atom_getfloatarg(0, argc, argv);
+ tmp = max(0, min( x->nb_link-1, tmp));
+ x->link[tmp].L += x->link[tmp].mass2->posX - x->link[tmp].mass1->posX;
+ }
+ else if ( ( argv[0].a_type == A_SYMBOL ) && ( argc == 1 ) )
+ {
+ for (i=0; i< x->nb_link; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
+ {
+ x->link[i].L += x->link[i].mass2->posX - x->link[i].mass1->posX;
+ }
+ }
+ }
+ else if ( (argc >= 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ K=1;
+ if ((argc >= 3) && ( argv[2].a_type == A_FLOAT )) K=atom_getfloatarg(2, argc, argv);
+ 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 += K*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)
{
int tmp, i;