aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Henry <nusmuk@users.sourceforge.net>2014-06-10 13:30:44 +0000
committerCyrille Henry <nusmuk@users.sourceforge.net>2014-06-10 13:30:44 +0000
commit398be306c1080d20b2399ccaa0f5ad6d15073a6c (patch)
tree5f5c30d322fc971971989eccffd6d4ad2100e21c
parent2ee9935535a98c91c1123eac0da9dc0414c71a08 (diff)
add setPow function
svn path=/trunk/externals/pmpd/; revision=17319
-rw-r--r--pmpd.c1
-rw-r--r--pmpd2d.c1
-rw-r--r--pmpd2d_set.c67
-rw-r--r--pmpd3d.c1
-rw-r--r--pmpd3d_set.c88
-rw-r--r--pmpd_set.c66
6 files changed, 224 insertions, 0 deletions
diff --git a/pmpd.c b/pmpd.c
index 459dec4..f70bdce 100644
--- a/pmpd.c
+++ b/pmpd.c
@@ -69,6 +69,7 @@ void pmpd_setup(void)
*/
class_addmethod(pmpd_class, (t_method)pmpd_setK, gensym("setK"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_setD, gensym("setD"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_setPow, gensym("setPow"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_setD2, gensym("setDEnv"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_setL, gensym("setL"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_setLCurrent, gensym("setLCurrent"), A_GIMME, 0);
diff --git a/pmpd2d.c b/pmpd2d.c
index eb0bdd9..a401c24 100644
--- a/pmpd2d.c
+++ b/pmpd2d.c
@@ -72,6 +72,7 @@ void pmpd2d_setup(void)
class_addmethod(pmpd2d_class, (t_method)pmpd2d_setK, gensym("setK"), A_GIMME, 0);
class_addmethod(pmpd2d_class, (t_method)pmpd2d_setD, gensym("setD"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_setPow, gensym("setPow"), A_GIMME, 0);
class_addmethod(pmpd2d_class, (t_method)pmpd2d_setDEnv, gensym("setDEnv"), A_GIMME, 0);
class_addmethod(pmpd2d_class, (t_method)pmpd2d_setDEnvOffset, gensym("setDEnvOffset"), A_GIMME, 0);
class_addmethod(pmpd2d_class, (t_method)pmpd2d_setL, gensym("setL"), A_GIMME, 0);
diff --git a/pmpd2d_set.c b/pmpd2d_set.c
index 8d1dfcb..f415221 100644
--- a/pmpd2d_set.c
+++ b/pmpd2d_set.c
@@ -130,6 +130,73 @@ 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;
+ 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].Pow = 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].Pow = atom_getfloatarg(1, argc, 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_link; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
+ {
+ x->link[i].Pow = K*vec[n].w_float;
+ 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_link-atom_getfloatarg(1, argc, argv));
+ for (i=0; i < n; i++)
+ {
+ x->link[i+offset].Pow = K*vec[i].w_float;
+ }
+ }
+ }
+}
+
void pmpd2d_setDEnv(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
{
int tmp, i, offset;
diff --git a/pmpd3d.c b/pmpd3d.c
index 82de7dd..f94ea93 100644
--- a/pmpd3d.c
+++ b/pmpd3d.c
@@ -72,6 +72,7 @@ void pmpd3d_setup(void)
*/
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setK, gensym("setK"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setD, gensym("setD"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setPow, gensym("setPow"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setDEnv, gensym("setDEnv"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setDEnvOffset, gensym("setDEnvOffset"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setL, gensym("setL"), A_GIMME, 0);
diff --git a/pmpd3d_set.c b/pmpd3d_set.c
index 755d2d2..296c94b 100644
--- a/pmpd3d_set.c
+++ b/pmpd3d_set.c
@@ -174,6 +174,94 @@ void pmpd3d_setD(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
+void pmpd3d_setPow(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int tmp, i, offset;
+ 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].Pow = 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].Pow = atom_getfloatarg(1, argc, 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_link; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
+ {
+ x->link[i].Pow = K*vec[n].w_float;
+ n++;
+ if (n >= npoints) break;
+ }
+ }
+ }
+ }
+ 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].Pow = K*vec[n].w_float;
+ 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_link-atom_getfloatarg(1, argc, argv));
+ for (i=0; i < n; i++)
+ {
+ x->link[i+offset].K = K*vec[i].w_float;
+ }
+ }
+ }
+}
+
void pmpd3d_setDEnv(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
int tmp, i, offset;
diff --git a/pmpd_set.c b/pmpd_set.c
index f6e40b0..4234345 100644
--- a/pmpd_set.c
+++ b/pmpd_set.c
@@ -132,6 +132,72 @@ void pmpd_setD(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+void pmpd_setPow(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int tmp, i, offset;
+ 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].Pow = atom_getfloatarg(1, argc, argv);
+ }
+ 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].Pow = atom_getfloatarg(1, argc, argv);
+ }
+ }
+ }
+ 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].Pow = K*vec[n].w_float;
+ // post("linkK %d = table %d : %f", i, n, vec[n].w_float);
+ 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_link-atom_getfloatarg(1, argc, argv));
+ for (i=0; i < n; i++)
+ {
+ x->link[i+offset].Pow = K*vec[i].w_float;
+ }
+ }
+ }
+}
void pmpd_setD2(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{