1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 12:34:05 +02:00

midi2osc: fix translation of Note On and Pitch; add debug output

This commit is contained in:
Werner Almesberger 2012-02-13 20:43:44 -03:00
parent 0032283321
commit 58d192ba4d

View File

@ -100,7 +100,12 @@ static void forward(snd_seq_t *midi, lo_address osc)
while (snd_seq_event_input(midi, &ev)) { while (snd_seq_event_input(midi, &ev)) {
switch (ev->type) { switch (ev->type) {
case SND_SEQ_EVENT_NOTEON: case SND_SEQ_EVENT_NOTEON:
msg[1] = 0x90 | ev->data.control.channel; if (debug)
fprintf(stderr, "note c%u.%u=%u\n",
ev->data.note.channel,
ev->data.note.note,
ev->data.note.velocity);
msg[1] = 0x90 | ev->data.note.channel;
msg[2] = ev->data.note.note; msg[2] = ev->data.note.note;
msg[3] = ev->data.note.velocity; msg[3] = ev->data.note.velocity;
break; break;
@ -110,7 +115,8 @@ static void forward(snd_seq_t *midi, lo_address osc)
value = ev->data.control.value; value = ev->data.control.value;
map(&chan, &ctrl, &value); map(&chan, &ctrl, &value);
if (debug) if (debug)
fprintf(stderr, "c%u.%u=%u -> c%u.%u=%u\n", fprintf(stderr,
"control c%u.%u=%u -> c%u.%u=%u\n",
ev->data.control.channel, ev->data.control.channel,
ev->data.control.param, ev->data.control.param,
ev->data.control.value, ev->data.control.value,
@ -120,9 +126,13 @@ static void forward(snd_seq_t *midi, lo_address osc)
msg[3] = value; msg[3] = value;
break; break;
case SND_SEQ_EVENT_PITCHBEND: case SND_SEQ_EVENT_PITCHBEND:
if (debug)
fprintf(stderr, "pitch c%u=%u\n",
ev->data.control.channel,
ev->data.control.value);
msg[1] = 0xe0 | ev->data.control.channel; msg[1] = 0xe0 | ev->data.control.channel;
msg[2] = ev->data.control.value; msg[2] = ev->data.control.value & 0x7f;
msg[3] = 0; msg[3] = ev->data.control.value >> 7;
break; break;
default: default:
/* Flickernoise currently doesn't support any others */ /* Flickernoise currently doesn't support any others */