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.
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
.
ChannelMode
Channel-level messages that should alter the mode of the receiver.
RunningChannelMode
Like RunningChannelVoice
but for ChannelMode
SystemCommon
Fields
msg: SystemCommonMsg
A fairly limited set of messages, generally for device synchronization.
SystemRealTime
Fields
msg: SystemRealTimeMsg
Another limited set of messages used for device synchronization.
SystemExclusive
Fields
msg: SystemExclusiveMsg
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.
Implementations§
source§impl MidiMsg
impl MidiMsg
sourcepub fn from_midi(m: &[u8]) -> Result<(Self, usize), ParseError>
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.
sourcepub fn from_midi_with_context(
m: &[u8],
ctx: &mut ReceiverContext
) -> Result<(Self, usize), ParseError>
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.
sourcepub fn from_midi_with_context_no_extensions(
m: &[u8],
ctx: &mut ReceiverContext
) -> Result<(Self, usize), ParseError>
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
.
sourcepub fn messages_to_midi(msgs: &[Self]) -> Vec<u8> ⓘ
pub fn messages_to_midi(msgs: &[Self]) -> Vec<u8> ⓘ
Turn a set of MidiMsg
s into a series of bytes, with fewer allocations than
repeatedly concatenating the results of to_midi
.
sourcepub fn extend_midi(&self, v: &mut Vec<u8>)
pub fn extend_midi(&self, v: &mut Vec<u8>)
Given a Vec<u8>
, append this MidiMsg
to it.