diff options
author | Juha Vehviläinen <jusu@users.sourceforge.net> | 2002-07-06 17:50:18 +0000 |
---|---|---|
committer | Juha Vehviläinen <jusu@users.sourceforge.net> | 2002-07-06 17:50:18 +0000 |
commit | 4d64e4cd434426234a5c313c151cd79b6afc299e (patch) | |
tree | 5c23dd6acc65b869741d3bb9d33912d74bb7407d /Patches/arraysize.c |
*** empty log message ***svn2git-root
svn path=/trunk/Framestein/; revision=27
Diffstat (limited to 'Patches/arraysize.c')
-rw-r--r-- | Patches/arraysize.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Patches/arraysize.c b/Patches/arraysize.c new file mode 100644 index 0000000..3393e8f --- /dev/null +++ b/Patches/arraysize.c @@ -0,0 +1,44 @@ +#include <m_pd.h> + +static t_class *arraysize_class; + +typedef struct _arraysize { + t_object x_obj; + t_symbol *array_name; +} t_arraysize; + +void arraysize_set(t_arraysize *x, t_symbol *s) +{ + x->array_name = s; +} + +void arraysize_bang(t_arraysize *x) +{ + t_garray *garray; + + if(!(garray = (t_garray *)pd_findbyclass(x->array_name,garray_class))) { + pd_error(x, "%s: no such table", x->array_name->s_name); + } else { + outlet_float(x->x_obj.ob_outlet, garray_npoints(garray)); + } +} + +void *arraysize_new(t_symbol *s) +{ + t_arraysize *x = (t_arraysize *)pd_new(arraysize_class); + + outlet_new(&x->x_obj, gensym("float")); + + x->array_name = s; + + return (void *)x; +} + +void arraysize_setup(void) +{ + + arraysize_class = class_new(gensym("arraysize"), (t_newmethod)arraysize_new, 0, sizeof(t_arraysize), CLASS_DEFAULT, A_DEFSYMBOL, 0); + + class_addmethod(arraysize_class,arraysize_set,gensym("set"), A_DEFSYM, 0); + class_addbang(arraysize_class,arraysize_bang); +} |