pub enum LiveEvent<'a> {
Midi {
channel: u4,
message: MidiMessage,
},
Common(SystemCommon<'a>),
Realtime(SystemRealtime),
}Expand description
A live event produced by an OS API or generated on-the-fly, in contrast with “dead”
TrackEvents stored in a .mid file.
See the live module for more information.
Variants§
Midi
A MIDI message associated with a channel, carrying musical data.
Status byte in the range 0x80 ..= 0xEF.
Fields
message: MidiMessageThe MIDI message type and associated data.
Common(SystemCommon<'a>)
A System Common message, as defined by the MIDI spec, including System Exclusive events.
Status byte in the range 0xF0 ..= 0xF7.
Realtime(SystemRealtime)
A one-byte System Realtime message.
Status byte in the range 0xF8 ..= 0xFF.
Implementations§
Source§impl<'a> LiveEvent<'a>
impl<'a> LiveEvent<'a>
Sourcepub fn parse(raw: &'a [u8]) -> Result<LiveEvent<'a>>
pub fn parse(raw: &'a [u8]) -> Result<LiveEvent<'a>>
Parse a complete MIDI message from its raw bytes.
This method can be used to parse raw MIDI bytes coming from an OS API (ie. a status byte
in the range 0x80 ..= 0xFF followed by data bytes in the range 0x00 ..= 0x7F).
Note that this function will not read the “meta messages” present in .mid files, since
those cannot appear in a live MIDI connection, only in offline files.
Also see the example in the root crate documentation.
Sourcepub fn write<W: Write>(&self, out: &mut W) -> WriteResult<W>
pub fn write<W: Write>(&self, out: &mut W) -> WriteResult<W>
Write a standalone message to the given output.
This method can be used to write messages to be consumed by OS APIs. Also see the example in the root crate documentation.
Sourcepub fn write_with_running_status<W: Write>(
&self,
running_status: &mut Option<u8>,
out: &mut W,
) -> WriteResult<W>
pub fn write_with_running_status<W: Write>( &self, running_status: &mut Option<u8>, out: &mut W, ) -> WriteResult<W>
Write a message, skipping the status if it shares the status with the previous message.
Note that it’s usually discouraged to feed messages with running status to OS APIs.
Sourcepub fn write_std<W: Write>(&self, out: W) -> Result<()>
pub fn write_std<W: Write>(&self, out: W) -> Result<()>
Write a standalone message to the given std::io::Write output.
This method is only available with the std feature enabled.
Sourcepub fn write_std_with_running_status<W: Write>(
&self,
running_status: &mut Option<u8>,
out: W,
) -> Result<()>
pub fn write_std_with_running_status<W: Write>( &self, running_status: &mut Option<u8>, out: W, ) -> Result<()>
Write a message, skipping the status if it shares the status with the previous message.
Note that it’s usually discouraged to feed messages with running status to OS APIs.
This method is only available with the std feature enabled.
Sourcepub fn to_static(&self) -> LiveEvent<'static>
pub fn to_static(&self) -> LiveEvent<'static>
Remove any lifetimed data from this event to create a LiveEvent with 'static
lifetime that can be stored and moved everywhere, solving borrow checker issues.
WARNING: Any bytestrings, including SysEx dumps, will be replaced by empty bytestrings.
Sourcepub fn as_track_event<'b>(&self, arena: &'b Arena) -> TrackEventKind<'b>
pub fn as_track_event<'b>(&self, arena: &'b Arena) -> TrackEventKind<'b>
Convert this LiveEvent into a static TrackEventKind,
which can be written to a .mid file.
This method takes an Arena allocator, since all
LiveEvent variants other than Midi require allocation to be converted.
Unlike as_live_event, this method
does not return an Option.
Any messages that do not have an analogous TrackEventKind variant will be encoded into
their raw bytes and converted as TrackEventKind::Escape.
This method is only available with the alloc feature enabled.
Trait Implementations§
impl<'a> Copy for LiveEvent<'a>
impl<'a> Eq for LiveEvent<'a>
impl<'a> StructuralPartialEq for LiveEvent<'a>
Auto Trait Implementations§
impl<'a> Freeze for LiveEvent<'a>
impl<'a> RefUnwindSafe for LiveEvent<'a>
impl<'a> Send for LiveEvent<'a>
impl<'a> Sync for LiveEvent<'a>
impl<'a> Unpin for LiveEvent<'a>
impl<'a> UnwindSafe for LiveEvent<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more