[][src]Enum wmidi::MidiMessage

pub enum MidiMessage<'a> {
    NoteOff(ChannelNoteVelocity),
    NoteOn(ChannelNoteVelocity),
    PolyphonicKeyPressure(ChannelNoteVelocity),
    ControlChange(ChannelControlNumberControlValue),
    ProgramChange(ChannelProgramNumber),
    ChannelPressure(ChannelVelocity),
    PitchBendChange(ChannelPitchBend),
    SysEx(&'a [U7]),
    OwnedSysEx(Vec<U7>),
    MidiTimeCode(U7),
    SongPositionPointer(SongPosition),
    SongSelect(Song),
    Reserved(u8),
    TuneRequest,
    TimingClock,
    Start,
    Continue,
    Stop,
    ActiveSensing,
    Reset,
}

Holds information based on the Midi 1.0 spec.

Variants

NoteOff(ChannelNoteVelocity)

This message is sent when a note is released (ended).

NoteOn(ChannelNoteVelocity)

This message is sent when a note is depressed (start).

PolyphonicKeyPressure(ChannelNoteVelocity)

This message is most often sent by pressing down on the key after it "bottoms out".

ControlChange(ChannelControlNumberControlValue)

This message is sent when a controller value changes. Controllers include devices such as pedals and levers.

Controller numbers 120-127 are reserved as "Channel Mode Messages".

ProgramChange(ChannelProgramNumber)

This message is sent when the patch number changes.

ChannelPressure(ChannelVelocity)

This message is most often sent by pressing down on the key after it "bottoms out". This message is different from polyphonic after-touch. Use this message to send the single greatest pressure value (of all the current depressed keys).

PitchBendChange(ChannelPitchBend)

This message is sent to indicate a change in the pitch bender (wheel or level, typically). The pitch bender is measured by a fourteen bit value. Center is 8192.

SysEx(&'a [U7])

This message type allows manufacturers to create their own messages (such as bulk dumps, patch parameters, and other non-spec data) and provides a mechanism for creating additional MIDI Specification messages.

In the data held by the SysEx message, the Manufacturer's ID code (assigned by MMA or AMEI) is either 1 byte or 3 bytes. Two of the 1 Byte IDs are reserved for extensions called Universal Exclusive Messages, which are not manufacturer-specific. If a device recognizes the ID code as its own (or as a supported Universal message) it will listen to the rest of the message. Otherwise the message will be ignored.

OwnedSysEx(Vec<U7>)

This message type allows manufacturers to create their own messages (such as bulk dumps, patch parameters, and other non-spec data) and provides a mechanism for creating additional MIDI Specification messages.

In the data held by the SysEx message, the Manufacturer's ID code (assigned by MMA or AMEI) is either 1 byte or 3 bytes. Two of the 1 Byte IDs are reserved for extensions called Universal Exclusive Messages, which are not manufacturer-specific. If a device recognizes the ID code as its own (or as a supported Universal message) it will listen to the rest of the message. Otherwise the message will be ignored.

MidiTimeCode(U7)

MIDI Time Code Quarter Frame.

The data is in the format 0nnndddd where nnn is the Message Type and dddd is the Value.

TODO: Interpret data instead of providing the raw format.

SongPositionPointer(SongPosition)

This is an internal 14 bit value that holds the number of MIDI beats (1 beat = six MIDI clocks) since the start of the song.

SongSelect(Song)

The Song Select specifies which sequence or song is to be played.

Reserved(u8)

The u8 data holds the status byte.

TuneRequest

Upon receiving a Tune Request, all analog synthesizers should tune their oscillators.

TimingClock

Timing Clock. Sent 24 times per quarter note when synchronization is required.

Start

Start the current sequence playing. (This message will be followed with Timing Clocks).

Continue

Continue at the point the sequence was Stopped.

Stop

Stop the current sequence.

ActiveSensing

This message is intended to be sent repeatedly to tell the receiver that a connection is alive. Use of this message is optional. When initially received, the receiver will expect to receive another Active Sensing message each 300ms (max), and if it idoes not, then it will assume that the connection has been terminated. At termination, the receiver will turn off all voices and return to normal (non-active sensing) operation.

Reset

Reset all receivers in the system to power-up status. This should be used sparingly, preferably under manual control. In particular, it should not be sent on power-up.

Methods

impl<'a> MidiMessage<'a>[src]

pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, Error>[src]

Deprecated since 2.0.0:

Use MidiMessage::try_from instead.

Construct a midi message from bytes. Use MidiMessage::try_from(bytes) instead.

pub fn drop_unowned_sysex(self) -> Option<MidiMessage<'static>>[src]

Return Some(midi_message) if self is not a SysEx message, or None if it is. This expands the lifetime of the MidiMessage from 'a to 'static.

Important traits for MidiMessage<'a>
pub fn to_owned(&self) -> MidiMessage<'static>[src]

Take ownership of the SysEx data. This expands the lifetime of the message to 'static. If 'static lifetime is needed but SysEx messages can be dropped, consider using self.drop_unowned_sysex().

pub fn wire_size(&self) -> usize[src]

The number of bytes the MIDI message takes when encoded with the std::io::Read trait.

pub fn channel(&self) -> Option<Channel>[src]

The channel associated with the MIDI message, if applicable for the message type.

Trait Implementations

impl<'a> PartialEq<MidiMessage<'a>> for MidiMessage<'a>[src]

impl<'a> Clone for MidiMessage<'a>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a> Eq for MidiMessage<'a>[src]

impl<'a> Debug for MidiMessage<'a>[src]

impl<'a> TryFrom<&'a [u8]> for MidiMessage<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(bytes: &'a [u8]) -> Result<Self, Self::Error>[src]

Construct a midi message from bytes.

impl<'a> Read for MidiMessage<'a>[src]

fn read_vectored(&mut self, bufs: &mut [IoSliceMut]) -> Result<usize, Error>1.36.0[src]

Like read, except that it reads into a slice of buffers. Read more

unsafe fn initializer(&self) -> Initializer[src]

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. Read more

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>1.0.0[src]

Read all bytes until EOF in this source, placing them into buf. Read more

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>1.0.0[src]

Read all bytes until EOF in this source, appending them to buf. Read more

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>1.6.0[src]

Read the exact number of bytes required to fill buf. Read more

fn by_ref(&mut self) -> &mut Self1.0.0[src]

Creates a "by reference" adaptor for this instance of Read. Read more

fn bytes(self) -> Bytes<Self>1.0.0[src]

Transforms this Read instance to an [Iterator] over its bytes. Read more

fn chain<R>(self, next: R) -> Chain<Self, R> where
    R: Read
1.0.0[src]

Creates an adaptor which will chain this stream with another. Read more

fn take(self, limit: u64) -> Take<Self>1.0.0[src]

Creates an adaptor which will read at most limit bytes from it. Read more

Auto Trait Implementations

impl<'a> Send for MidiMessage<'a>

impl<'a> Unpin for MidiMessage<'a>

impl<'a> Sync for MidiMessage<'a>

impl<'a> UnwindSafe for MidiMessage<'a>

impl<'a> RefUnwindSafe for MidiMessage<'a>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]