pub enum ChannelMessage {
NoteOff {
key: u8,
velocity: u8,
},
NoteOn {
key: u8,
velocity: u8,
},
PolyKeyPressure {
key: u8,
pressure: u8,
},
ControlChange {
controller: u8,
value: u8,
},
ProgramChange {
program: u8,
},
ChannelPressure {
pressure: u8,
},
PitchBend {
value: u16,
},
}Expand description
A channel voice message, without its channel.
Data bytes are 7-bit: every field except ChannelMessage::PitchBend holds
0..=127, and the decoder never produces anything else. A note-on with
velocity zero is reported as it arrived rather than rewritten into a note-off,
because the two are distinguishable on the wire and some devices mean the
difference.
Variants§
NoteOff
Key released.
NoteOn
Key pressed.
PolyKeyPressure
Per-key aftertouch.
ControlChange
Continuous controller.
ProgramChange
Program change.
ChannelPressure
Channel aftertouch.
PitchBend
Pitch bend, 14 bits.
Fields
value: u16Bend position, 0..=16383, centred on ChannelMessage::BEND_CENTRE.
Implementations§
Source§impl ChannelMessage
impl ChannelMessage
Sourcepub const BEND_CENTRE: u16 = 8192
pub const BEND_CENTRE: u16 = 8192
Pitch bend value meaning no bend.
Sourcepub const fn status_nibble(self) -> u8
pub const fn status_nibble(self) -> u8
Returns the high nibble of this message’s status byte.
Sourcepub const fn data_len_for(status: u8) -> Option<usize>
pub const fn data_len_for(status: u8) -> Option<usize>
Returns how many data bytes follow the status byte of status.
Returns None for a byte that is not a channel status byte.
Sourcepub const fn encoded_len(self) -> usize
pub const fn encoded_len(self) -> usize
Returns the number of bytes encode_into writes.
Sourcepub fn encode_into(self, channel: Channel, out: &mut [u8]) -> Result<usize>
pub fn encode_into(self, channel: Channel, out: &mut [u8]) -> Result<usize>
Writes this message to out, status byte first.
Values wider than their field are masked to 7 bits rather than rejected, so a caller that has already range-checked a value pays nothing and one that has not cannot emit a byte that would be read as a status.
§Errors
Returns Error::BufferTooSmall when out is shorter than
encoded_len.
Trait Implementations§
Source§impl Clone for ChannelMessage
impl Clone for ChannelMessage
impl Copy for ChannelMessage
Source§impl Debug for ChannelMessage
impl Debug for ChannelMessage
Source§impl<'de> Deserialize<'de> for ChannelMessage
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ChannelMessage
serde only.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>,
Source§impl Display for ChannelMessage
impl Display for ChannelMessage
impl Eq for ChannelMessage
Source§impl Hash for ChannelMessage
impl Hash for ChannelMessage
Source§impl Ord for ChannelMessage
impl Ord for ChannelMessage
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ChannelMessage
impl PartialEq for ChannelMessage
Source§impl PartialOrd for ChannelMessage
impl PartialOrd for ChannelMessage
Source§impl Serialize for ChannelMessage
Available on crate feature serde only.
impl Serialize for ChannelMessage
serde only.