From ca2e3185514624be0349b96cd5755a6fe4ea4b8c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 20 Aug 2022 23:56:18 +0200 Subject: [PATCH] Clean up JACK MIDI handling #23 --- src/wrapper/standalone/backend/jack.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/wrapper/standalone/backend/jack.rs b/src/wrapper/standalone/backend/jack.rs index 57e91c2d..aef9b8fd 100644 --- a/src/wrapper/standalone/backend/jack.rs +++ b/src/wrapper/standalone/backend/jack.rs @@ -121,16 +121,13 @@ impl Backend for Jack { input_events.extend(midi_input.iter(ps).filter_map(|midi| { // Unless it is a SysEx message, a JACK MIDI message is always three bytes or // less and is normalized (starts with a status byte and is self-contained). - // Filter out the SysEx messages. - let len = midi.bytes.len(); - if len <= 3 { + if midi.bytes.len() <= 3 { + // JACK may not pad messages with zeroes, so mesages for things like channel + // pressure may be less than three bytes in length. let mut midi_data = [0u8; 3]; - midi_data[..len].copy_from_slice(midi.bytes); - if midi_data[0] >= 0x80 && midi_data[0] != 0xF0 && midi_data[0] != 0xF7 { - NoteEvent::from_midi(midi.time, midi_data).ok() - } else { - None - } + midi_data[..midi.bytes.len()].copy_from_slice(midi.bytes); + + NoteEvent::from_midi(midi.time, midi_data).ok() } else { None }