Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 05, 2011
@wpwrak wpwrak midi.c: "learn" mode for controllers
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.
@sbourdeauducq sbourdeauducq midi.c: use mtk_bindf + style corrections fedfe72
Showing with 17 additions and 0 deletions.
  1. +17 −0 src/midi.c
17 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,8 @@ 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 +351,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 = (int)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);
@@ -537,6 +552,8 @@ void init_midi()
mtk_cmdf(appid, "e_midi%d = new Entry()", i);
mtk_cmdf(appid, ", -column 1 -row %d)", i, i);
mtk_cmdf(appid, ", -column 2 -row %d)", i, i);
+ mtk_bindf(appid, "l_midi%d", "press", press_callback, (void *)i, i);
+ mtk_bindf(appid, "l_midi%d", "release", release_callback, NULL, i);
mtk_bind(appid, "lst_existing", "selchange", selchange_callback, NULL);

No commit comments for this range

Something went wrong with that request. Please try again.