summaryrefslogtreecommitdiff
path: root/apps/midi.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/midi.c')
-rw-r--r--apps/midi.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/apps/midi.c b/apps/midi.c
index 1a9bc94..6e14bc8 100644
--- a/apps/midi.c
+++ b/apps/midi.c
@@ -56,16 +56,44 @@ int midi_get_poll_fds(midi_t* m, struct pollfd *pfds, int npfds)
return snd_rawmidi_poll_descriptors(m->input_, pfds, npfds);
}
-static int midi_handle_message(midi_t* m, mixer_t* x)
+void midi_switch_lang_done(void* data)
{
- int i;
- printf("MIDI: ");
- for (i = 0; i < sizeof(m->buf_); ++i)
- printf("%02X%c", m->buf_[i], (i >= (sizeof(m->buf_)-1)) ? '\n' : ' ');
+ printf("language switching is done: %s\n", (char*)data);
+}
+static int midi_handle_note_on(midi_t* m, mixer_t* x)
+{
+ int ret = 0;
+ switch(m->buf_[1]) {
+ case 0x00: ret = mixer_switch_lang(x, "en", &midi_switch_lang_done, " -> EN"); break;
+ case 0x01: ret = mixer_switch_lang(x, "de", &midi_switch_lang_done, " -> DE"); break;
+ default: printf("ignoring unknown note\n"); break;
+ }
+ return ret;
+}
+
+static int midi_handle_note_off(midi_t* m, mixer_t* x)
+{
return 0;
}
+static int midi_handle_message(midi_t* m, mixer_t* x)
+{
+ /* int i; */
+ /* printf("MIDI: "); */
+ /* for (i = 0; i < sizeof(m->buf_); ++i) */
+ /* printf("%02X%c", m->buf_[i], (i >= (sizeof(m->buf_)-1)) ? '\n' : ' '); */
+
+ int ret = 0;
+ switch(m->buf_[0]) {
+ case 0x90: ret = midi_handle_note_on(m, x); break;
+ case 0x80: ret = midi_handle_note_off(m, x); break;
+ default: printf("ignoring unknown midi command\n"); break;
+ }
+
+ return ret;
+}
+
int midi_handle_revents(midi_t* m, struct pollfd *pfds, int npfds, mixer_t* x)
{
int err;