From 6164e2c5fee5d3a1622c27e36d9402976054e99d Mon Sep 17 00:00:00 2001 From: Francois Best Date: Fri, 18 Apr 2014 14:56:15 +0200 Subject: [PATCH] Fix issue #13 on GitHub. --- src/MIDI.hpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 7a154c2..789f524 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -483,24 +483,22 @@ inline bool MidiInterface::read(Channel inChannel) if (inChannel >= MIDI_CHANNEL_OFF) return false; // MIDI Input disabled. - if (parse()) + if (!parse()) + return false; + + handleNullVelocityNoteOnAsNoteOff(); + const bool channelMatch = inputFilter(inChannel); + + if (MIDI_USE_CALLBACKS && channelMatch) { - handleNullVelocityNoteOnAsNoteOff(); - if (inputFilter(inChannel)) - { - -#if (MIDI_BUILD_OUTPUT && MIDI_BUILD_THRU) - thruFilter(inChannel); -#endif - -#if MIDI_USE_CALLBACKS - launchCallback(); -#endif - return true; - } + launchCallback(); } - return false; +#if MIDI_BUILD_THRU + thruFilter(inChannel); +#endif + + return channelMatch; } // -----------------------------------------------------------------------------