pub struct MidiEvent {
pub timestamp: u64,
pub channel: u8,
pub kind: MidiEventKind,
}Expand description
A single MIDI event with timestamp.
Fields§
§timestamp: u64Sample-accurate timestamp (samples since engine start).
channel: u8MIDI channel (0–15).
kind: MidiEventKindThe event kind.
Implementations§
Source§impl MidiEvent
impl MidiEvent
Sourcepub fn from_bytes(bytes: &[u8], timestamp: u64) -> Option<Self>
pub fn from_bytes(bytes: &[u8], timestamp: u64) -> Option<Self>
Parse raw MIDI bytes into a MidiEvent. Returns None for unsupported or malformed messages.
Sourcepub fn is_note_on(&self) -> bool
pub fn is_note_on(&self) -> bool
Is this a note-on event?
Sourcepub fn is_note_off(&self) -> bool
pub fn is_note_off(&self) -> bool
Is this a note-off event?
Sourcepub fn velocity_linear(&self) -> f32
pub fn velocity_linear(&self) -> f32
Convert velocity to linear amplitude (0.0–1.0).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MidiEvent
impl<'de> Deserialize<'de> for MidiEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for MidiEvent
impl RefUnwindSafe for MidiEvent
impl Send for MidiEvent
impl Sync for MidiEvent
impl Unpin for MidiEvent
impl UnsafeUnpin for MidiEvent
impl UnwindSafe for MidiEvent
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