aboutsummaryrefslogtreecommitdiff
path: root/externals/vanilla/bang~.c
diff options
context:
space:
mode:
Diffstat (limited to 'externals/vanilla/bang~.c')
-rw-r--r--externals/vanilla/bang~.c56
1 files changed, 56 insertions, 0 deletions
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 <stdio.h>
+#include <string.h>
+
+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);
+}