From a60cbaca898df3d154906c6c67e5be478c33969e Mon Sep 17 00:00:00 2001 From: Daniel Gallups Date: Thu, 5 Dec 2024 23:56:30 -0500 Subject: [PATCH] fix: note on message with velocity of 0 is note off --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 16076bd..1a0003b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,12 +26,13 @@ impl From<[u8; 3]> for MidiMessage { impl MidiMessage { #[must_use] pub fn is_note_on(&self) -> bool { - (self.msg[0] & 0b1111_0000) == NOTE_ON_STATUS + (self.msg[0] & 0b1111_0000) == NOTE_ON_STATUS && self.msg[2] != 0 } #[must_use] pub fn is_note_off(&self) -> bool { (self.msg[0] & 0b1111_0000) == NOTE_OFF_STATUS + || ((self.msg[0] & 0b1111_0000) == NOTE_ON_STATUS && self.msg[2] == 0) } /// Get the channel of a message, assuming the message is not a system message.