aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pmpd2d_set.c51
-rw-r--r--pmpd3d_set.c68
-rw-r--r--pmpd_set.c111
3 files changed, 162 insertions, 68 deletions
diff --git a/pmpd2d_set.c b/pmpd2d_set.c
index 4f52839..8d1dfcb 100644
--- a/pmpd2d_set.c
+++ b/pmpd2d_set.c
@@ -54,7 +54,7 @@ void pmpd2d_setK(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_link-atom_getfloatarg(1, argc, argv));
for (i=0; i < n; i++)
{
@@ -120,7 +120,7 @@ void pmpd2d_setD(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_link-atom_getfloatarg(1, argc, argv));
for (i=0; i < n; i++)
{
@@ -193,7 +193,7 @@ void pmpd2d_setDEnv(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_mass-atom_getfloatarg(1, argc, argv));
for (i=0; i < n; i++)
{
@@ -215,7 +215,7 @@ void pmpd2d_setDEnvOffset(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
{
tmp = atom_getfloatarg(0, argc, argv);
tmp = max(0, min( x->nb_mass-1, tmp));
- x->mass[tmp].D2offset = atom_getfloatarg(1, argc, argv);
+ x->mass[tmp].D2offset = atom_getfloatarg(0, argc, argv);
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
{
@@ -266,7 +266,7 @@ void pmpd2d_setDEnvOffset(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_mass-atom_getfloatarg(1, argc, argv));
for (i=0; i < n; i++)
{
@@ -348,7 +348,7 @@ void pmpd2d_setL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_link-atom_getfloatarg(1, argc, argv));
for (i=0; i < n; i++)
{
@@ -809,17 +809,16 @@ void pmpd2d_pos(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min((int)npoints/2,x->nb_mass-offset);
- n+=offset;
- for (i=offset; i < n; i++)
+ for (i=0; i < n; i++)
{
- x->mass[i].posX = K*vec[2*i].w_float;
- x->mass[i].posY = K*vec[2*i+1].w_float;
- x->mass[i].speedX = 0;
- x->mass[i].forceX = 0;
- x->mass[i].speedY = 0;
- x->mass[i].forceY = 0;
+ x->mass[i+offset].posX = K*vec[2*i].w_float;
+ x->mass[i+offset].speedX = 0;
+ x->mass[i+offset].forceX = 0;
+ x->mass[i+offset].posY = K*vec[2*i+1].w_float;
+ x->mass[i+offset].speedY = 0;
+ x->mass[i+offset].forceY = 0;
}
}
}
@@ -888,14 +887,13 @@ void pmpd2d_posX(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_mass-offset);
- n+=offset;
- for (i=offset; i < n; i++)
+ for (i=0; i < n; i++)
{
- x->mass[i].posX = K*vec[i].w_float;
- x->mass[i].speedX = 0;
- x->mass[i].forceX = 0;
+ x->mass[i+offset].posX = K*vec[i].w_float;
+ x->mass[i+offset].speedX = 0;
+ x->mass[i+offset].forceX = 0;
}
}
}
@@ -965,14 +963,13 @@ void pmpd2d_posY(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_mass-offset);
- n+=offset;
- for (i=offset; i < n; i++)
+ for (i=0; i < n; i++)
{
- x->mass[i].posY = K*vec[i].w_float;
- x->mass[i].speedY = 0;
- x->mass[i].forceY = 0;
+ x->mass[i+offset].posY = K*vec[i].w_float;
+ x->mass[i+offset].speedY = 0;
+ x->mass[i+offset].forceY = 0;
}
}
}
diff --git a/pmpd3d_set.c b/pmpd3d_set.c
index d65602e..755d2d2 100644
--- a/pmpd3d_set.c
+++ b/pmpd3d_set.c
@@ -76,7 +76,7 @@ void pmpd3d_setK(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_link-atom_getfloatarg(1, argc, argv));
for (i=0; i < n; i++)
{
@@ -164,7 +164,7 @@ void pmpd3d_setD(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_link-atom_getfloatarg(1, argc, argv));
for (i=0; i < n; i++)
{
@@ -259,7 +259,7 @@ void pmpd3d_setDEnv(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_mass-atom_getfloatarg(1, argc, argv));
for (i=0; i < n; i++)
{
@@ -281,7 +281,7 @@ void pmpd3d_setDEnvOffset(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
tmp = atom_getfloatarg(0, argc, argv);
tmp = max(0, min( x->nb_mass-1, tmp));
- x->mass[tmp].D2offset = atom_getfloatarg(1, argc, argv);
+ x->mass[tmp].D2offset = atom_getfloatarg(0, argc, argv);
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
{
@@ -354,7 +354,7 @@ void pmpd3d_setDEnvOffset(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_mass-atom_getfloatarg(1, argc, argv));
for (i=0; i < n; i++)
{
@@ -936,20 +936,19 @@ void pmpd3d_pos(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
- n=min((int)npoints/3,x->nb_mass-offset);
- n+=offset;
- for (i=offset; i < n; i++)
+ offset = atom_getfloatarg(0, argc, argv);
+ n=min((int)npoints/2,x->nb_mass-offset);
+ for (i=0; i < n; i++)
{
- x->mass[i].posX = K*vec[3*i].w_float;
- x->mass[i].posY = K*vec[3*i+1].w_float;
- x->mass[i].posZ = K*vec[3*i+2].w_float;
- x->mass[i].speedX = 0;
- x->mass[i].forceX = 0;
- x->mass[i].speedY = 0;
- x->mass[i].forceY = 0;
- x->mass[i].speedZ = 0;
- x->mass[i].forceZ = 0;
+ x->mass[i+offset].posX = K*vec[3*i].w_float;
+ x->mass[i+offset].speedX = 0;
+ x->mass[i+offset].forceX = 0;
+ x->mass[i+offset].posY = K*vec[3*i+1].w_float;
+ x->mass[i+offset].speedY = 0;
+ x->mass[i+offset].forceY = 0;
+ x->mass[i+offset].posZ = K*vec[3*i+1].w_float;
+ x->mass[i+offset].speedZ = 0;
+ x->mass[i+offset].forceZ = 0;
}
}
}
@@ -1020,14 +1019,13 @@ void pmpd3d_posX(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_mass-offset);
- n+=offset;
- for (i=offset; i < n; i++)
+ for (i=0; i < n; i++)
{
- x->mass[i].posX = K*vec[i].w_float;
- x->mass[i].speedX = 0;
- x->mass[i].forceX = 0;
+ x->mass[i+offset].posX = K*vec[i].w_float;
+ x->mass[i+offset].speedX = 0;
+ x->mass[i+offset].forceX = 0;
}
}
}
@@ -1097,14 +1095,13 @@ void pmpd3d_posY(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_mass-offset);
- n+=offset;
- for (i=offset; i < n; i++)
+ for (i=0; i < n; i++)
{
- x->mass[i].posY = K*vec[i].w_float;
- x->mass[i].speedY = 0;
- x->mass[i].forceY = 0;
+ x->mass[i+offset].posY = K*vec[i].w_float;
+ x->mass[i+offset].speedY = 0;
+ x->mass[i+offset].forceY = 0;
}
}
}
@@ -1174,14 +1171,13 @@ void pmpd3d_posZ(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
else
{
- offset = atom_getfloatarg(1, argc, argv);
+ offset = atom_getfloatarg(0, argc, argv);
n=min(npoints,x->nb_mass-offset);
- n+=offset;
- for (i=offset; i < n; i++)
+ for (i=0; i < n; i++)
{
- x->mass[i].posZ = K*vec[i].w_float;
- x->mass[i].speedZ = 0;
- x->mass[i].forceZ = 0;
+ x->mass[i+offset].posZ = K*vec[i].w_float;
+ x->mass[i+offset].speedZ = 0;
+ x->mass[i+offset].forceZ = 0;
}
}
}
diff --git a/pmpd_set.c b/pmpd_set.c
index 295413f..f6e40b0 100644
--- a/pmpd_set.c
+++ b/pmpd_set.c
@@ -1,6 +1,6 @@
void pmpd_setK(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{
- int tmp, i;
+ int tmp, i, offset;
t_garray *a;
int npoints, n;
t_word *vec;
@@ -45,12 +45,30 @@ void pmpd_setK(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+ else if ( (argc >= 2) && ( argv[0].a_type == A_FLOAT ) && ( 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
+ {
+ offset = atom_getfloatarg(0, argc, argv);
+ n=min(npoints,x->nb_link-atom_getfloatarg(1, argc, argv));
+ for (i=0; i < n; i++)
+ {
+ x->link[i+offset].K = K*vec[i].w_float;
+ }
+ }
+ }
}
void pmpd_setD(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{
- int tmp, i;
+ int tmp, i, offset;
t_garray *a;
int npoints, n;
t_word *vec;
@@ -95,11 +113,29 @@ void pmpd_setD(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+ else if ( (argc >= 2) && ( argv[0].a_type == A_FLOAT ) && ( 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
+ {
+ offset = atom_getfloatarg(0, argc, argv);
+ n=min(npoints,x->nb_link-atom_getfloatarg(1, argc, argv));
+ for (i=0; i < n; i++)
+ {
+ x->link[i+offset].D = K*vec[i].w_float;
+ }
+ }
+ }
}
void pmpd_setD2(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{
- int tmp, i;
+ int tmp, i, offset;
t_garray *a;
int npoints, n;
t_word *vec;
@@ -151,7 +187,24 @@ void pmpd_setD2(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
-
+ else if ( (argc >= 2) && ( argv[0].a_type == A_FLOAT ) && ( 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
+ {
+ offset = atom_getfloatarg(0, argc, argv);
+ n=min(npoints,x->nb_link-atom_getfloatarg(1, argc, argv));
+ for (i=0; i < n; i++)
+ {
+ x->link[i+offset].D = K*vec[i].w_float;
+ }
+ }
+ }
}
void pmpd_setL(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
@@ -502,7 +555,11 @@ void pmpd_setInactive(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
void pmpd_posX(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{
// displace a mass to a certain position
- int tmp, i;
+ int tmp, i, offset;
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+ t_float K;
if ( ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
@@ -526,6 +583,50 @@ void pmpd_posX(t_pmpd *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 ) )
+ {
+ 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_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ x->mass[i].posX = K*vec[n].w_float;
+ x->mass[i].speedX = 0;
+ x->mass[i].forceX = 0;
+ n++;
+ if (n >= npoints) break;
+ }
+ }
+ }
+ }
+ else if ( (argc >= 2) && ( argv[0].a_type == A_FLOAT ) && ( 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
+ {
+ offset = atom_getfloatarg(0, argc, argv);
+ n=min(npoints,x->nb_mass-offset);
+ for (i=0; i < n; i++)
+ {
+ x->mass[i+offset].posX = K*vec[i].w_float;
+ x->mass[i+offset].speedX = 0;
+ x->mass[i+offset].forceX = 0;
+ }
+ }
+ }
}
void pmpd_overdamp(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)