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/midiin.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 externals/vanilla/midiin.c (limited to 'externals/vanilla/midiin.c') diff --git a/externals/vanilla/midiin.c b/externals/vanilla/midiin.c new file mode 100644 index 00000000..16b82a66 --- /dev/null +++ b/externals/vanilla/midiin.c @@ -0,0 +1,51 @@ +/* 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 *midiin_sym; + +static t_class *midiin_class; + +typedef struct _midiin +{ + t_object x_obj; + t_outlet *x_outlet1; + t_outlet *x_outlet2; +} t_midiin; + +static void *midiin_new( void) +{ + t_midiin *x = (t_midiin *)pd_new(midiin_class); + x->x_outlet1 = outlet_new(&x->x_obj, &s_float); + x->x_outlet2 = outlet_new(&x->x_obj, &s_float); + pd_bind(&x->x_obj.ob_pd, midiin_sym); +#ifdef WIN32 + pd_error(x, "midiin: windows: not supported"); +#endif + return (x); +} + +static void midiin_list(t_midiin *x, t_symbol *s, int ac, t_atom *av) +{ + outlet_float(x->x_outlet2, atom_getfloatarg(1, ac, av) + 1); + outlet_float(x->x_outlet1, atom_getfloatarg(0, ac, av)); +} + +static void midiin_free(t_midiin *x) +{ + pd_unbind(&x->x_obj.ob_pd, midiin_sym); +} + +void midiin_setup(void) +{ + midiin_class = class_new(gensym("midiin"), (t_newmethod)midiin_new, + (t_method)midiin_free, sizeof(t_midiin), + CLASS_NOINLET, A_DEFFLOAT, 0); + class_addlist(midiin_class, midiin_list); + class_sethelpsymbol(midiin_class, gensym("midi")); + midiin_sym = gensym("#midiin"); +} -- cgit v1.2.1