From fc3d3c0a4f110a23335398c327ac0a4fc949d5cb Mon Sep 17 00:00:00 2001 From: Guenter Geiger Date: Mon, 17 Jun 2002 10:13:57 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r12, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/ggee/; revision=13 --- control/unserialize.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 control/unserialize.c (limited to 'control/unserialize.c') diff --git a/control/unserialize.c b/control/unserialize.c new file mode 100755 index 0000000..6133ead --- /dev/null +++ b/control/unserialize.c @@ -0,0 +1,57 @@ +/* (C) Guenter Geiger */ + + +#include +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ unserialize ----------------------------- */ + +#define MAX_ELEMENTS 256 + +static t_class *unserialize_class; + + +typedef struct _unserialize +{ + t_object x_obj; + t_atom x_abuf[MAX_ELEMENTS]; + t_int x_count; + t_int x_elements; +} t_unserialize; + + +void unserialize_float(t_unserialize *x,t_floatarg f) +{ + SETFLOAT(&x->x_abuf[x->x_count],f); + x->x_count++; + + if (x->x_count == x->x_elements) { + outlet_list(x->x_obj.ob_outlet,0,x->x_count,x->x_abuf); + x->x_count = 0; + } +} + + +static void *unserialize_new(t_floatarg f) +{ + t_unserialize *x = (t_unserialize *)pd_new(unserialize_class); + outlet_new(&x->x_obj,&s_float); + x->x_elements = f; + x->x_count=0; + if ((f <= 0) || (f > MAX_ELEMENTS)) x->x_elements = 1; + return (x); +} + + + +void unserialize_setup(void) +{ + unserialize_class = class_new(gensym("unserialize"), (t_newmethod)unserialize_new, + 0,sizeof(t_unserialize),0, A_DEFFLOAT,0); + class_addfloat(unserialize_class,unserialize_float); +} + + -- cgit v1.2.1