Roland Mas, 2012-02-29 19:46:53 +0100 : [...]
> With ALSA: > t0: note-off for the current instrument > t0: note-on > t0+length of the current sample: note-off > > With JACK: > t0: note-off for the *previous* instrument > t0+length of the current sample: note-on for the current instrument It occurs to me that there are actually two bugs in there. 1. the lack of the first note-off event for the current sample; 2. the lagging of the events. Number 1 could be argued not to be a bug; after all, the note-off is only there as a safety net. However, number 2 seems to be that the events that are actually sent lag by one event behind those that are enqueued, which is why t0 includes the note-off related to the previous instrument. Further debugging leads me to the included patch. I added the note-off event too (second hunk). The fix is tested here, but I'd appreciate upstream review of course :-)
Description: Fix off-by-one error in JACK MIDI Fixed bug whereby a MIDI event is only sent when there is another one queued. Author: Roland Mas <[email protected]> Bug-Debian: http://bugs.debian.org/661725 --- hydrogen-0.9.6~beta1.orig/src/core/src/IO/jack_midi_driver.cpp +++ hydrogen-0.9.6~beta1/src/core/src/IO/jack_midi_driver.cpp @@ -222,11 +222,12 @@ JackMidiDriver::JackMidiRead(jack_nframe if (buffer == NULL) break; - memcpy(buffer, jack_buffer + (4 * rx_in_pos) + 1, len); t++; rx_in_pos++; if (rx_in_pos >= JACK_MIDI_BUFFER_MAX) rx_in_pos = 0; + + memcpy(buffer, jack_buffer + (4 * rx_in_pos) + 1, len); } unlock(); } @@ -379,6 +380,13 @@ void JackMidiDriver::handleQueueNote(Not if (vel < 0 || vel > 127) return; + buffer[0] = 0x80 | channel; /* note off */ + buffer[1] = key; + buffer[2] = 0; + buffer[3] = 0; + + JackMidiOutEvent(buffer, 3); + buffer[0] = 0x90 | channel; /* note on */ buffer[1] = key; buffer[2] = vel;
Roland. -- Roland Mas Le weblog entièrement nu -- http://roland.entierement.nu/ Le photoblog entièrement net -- http://roland.entierement.net/

