diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-03-21 21:01:26 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-03-21 21:01:26 +0000 |
commit | 0f12c96d992570360af4676b90d1cb2f40cf6fa8 (patch) | |
tree | de217ab398ef18b7618001d084ed9f445196f2b2 /externals/vanilla/notein.c | |
parent | 70fa5194a370320732db2d7048316c8e09b07a88 (diff) |
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
Diffstat (limited to 'externals/vanilla/notein.c')
-rw-r--r-- | externals/vanilla/notein.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/externals/vanilla/notein.c b/externals/vanilla/notein.c new file mode 100644 index 00000000..00b41f0f --- /dev/null +++ b/externals/vanilla/notein.c @@ -0,0 +1,64 @@ +/* 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 *notein_sym; + +static t_class *notein_class; + +typedef struct _notein +{ + t_object x_obj; + t_float x_channel; + t_outlet *x_outlet1; + t_outlet *x_outlet2; + t_outlet *x_outlet3; +} t_notein; + +static void *notein_new(t_floatarg f) +{ + t_notein *x = (t_notein *)pd_new(notein_class); + x->x_channel = f; + x->x_outlet1 = outlet_new(&x->x_obj, &s_float); + x->x_outlet2 = outlet_new(&x->x_obj, &s_float); + if (f == 0) x->x_outlet3 = outlet_new(&x->x_obj, &s_float); + pd_bind(&x->x_obj.ob_pd, notein_sym); + return (x); +} + +static void notein_list(t_notein *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float pitch = atom_getfloatarg(0, argc, argv); + t_float velo = atom_getfloatarg(1, argc, argv); + t_float channel = atom_getfloatarg(2, argc, argv); + if (x->x_channel != 0) + { + if (channel != x->x_channel) return; + outlet_float(x->x_outlet2, velo); + outlet_float(x->x_outlet1, pitch); + } + else + { + outlet_float(x->x_outlet3, channel); + outlet_float(x->x_outlet2, velo); + outlet_float(x->x_outlet1, pitch); + } +} + +static void notein_free(t_notein *x) +{ + pd_unbind(&x->x_obj.ob_pd, notein_sym); +} + +void notein_setup(void) +{ + notein_class = class_new(gensym("notein"), (t_newmethod)notein_new, + (t_method)notein_free, sizeof(t_notein), CLASS_NOINLET, A_DEFFLOAT, 0); + class_addlist(notein_class, notein_list); + class_sethelpsymbol(notein_class, gensym("midi")); + notein_sym = gensym("#notein"); +} |