#[non_exhaustive]pub enum MidiEvent {
NoteOn {
channel: MidiChannel,
note: u8,
velocity: u8,
},
NoteOff {
channel: MidiChannel,
note: u8,
velocity: u8,
},
ControlChange {
channel: MidiChannel,
controller: u8,
value: u8,
},
ProgramChange {
channel: MidiChannel,
program: u8,
},
PitchBend {
channel: MidiChannel,
value: u16,
},
ChannelAftertouch {
channel: MidiChannel,
pressure: u8,
},
PolyAftertouch {
channel: MidiChannel,
note: u8,
pressure: u8,
},
}Expand description
High-level MIDI event types.
Marked #[non_exhaustive]: match with a wildcard arm, as new event kinds (e.g. SysEx)
may be added in future versions without it being a breaking change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NoteOn
Note On event
Fields
channel: MidiChannelMIDI channel (1-16)
NoteOff
Note Off event
Fields
channel: MidiChannelMIDI channel (1-16)
ControlChange
Control Change event
Fields
channel: MidiChannelMIDI channel (1-16)
ProgramChange
Program Change event
PitchBend
Pitch Bend event
Fields
channel: MidiChannelMIDI channel (1-16)
ChannelAftertouch
Channel Aftertouch event
PolyAftertouch
Polyphonic Aftertouch event
Implementations§
Source§impl MidiEvent
impl MidiEvent
Sourcepub fn from_midi_bytes(bytes: &[u8]) -> Option<MidiEvent>
pub fn from_midi_bytes(bytes: &[u8]) -> Option<MidiEvent>
Parse a single channel-voice MIDI message from raw bytes (status + data), as delivered by a MIDI input device.
Maps Note On/Off (a Note On with velocity 0 becomes a Note Off), Control Change,
Pitch Bend (14-bit), channel/poly aftertouch, and Program Change. Returns None for
empty/truncated input, running-status messages (no leading status byte), and
system/realtime/SysEx messages.