diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-06-02 18:25:00 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-06-02 18:25:00 +0000 |
commit | 0c9b89b1018eb7760708ee5b080cd96846861328 (patch) | |
tree | f43a2b20292bba90931fe84e67aca8fb0013a984 /src/iemlib2/toggle_mess.c | |
parent | d56ec9d039c904e9230137254ff2fe281320eed9 (diff) |
updated to release-1.16
svn path=/trunk/externals/iemlib/; revision=3102
Diffstat (limited to 'src/iemlib2/toggle_mess.c')
-rw-r--r-- | src/iemlib2/toggle_mess.c | 240 |
1 files changed, 121 insertions, 119 deletions
diff --git a/src/iemlib2/toggle_mess.c b/src/iemlib2/toggle_mess.c index b8cb569..feb1b79 100644 --- a/src/iemlib2/toggle_mess.c +++ b/src/iemlib2/toggle_mess.c @@ -1,119 +1,121 @@ -/* Copyright (c) 1997-2003 Miller Puckette. -* For information on usage and redistribution, and for a DISCLAIMER OF ALL -* WARRANTIES, see the file, "LICENSE.txt," in this distribution. - -iemlib2 written by Thomas Musil (c) IEM KUG Graz Austria 2000 - 2003 */ - -#ifdef NT -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -#include "m_pd.h" -#include "iemlib.h" -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <math.h> - -/* ------------------------ toggle_mess ---------------------------- */ -static t_class *toggle_mess_class; - -typedef struct _toggle_mess -{ - t_object x_obj; - int x_index; - int x_ac; - t_atom *x_at; - void *x_out_mid_sym; - void *x_out_rght_flt; - t_symbol *x_set; -} t_toggle_mess; - -static void toggle_mess_bang(t_toggle_mess *x) -{ - int i = x->x_index; - - outlet_float(x->x_out_rght_flt, (float)i); - if(IS_A_FLOAT(x->x_at, i)) - outlet_float(x->x_out_mid_sym, atom_getfloat(&x->x_at[i])); - else - outlet_anything(x->x_out_mid_sym, atom_getsymbol(&x->x_at[i]), 0, x->x_at); - outlet_anything(x->x_obj.ob_outlet, x->x_set, 1, &x->x_at[i]); -} - -static void toggle_mess_float(t_toggle_mess *x, t_float f) -{ - x->x_index++; - if(x->x_index >= x->x_ac) - x->x_index = 0; - toggle_mess_bang(x); -} - -static void toggle_mess_set(t_toggle_mess *x, t_symbol *s, int ac, t_atom *av) -{ - if((ac >= 1) && (IS_A_FLOAT(av, 0))) - { - int x_index = (int)atom_getint(av); - - if(x_index < 0) - x_index = 0; - else if(x_index >= x->x_ac) - x_index = x->x_ac; - x->x_index = x_index; - outlet_anything(x->x_obj.ob_outlet, x->x_set, 1, &x->x_at[x_index]); - } - else - toggle_mess_float(x, 0); -} - -static void toggle_mess_symbol(t_toggle_mess *x, t_symbol *s) -{ - toggle_mess_float(x, 0); -} - -static void toggle_mess_anything(t_toggle_mess *x, t_symbol *s, int ac, t_atom *av) -{ - toggle_mess_float(x, 0); -} - -static void toggle_mess_free(t_toggle_mess *x) -{ - freebytes(x->x_at, x->x_ac * sizeof(t_atom)); -} - -static void *toggle_mess_new(t_symbol *s, int ac, t_atom *av) -{ - t_toggle_mess *x = (t_toggle_mess *)pd_new(toggle_mess_class); - int i; - - if(!ac) - { - post("toggle_mess-ERROR: must have at least one argument!"); - x->x_at = (t_atom *)0; - return(0); - } - x->x_ac = ac; - x->x_at = (t_atom *)getbytes(ac * sizeof(t_atom)); - for(i=0; i<ac; i++) - x->x_at[i] = *av++; - x->x_index = 0; - x->x_set = gensym("set"); - outlet_new(&x->x_obj, &s_list); - x->x_out_mid_sym = outlet_new(&x->x_obj, &s_list); - x->x_out_rght_flt = outlet_new(&x->x_obj, &s_float); - return(x); -} - -void toggle_mess_setup(void) -{ - toggle_mess_class = class_new(gensym("toggle_mess"), (t_newmethod)toggle_mess_new, - (t_method)toggle_mess_free, sizeof(t_toggle_mess), 0, A_GIMME, 0); - class_addcreator((t_newmethod)toggle_mess_new, gensym("tm"), A_GIMME, 0); - class_addbang(toggle_mess_class, (t_method)toggle_mess_bang); - class_addmethod(toggle_mess_class, (t_method)toggle_mess_set, gensym("set"), A_GIMME, 0); - class_addfloat(toggle_mess_class, (t_method)toggle_mess_float); - class_addsymbol(toggle_mess_class, toggle_mess_symbol); - class_addanything(toggle_mess_class, toggle_mess_anything); - class_sethelpsymbol(toggle_mess_class, gensym("iemhelp/help-toggle_mess")); -} +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/* ------------------------ toggle_mess ---------------------------- */
+/* -- inital arguments building a set of messages, any incomming --- */
+/* -- increments the internal counter and outputs the n-th initial --*/
+/* -- message. -- */
+
+static t_class *toggle_mess_class;
+
+typedef struct _toggle_mess
+{
+ t_object x_obj;
+ int x_index;
+ int x_ac;
+ t_atom *x_at;
+ void *x_out_mid_sym;
+ void *x_out_rght_flt;
+ t_symbol *x_set;
+} t_toggle_mess;
+
+static void toggle_mess_bang(t_toggle_mess *x)
+{
+ int i = x->x_index;
+
+ outlet_float(x->x_out_rght_flt, (float)i);
+ if(IS_A_FLOAT(x->x_at, i))
+ outlet_float(x->x_out_mid_sym, atom_getfloat(&x->x_at[i]));
+ else
+ outlet_anything(x->x_out_mid_sym, atom_getsymbol(&x->x_at[i]), 0, x->x_at);
+ outlet_anything(x->x_obj.ob_outlet, x->x_set, 1, &x->x_at[i]);
+}
+
+static void toggle_mess_float(t_toggle_mess *x, t_float f)
+{
+ x->x_index++;
+ if(x->x_index >= x->x_ac)
+ x->x_index = 0;
+ toggle_mess_bang(x);
+}
+
+static void toggle_mess_set(t_toggle_mess *x, t_symbol *s, int ac, t_atom *av)
+{
+ if((ac >= 1) && (IS_A_FLOAT(av, 0)))
+ {
+ int x_index = (int)atom_getint(av);
+
+ if(x_index < 0)
+ x_index = 0;
+ else if(x_index >= x->x_ac)
+ x_index = x->x_ac;
+ x->x_index = x_index;
+ outlet_anything(x->x_obj.ob_outlet, x->x_set, 1, &x->x_at[x_index]);
+ }
+ else
+ toggle_mess_float(x, 0);
+}
+
+static void toggle_mess_symbol(t_toggle_mess *x, t_symbol *s)
+{
+ toggle_mess_float(x, 0);
+}
+
+static void toggle_mess_anything(t_toggle_mess *x, t_symbol *s, int ac, t_atom *av)
+{
+ toggle_mess_float(x, 0);
+}
+
+static void toggle_mess_free(t_toggle_mess *x)
+{
+ freebytes(x->x_at, x->x_ac * sizeof(t_atom));
+}
+
+static void *toggle_mess_new(t_symbol *s, int ac, t_atom *av)
+{
+ t_toggle_mess *x = (t_toggle_mess *)pd_new(toggle_mess_class);
+ int i;
+
+ if(!ac)
+ {
+ post("toggle_mess-ERROR: must have at least one argument!");
+ x->x_at = (t_atom *)0;
+ return(0);
+ }
+ x->x_ac = ac;
+ x->x_at = (t_atom *)getbytes(ac * sizeof(t_atom));
+ for(i=0; i<ac; i++)
+ x->x_at[i] = *av++;
+ x->x_index = 0;
+ x->x_set = gensym("set");
+ outlet_new(&x->x_obj, &s_list);
+ x->x_out_mid_sym = outlet_new(&x->x_obj, &s_list);
+ x->x_out_rght_flt = outlet_new(&x->x_obj, &s_float);
+ return(x);
+}
+
+void toggle_mess_setup(void)
+{
+ toggle_mess_class = class_new(gensym("toggle_mess"), (t_newmethod)toggle_mess_new,
+ (t_method)toggle_mess_free, sizeof(t_toggle_mess), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)toggle_mess_new, gensym("tm"), A_GIMME, 0);
+ class_addbang(toggle_mess_class, (t_method)toggle_mess_bang);
+ class_addmethod(toggle_mess_class, (t_method)toggle_mess_set, gensym("set"), A_GIMME, 0);
+ class_addfloat(toggle_mess_class, (t_method)toggle_mess_float);
+ class_addsymbol(toggle_mess_class, toggle_mess_symbol);
+ class_addanything(toggle_mess_class, toggle_mess_anything);
+ class_sethelpsymbol(toggle_mess_class, gensym("iemhelp/help-toggle_mess"));
+}
|