Skip to content

Commit

Permalink
fix: note on message with velocity of 0 is note off
Browse files Browse the repository at this point in the history
  • Loading branch information
dsgallups committed Dec 6, 2024
1 parent 6b46b89 commit a60cbac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a60cbac

Please sign in to comment.