Enum midly::live::LiveEvent

source ·
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

Fields

§channel: u4

The MIDI channel that this message is associated with.

§message: MidiMessage

The MIDI message type and associated data.

A MIDI message associated with a channel, carrying musical data.

Status byte in the range 0x80 ..= 0xEF.

§

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§

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.

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.

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.

Write a standalone message to the given std::io::Write output.

This method is only available with the std feature enabled.

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.

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.

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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.