pub struct MidiMessage {
pub timestamp: Option<u64>,
pub message_type: MidiMessageType,
pub raw: [u8; 3],
pub len: u8,
}Expand description
A timestamped MIDI message. Small enough to pass through a ring buffer.
Fields§
§timestamp: Option<u64>When this message was received (high-resolution).
message_type: MidiMessageTypeThe parsed message type.
raw: [u8; 3]Raw bytes for forwarding (up to 3 bytes for channel messages).
len: u8Number of valid bytes in raw.
Implementations§
Source§impl MidiMessage
impl MidiMessage
Sourcepub fn from_bytes(bytes: &[u8], timestamp: u64) -> Option<Self>
pub fn from_bytes(bytes: &[u8], timestamp: u64) -> Option<Self>
Parse a raw MIDI byte slice into a MidiMessage. Returns None only if the slice is empty.
Sourcepub fn note_to_freq(note: u8) -> f64
pub fn note_to_freq(note: u8) -> f64
MIDI note number to frequency (A4 = 440 Hz).
Sourcepub fn note_to_name(note: u8) -> String
pub fn note_to_name(note: u8) -> String
MIDI note number to name (e.g., 60 → “C4”).
Trait Implementations§
Source§impl Clone for MidiMessage
impl Clone for MidiMessage
Source§fn clone(&self) -> MidiMessage
fn clone(&self) -> MidiMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MidiMessage
Auto Trait Implementations§
impl Freeze for MidiMessage
impl RefUnwindSafe for MidiMessage
impl Send for MidiMessage
impl Sync for MidiMessage
impl Unpin for MidiMessage
impl UnsafeUnpin for MidiMessage
impl UnwindSafe for MidiMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more