While a miniN tag is being clicked (click button 1 and hold down),
any incoming controller message will map that MIDI variable to the
respective controller. This simplified MIDI configuration.
Controls appearing as multiple controllers may need special
precautions. E.g., an X/Y pad may have three controllers: X, Y, and
touch/release. X and Y can be distinguished by moving the finger
and simply stopping when the right value has been taken. To prevent
release from overriding an X/Y controller, release the mouse button
before releasing the pad.
Some scenarios may be beyond the capabilities of this simple
mechanism and require manual setup.
---
src/midi.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/midi.c b/src/midi.c
index d5b708c..9cf5147 100644
--- a/src/midi.c
+++ b/src/midi.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <dirent.h>
#include <unistd.h>
+#include <assert.h>
#include <mtklib.h>
#include "util.h"
@@ -158,6 +159,7 @@ static int midistr(const char *str)
static int appid;
static struct filedialog *browse_dlg;
+static int learn = -1;
static int w_open;
@@ -269,6 +271,9 @@ static void note_event(int code)
static void controller_event(int controller, int value)
{
mtk_cmdf(appid, "l_lastctl.set(-text \"%d (%d)\")", controller, value);
+ if (learn != -1)
+ mtk_cmdf(appid, "e_midi%d.set(-text \"%d\")",
+ learn, controller);
}
static void midi_event(mtk_event *e, int count)
@@ -347,6 +352,17 @@ static void addupdate_callback(mtk_event *e, void *arg)
mtk_cmd(appid, "e_filename.set(-text \"\")");
}
+static void press_callback(mtk_event *e, void *arg)
+{
+ learn = (long) arg;
+ assert(learn >= 0 && learn < MIDI_COUNT);
+}
+
+static void release_callback(mtk_event *e, void *arg)
+{
+ learn = -1;
+}
+
static int cmpstringp(const void *p1, const void *p2)
{
return strcmp(*(char * const *)p1, *(char * const *)p2);
@@ -533,10 +549,15 @@ void init_midi()
0);
for(i=0;i<MIDI_COUNT;i++) {
+ char tmp[20];
+
mtk_cmdf(appid, "l_midi%d = new Label(-text \"\emidi%d\")", i,
i+1);
mtk_cmdf(appid, "e_midi%d = new Entry()", i);
mtk_cmdf(appid, "g_vars.place(l_midi%d, -column 1 -row %d)", i,
i);
mtk_cmdf(appid, "g_vars.place(e_midi%d, -column 2 -row %d)", i,
i);
+ snprintf(tmp, sizeof(tmp), "l_midi%d", i);
+ mtk_bind(appid, tmp, "press", press_callback, (void *) i);
+ mtk_bind(appid, tmp, "release", release_callback, NULL);
}
mtk_bind(appid, "lst_existing", "selchange", selchange_callback, NULL);
--
1.7.0.4
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode