aboutsummaryrefslogtreecommitdiff
path: root/externals/vanilla/bendout.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-03-21 21:01:26 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-03-21 21:01:26 +0000
commit0f12c96d992570360af4676b90d1cb2f40cf6fa8 (patch)
treede217ab398ef18b7618001d084ed9f445196f2b2 /externals/vanilla/bendout.c
parent70fa5194a370320732db2d7048316c8e09b07a88 (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/bendout.c')
-rw-r--r--externals/vanilla/bendout.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/externals/vanilla/bendout.c b/externals/vanilla/bendout.c
new file mode 100644
index 00000000..0ec4f35f
--- /dev/null
+++ b/externals/vanilla/bendout.c
@@ -0,0 +1,41 @@
+/* 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 *bendout_class;
+
+typedef struct _bendout
+{
+ t_object x_obj;
+ t_float x_channel;
+} t_bendout;
+
+static void *bendout_new(t_floatarg channel)
+{
+ t_bendout *x = (t_bendout *)pd_new(bendout_class);
+ if (channel <= 0) channel = 1;
+ x->x_channel = channel;
+ floatinlet_new(&x->x_obj, &x->x_channel);
+ return (x);
+}
+
+static void bendout_float(t_bendout *x, t_float f)
+{
+ int binchan = x->x_channel - 1;
+ int n = (int)f + 8192;
+ if (binchan < 0)
+ binchan = 0;
+ outmidi_pitchbend((binchan >> 4), (binchan & 15), n);
+}
+
+void bendout_setup(void)
+{
+ bendout_class = class_new(gensym("bendout"), (t_newmethod)bendout_new, 0,
+ sizeof(t_bendout), 0, A_DEFFLOAT, 0);
+ class_addfloat(bendout_class, bendout_float);
+ class_sethelpsymbol(bendout_class, gensym("midi"));
+}