From a71366075fadcdb720b8fa02663bb19200fed5e5 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 13 Dec 2010 02:26:52 +0000 Subject: refactored d_misc.c into bang~.c and print~.c svn path=/trunk/; revision=14609 --- externals/vanilla/bang~.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 externals/vanilla/bang~.c (limited to 'externals/vanilla/bang~.c') diff --git a/externals/vanilla/bang~.c b/externals/vanilla/bang~.c new file mode 100644 index 00000000..559e6ef1 --- /dev/null +++ b/externals/vanilla/bang~.c @@ -0,0 +1,56 @@ +/* Copyright (c) 1997-1999 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* miscellaneous: print~; more to come. +*/ + +#include "m_pd.h" +#include +#include + +static t_class *bang_tilde_class; + +typedef struct _bang +{ + t_object x_obj; + t_clock *x_clock; +} t_bang; + +static t_int *bang_tilde_perform(t_int *w) +{ + t_bang *x = (t_bang *)(w[1]); + clock_delay(x->x_clock, 0); + return (w+2); +} + +static void bang_tilde_dsp(t_bang *x, t_signal **sp) +{ + dsp_add(bang_tilde_perform, 1, x); +} + +static void bang_tilde_tick(t_bang *x) +{ + outlet_bang(x->x_obj.ob_outlet); +} + +static void bang_tilde_free(t_bang *x) +{ + clock_free(x->x_clock); +} + +static void *bang_tilde_new(t_symbol *s) +{ + t_bang *x = (t_bang *)pd_new(bang_tilde_class); + x->x_clock = clock_new(x, (t_method)bang_tilde_tick); + outlet_new(&x->x_obj, &s_bang); + return (x); +} + +void bang_tilde_setup(void) +{ + bang_tilde_class = class_new(gensym("bang~"), (t_newmethod)bang_tilde_new, + (t_method)bang_tilde_free, sizeof(t_bang), 0, 0); + class_addmethod(bang_tilde_class, (t_method)bang_tilde_dsp, + gensym("dsp"), 0); +} -- cgit v1.2.1