summaryrefslogtreecommitdiff
path: root/client/midi.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-12 07:45:36 +0200
committerChristian Pointner <equinox@spreadspace.org>2015-10-12 07:45:36 +0200
commit72f7565e3210dfc8c068962fdcae7c99db5d6557 (patch)
tree6c54e6a0cfb3eefd91b7a724dc3b1b5e5c922058 /client/midi.c
parentadded support for midi (diff)
added inital osc support
Diffstat (limited to 'client/midi.c')
-rw-r--r--client/midi.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/client/midi.c b/client/midi.c
index cd4885a..46a4687 100644
--- a/client/midi.c
+++ b/client/midi.c
@@ -95,8 +95,7 @@ void midi_lang_switch_done(void* data)
d->active_ = 1;
}
-//static int midi_enqueue_lang_switch(midi_t* m, osc_t* o, const char* lang, const u_int8_t* buf, int len)
-static int midi_enqueue_lang_switch(midi_t* m, const char* lang, const u_int8_t* buf, int len)
+static int midi_enqueue_lang_switch(midi_t* m, osc_t* o, const char* lang, const u_int8_t* buf, int len)
{
midi_done_data_t* done_data = malloc(sizeof(midi_done_data_t));
assert(done_data);
@@ -110,26 +109,23 @@ static int midi_enqueue_lang_switch(midi_t* m, const char* lang, const u_int8_t*
return 0; // mixer_switch_lang(x, lang, &midi_lang_switch_done, done_data);
}
-//static int midi_handle_note_on(midi_t* m, osc_t* o)
-static int midi_handle_note_on(midi_t* m)
+static int midi_handle_note_on(midi_t* m, osc_t* o)
{
int ret = 0;
switch(m->buf_[1]) {
- case NOTE_EN: ret = midi_enqueue_lang_switch(m/*, o*/,"en", done_data_en, sizeof(done_data_en)); break;
- case NOTE_DE: ret = midi_enqueue_lang_switch(m/*, o*/, "de", done_data_de, sizeof(done_data_de)); break;
+ case NOTE_EN: ret = midi_enqueue_lang_switch(m, o,"en", done_data_en, sizeof(done_data_en)); break;
+ case NOTE_DE: ret = midi_enqueue_lang_switch(m, o, "de", done_data_de, sizeof(done_data_de)); break;
default: printf("ignoring unknown note\n"); break;
}
return ret;
}
-//static int midi_handle_note_off(midi_t* m, osc_t* o)
-static int midi_handle_note_off(midi_t* m)
+static int midi_handle_note_off(midi_t* m, osc_t* o)
{
return 0;
}
-//static int midi_handle_message(midi_t* m, osc_t* o)
-static int midi_handle_message(midi_t* m)
+static int midi_handle_message(midi_t* m, osc_t* o)
{
int i;
printf("MIDI: ");
@@ -138,18 +134,15 @@ static int midi_handle_message(midi_t* m)
int ret = 0;
switch(m->buf_[0]) {
-// case 0x90: ret = midi_handle_note_on(m, o); break;
-// case 0x80: ret = midi_handle_note_off(m, o); break;
- case 0x90: ret = midi_handle_note_on(m); break;
- case 0x80: ret = midi_handle_note_off(m); break;
+ case 0x90: ret = midi_handle_note_on(m, o); break;
+ case 0x80: ret = midi_handle_note_off(m, o); break;
default: printf("ignoring unknown midi command\n"); break;
}
return ret;
}
-//static int midi_handle_in_revents(midi_t* m, struct pollfd *pfds, int npfds, osc_t* o)
-static int midi_handle_in_revents(midi_t* m, struct pollfd *pfds, int npfds)
+static int midi_handle_in_revents(midi_t* m, struct pollfd *pfds, int npfds, osc_t* o)
{
int err;
unsigned short revents;
@@ -173,8 +166,7 @@ static int midi_handle_in_revents(midi_t* m, struct pollfd *pfds, int npfds)
}
m->read_idx_ += ret;
if(m->read_idx_ >= sizeof(m->buf_)) {
-// ret = midi_handle_message(m, o);
- ret = midi_handle_message(m);
+ ret = midi_handle_message(m, o);
memset(m->buf_, 0, sizeof(m->buf_));
m->read_idx_ = 0;
return ret;
@@ -223,16 +215,14 @@ static int midi_handle_out_revents(midi_t* m, struct pollfd *pfds, int npfds)
return 0;
}
-//int midi_handle_revents(midi_t* m, struct pollfd *pfds, int npfds, osc_t* o)
-int midi_handle_revents(midi_t* m, struct pollfd *pfds, int npfds)
+int midi_handle_revents(midi_t* m, struct pollfd *pfds, int npfds, osc_t* o)
{
assert(m);
if(!m->input_ || !m->output_)
return 0;
-// int ret = midi_handle_in_revents(m, pfds, m->in_pfds_cnt_, o);
- int ret = midi_handle_in_revents(m, pfds, m->in_pfds_cnt_);
+ int ret = midi_handle_in_revents(m, pfds, m->in_pfds_cnt_, o);
if(ret)
return ret;