From 0f12c96d992570360af4676b90d1cb2f40cf6fa8 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 21 Mar 2011 21:01:26 +0000 Subject: refactored x_midi.c into individual objects, and split out inmidi_* functions to e_midi.c in pd-extended.git svn path=/trunk/; revision=15037 --- externals/vanilla/bendin.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 externals/vanilla/bendin.c (limited to 'externals/vanilla/bendin.c') diff --git a/externals/vanilla/bendin.c b/externals/vanilla/bendin.c new file mode 100644 index 00000000..ce9c283b --- /dev/null +++ b/externals/vanilla/bendin.c @@ -0,0 +1,59 @@ +/* Copyright (c) 1997-2001 Miller Puckette and others. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* MIDI. */ + +#include "m_pd.h" + +static t_symbol *bendin_sym; + +static t_class *bendin_class; + +typedef struct _bendin +{ + t_object x_obj; + t_float x_channel; + t_outlet *x_outlet1; + t_outlet *x_outlet2; +} t_bendin; + +static void *bendin_new(t_floatarg f) +{ + t_bendin *x = (t_bendin *)pd_new(bendin_class); + x->x_channel = f; + x->x_outlet1 = outlet_new(&x->x_obj, &s_float); + if (f == 0) x->x_outlet2 = outlet_new(&x->x_obj, &s_float); + pd_bind(&x->x_obj.ob_pd, bendin_sym); + return (x); +} + +static void bendin_list(t_bendin *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float value = atom_getfloatarg(0, argc, argv); + t_float channel = atom_getfloatarg(1, argc, argv); + if (x->x_channel != 0) + { + if (channel != x->x_channel) return; + outlet_float(x->x_outlet1, value); + } + else + { + outlet_float(x->x_outlet2, channel); + outlet_float(x->x_outlet1, value); + } +} + +static void bendin_free(t_bendin *x) +{ + pd_unbind(&x->x_obj.ob_pd, bendin_sym); +} + +void bendin_setup(void) +{ + bendin_class = class_new(gensym("bendin"), (t_newmethod)bendin_new, + (t_method)bendin_free, sizeof(t_bendin), CLASS_NOINLET, A_DEFFLOAT, 0); + class_addlist(bendin_class, bendin_list); + class_sethelpsymbol(bendin_class, gensym("midi")); + bendin_sym = gensym("#bendin"); +} -- cgit v1.2.1