Enum midi_msg::MidiMsg

source ·
pub enum MidiMsg {
    ChannelVoice {
        channel: Channel,
        msg: ChannelVoiceMsg,
    },
    RunningChannelVoice {
        channel: Channel,
        msg: ChannelVoiceMsg,
    },
    ChannelMode {
        channel: Channel,
        msg: ChannelModeMsg,
    },
    RunningChannelMode {
        channel: Channel,
        msg: ChannelModeMsg,
    },
    SystemCommon {
        msg: SystemCommonMsg,
    },
    SystemRealTime {
        msg: SystemRealTimeMsg,
    },
    SystemExclusive {
        msg: SystemExclusiveMsg,
    },
    Meta {
        msg: Meta,
    },
}
Expand description

The primary interface of this library. Used to encode MIDI messages.

Variants§

§

ChannelVoice

Channel-level messages that act on a voice, such as turning notes on and off.

Fields

§channel: Channel
§

RunningChannelVoice

Like ChannelVoice, but with the first “status” byte of the message omitted. When these “running status” messages are sent, the receiver must treat them as implicitly referring to the previous “status” received.

For instance, if a ChannelVoiceMsg::NoteOn message is received, and then the next message does not contain a status byte, it implicitly refers to a ChannelVoiceMsg::NoteOn.

Fields

§channel: Channel
§

ChannelMode

Channel-level messages that should alter the mode of the receiver.

Fields

§channel: Channel
§

RunningChannelMode

Like RunningChannelVoice but for ChannelMode

Fields

§channel: Channel
§

SystemCommon

A fairly limited set of messages, generally for device synchronization.

§

SystemRealTime

Another limited set of messages used for device synchronization.

§

SystemExclusive

The bulk of the MIDI spec lives here, in “Universal System Exclusive” messages. Also the home of manufacturer-specific messages.

§

Meta

A Meta event, which occur within MIDI files.

Fields

§msg: Meta

Implementations§

source§

impl MidiMsg

source

pub fn to_midi(&self) -> Vec<u8>

Turn a MidiMsg into a series of bytes.

source

pub fn from_midi(m: &[u8]) -> Result<(Self, usize), ParseError>

Turn a series of bytes into a MidiMsg.

Ok results return a MidiMsg and the number of bytes consumed from the input.

source

pub fn from_midi_with_context( m: &[u8], ctx: &mut ReceiverContext ) -> Result<(Self, usize), ParseError>

Turn a series of bytes into a MidiMsg, given a ReceiverContext.

Consecutive messages that relate to each other will be collapsed into one MidiMsg. E.g. a ChannelVoiceMsg::ControlChange where the CC is the MSB and LSB of ControlChange::Volume will turn into a single ControlChange::Volume with both bytes turned into one. Use MidiMsg::from_midi_with_context_no_extensions to disable this behavior.

The ReceiverContext is also used to track the current TimeCode as sent through SystemCommonMsg::TimeCodeQuarterFrame messages, or UniversalRealTimeMsg::TimeCodeFull messages.

Ok results return a MidiMsg and the number of bytes consumed from the input.

source

pub fn from_midi_with_context_no_extensions( m: &[u8], ctx: &mut ReceiverContext ) -> Result<(Self, usize), ParseError>

Like MidiMsg::from_midi_with_context but does not turn multiple related consecutive messages into one MidiMsg.

source

pub fn messages_to_midi(msgs: &[Self]) -> Vec<u8>

Turn a set of MidiMsgs into a series of bytes, with fewer allocations than repeatedly concatenating the results of to_midi.

source

pub fn extend_midi(&self, v: &mut Vec<u8>)

Given a Vec<u8>, append this MidiMsg to it.

source

pub fn is_channel_voice(&self) -> bool

Returns true if this message is a channel voice message.

source

pub fn is_note(&self) -> bool

Returns true if this message is a note (on or off) message.

source

pub fn is_cc(&self) -> bool

Returns true if this message is a control change message.

source

pub fn is_channel_mode(&self) -> bool

Returns true if this message is a channel mode message.

source

pub fn is_system_common(&self) -> bool

Returns true if this message is a system common message.

source

pub fn is_system_real_time(&self) -> bool

Returns true if this message is a system real-time message.

source

pub fn is_system_exclusive(&self) -> bool

Returns true if this message is a system exclusive message.

source

pub fn is_meta(&self) -> bool

Returns true if this message is a meta message.

Trait Implementations§

source§

impl Clone for MidiMsg

source§

fn clone(&self) -> MidiMsg

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MidiMsg

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&MidiMsg> for Vec<u8>

source§

fn from(m: &MidiMsg) -> Vec<u8>

Converts to this type from the input type.
source§

impl PartialEq for MidiMsg

source§

fn eq(&self, other: &MidiMsg) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for MidiMsg

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.