From c8f3e3674f08bf56407e478c3160c4392196c118 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 30 Jul 2003 21:52:27 +0000 Subject: separated out all objects into individual files; created a few missing help files; moves all help files to new 0.37 help- standard; removed [reson~] and [abs~] since they are now maintained elsewhere; created Makefile for Linux and Darwin svn path=/trunk/externals/markex/; revision=806 --- oneshot.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 oneshot.c (limited to 'oneshot.c') diff --git a/oneshot.c b/oneshot.c new file mode 100644 index 0000000..ba2e0a0 --- /dev/null +++ b/oneshot.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 1997-1999 Mark Danks. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + */ + +#include "m_pd.h" + +/* -------------------------- oneshot ------------------------------ */ + +/* instance structure */ +static t_class *oneshot_class; + +typedef struct _oneshot +{ + t_object x_obj; /* obligatory object header */ + int t_armed; /* if willing to pass data */ + t_outlet *t_out1; /* the outlet */ +} t_oneshot; + +static void oneshot_float(t_oneshot *x, t_floatarg n) +{ + if (x->t_armed) + { + outlet_float(x->t_out1, n); + x->t_armed = 0; + } +} + +static void oneshot_bang(t_oneshot *x) +{ + if (x->t_armed) + { + outlet_bang(x->t_out1); + x->t_armed = 0; + } +} + +static void oneshot_clear(t_oneshot *x) +{ + x->t_armed = 1; +} + +static void *oneshot_new(t_symbol *s) /* init vals in struc */ +{ + t_oneshot *x = (t_oneshot *)pd_new(oneshot_class); + x->t_out1 = outlet_new(&x->x_obj, 0); + x->t_armed = 1; + return (x); +} + +void oneshot_setup(void) +{ + oneshot_class = class_new(gensym("oneshot"), (t_newmethod)oneshot_new, 0, + sizeof(t_oneshot), 0, A_NULL); + class_addfloat(oneshot_class, (t_method)oneshot_float); + class_addbang(oneshot_class, (t_method)oneshot_bang); + class_addmethod(oneshot_class, (t_method)oneshot_clear, gensym("clear"), A_NULL); + class_sethelpsymbol(oneshot_class, gensym("help-oneshot")); +} + -- cgit v1.2.1