aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Henry <nusmuk@users.sourceforge.net>2015-01-01 10:45:44 +0000
committerCyrille Henry <nusmuk@users.sourceforge.net>2015-01-01 10:45:44 +0000
commitbb37da616233f5dc5b7b1cd7981f0ba0aeeb48c8 (patch)
tree06d618b4ca2e4d1dfa44b430d19db1847b6f6b37
parentcb35519b73e4f210eb41dbd44ab1181b0577f27e (diff)
optimisation
svn path=/trunk/externals/nusmuk/; revision=17396
-rw-r--r--nusmuk-utils/mtx_preset.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/nusmuk-utils/mtx_preset.c b/nusmuk-utils/mtx_preset.c
index afd681c..912d4c6 100644
--- a/nusmuk-utils/mtx_preset.c
+++ b/nusmuk-utils/mtx_preset.c
@@ -156,40 +156,28 @@ void mtx_preset_col(t_mtx_preset *x, t_symbol *s, int argc, t_atom *argv)
x->matrix[col][i] = atom_getfloatarg(i+1,argc,argv);
}
-void mtx_preset_setrow(t_mtx_preset *x, t_symbol *s, int argc, t_atom *argv)
+void mtx_preset_setrow(t_mtx_preset *x, t_float rowtoset, t_float value)
{
-// reception de row Y values...
-// TODO : optimized
+// reception de row Y value
int row, i;
- if ((argc > 0) && (argv[0].a_type == A_FLOAT))
- row = atom_getfloatarg(0,argc,argv);
- else {
- error("bad row");
- return;
- }
- row = min(x->sizeY, row);
+ row = min(x->sizeY, rowtoset);
+ row = max(0, row);
+
for (i=0; i < x->sizeX; i++)
- if ((argc > 1) && (argv[1].a_type == A_FLOAT))
- x->matrix[i][row] = atom_getfloatarg(1,argc,argv);
+ x->matrix[i][row] = value;
}
-void mtx_preset_setcol(t_mtx_preset *x, t_symbol *s, int argc, t_atom *argv)
+void mtx_preset_setcol(t_mtx_preset *x, t_float coltoset, t_float value)
{
-// reception de col X values...
-// TODO : optimized
+// reception de col X value
int col, i;
- if ((argc > 0) && (argv[0].a_type == A_FLOAT))
- col = atom_getfloatarg(0,argc,argv);
- else {
- error("bad col");
- return;
- }
- col = min(x->sizeX, col);
+ col = min(x->sizeX, coltoset);
+ col = max(0, col);
+
for (i=0; i < x->sizeY; i++)
- if ((argc > 1) && (argv[1].a_type == A_FLOAT))
- x->matrix[col][i] = atom_getfloatarg(1,argc,argv);
+ x->matrix[col][i] = value;
}
void mtx_preset_element(t_mtx_preset *x, t_float posX, t_float posY, t_float value)
@@ -283,9 +271,9 @@ void mtx_preset_setup(void) {
// row float float ... -> put all value to a row
class_addmethod(mtx_preset_class, (t_method)mtx_preset_col, gensym("col"),A_GIMME, 0); // put Col
// coll float float ... -> put all value to a col
- class_addmethod(mtx_preset_class, (t_method)mtx_preset_setrow, gensym("setRow"),A_GIMME, 0); // set Row
+ class_addmethod(mtx_preset_class, (t_method)mtx_preset_setrow, gensym("setRow"),A_FLOAT, A_FLOAT, 0); // set Row
// row float float -> put value to a row
- class_addmethod(mtx_preset_class, (t_method)mtx_preset_setcol, gensym("setCol"),A_GIMME, 0); // set Col
+ class_addmethod(mtx_preset_class, (t_method)mtx_preset_setcol, gensym("setCol"),A_FLOAT, A_FLOAT, 0); // set Col
// coll float float -> put value to a col
class_addmethod(mtx_preset_class, (t_method)mtx_preset_element, gensym("element"),A_FLOAT, A_FLOAT, A_FLOAT, 0); // put 1 element
// element posX posY value