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/noteout.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 externals/vanilla/noteout.c (limited to 'externals/vanilla/noteout.c') diff --git a/externals/vanilla/noteout.c b/externals/vanilla/noteout.c new file mode 100644 index 00000000..5dd84af6 --- /dev/null +++ b/externals/vanilla/noteout.c @@ -0,0 +1,44 @@ +/* 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_class *noteout_class; + +typedef struct _noteout +{ + t_object x_obj; + t_float x_velo; + t_float x_channel; +} t_noteout; + +static void *noteout_new(t_floatarg channel) +{ + t_noteout *x = (t_noteout *)pd_new(noteout_class); + x->x_velo = 0; + if (channel < 1) channel = 1; + x->x_channel = channel; + floatinlet_new(&x->x_obj, &x->x_velo); + floatinlet_new(&x->x_obj, &x->x_channel); + return (x); +} + +static void noteout_float(t_noteout *x, t_float f) +{ + int binchan = x->x_channel - 1; + if (binchan < 0) + binchan = 0; + outmidi_noteon((binchan >> 4), + (binchan & 15), (int)f, (int)x->x_velo); +} + +void noteout_setup(void) +{ + noteout_class = class_new(gensym("noteout"), (t_newmethod)noteout_new, 0, + sizeof(t_noteout), 0, A_DEFFLOAT, 0); + class_addfloat(noteout_class, noteout_float); + class_sethelpsymbol(noteout_class, gensym("midi")); +} -- cgit v1.2.1