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/polytouchout.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/polytouchout.c')
-rw-r--r-- | externals/vanilla/polytouchout.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/externals/vanilla/polytouchout.c b/externals/vanilla/polytouchout.c new file mode 100644 index 00000000..ead6a99a --- /dev/null +++ b/externals/vanilla/polytouchout.c @@ -0,0 +1,45 @@ +/* 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" +void outmidi_polyaftertouch(int portno, int channel, int pitch, int value); + +static t_class *polytouchout_class; + +typedef struct _polytouchout +{ + t_object x_obj; + t_float x_channel; + t_float x_pitch; +} t_polytouchout; + +static void *polytouchout_new(t_floatarg channel) +{ + t_polytouchout *x = (t_polytouchout *)pd_new(polytouchout_class); + if (channel <= 0) channel = 1; + x->x_channel = channel; + x->x_pitch = 0; + floatinlet_new(&x->x_obj, &x->x_pitch); + floatinlet_new(&x->x_obj, &x->x_channel); + return (x); +} + +static void polytouchout_float(t_polytouchout *x, t_float n) +{ + int binchan = x->x_channel - 1; + if (binchan < 0) + binchan = 0; + outmidi_polyaftertouch((binchan >> 4), (binchan & 15), x->x_pitch, n); +} + +void polytouchout_setup(void) +{ + polytouchout_class = class_new(gensym("polytouchout"), + (t_newmethod)polytouchout_new, 0, + sizeof(t_polytouchout), 0, A_DEFFLOAT, 0); + class_addfloat(polytouchout_class, polytouchout_float); + class_sethelpsymbol(polytouchout_class, gensym("midi")); +} |