pub enum StructuredShortMessage {
Show 23 variants NoteOff { channel: Channel, key_number: KeyNumber, velocity: U7, }, NoteOn { channel: Channel, key_number: KeyNumber, velocity: U7, }, PolyphonicKeyPressure { channel: Channel, key_number: KeyNumber, pressure_amount: U7, }, ControlChange { channel: Channel, controller_number: ControllerNumber, control_value: U7, }, ProgramChange { channel: Channel, program_number: U7, }, ChannelPressure { channel: Channel, pressure_amount: U7, }, PitchBendChange { channel: Channel, pitch_bend_value: U14, }, SystemExclusiveStart, TimeCodeQuarterFrame(TimeCodeQuarterFrame), SongPositionPointer { position: U14, }, SongSelect { song_number: U7, }, TuneRequest, SystemExclusiveEnd, TimingClock, Start, Continue, Stop, ActiveSensing, SystemReset, SystemCommonUndefined1, SystemCommonUndefined2, SystemRealTimeUndefined1, SystemRealTimeUndefined2,
}
Expand description

A short message implemented as an enum where each variant contains exactly the data which is relevant for the particular message type.

This enum is primarily intended for read-only usage via pattern matching. For that reason each variant is a struct-like enum, which is ideal for pattern matching while it is less ideal for reuse (the data contained in the variant can’t be passed around in one piece).

The enum’s size in memory is currently 4 bytes.

Example

use helgoboss_midi::{
    controller_numbers, Channel, RawShortMessage, ShortMessage, ShortMessageFactory,
    StructuredShortMessage, U7,
};

let msg = RawShortMessage::control_change(
    Channel::new(5),
    controller_numbers::DAMPER_PEDAL_ON_OFF,
    U7::new(100),
);
let structured_msg = msg.to_structured();
match structured_msg {
    StructuredShortMessage::ControlChange {
        channel,
        controller_number,
        control_value,
    } => {
        assert_eq!(channel.get(), 5);
        assert_eq!(controller_number.get(), 64);
        assert_eq!(control_value.get(), 100);
    }
    _ => panic!("wrong type"),
};
assert_eq!(structured_msg.channel(), Some(Channel::new(5)));
assert_eq!(core::mem::size_of_val(&structured_msg), 4);

Variants

NoteOff

Fields

channel: Channel
key_number: KeyNumber
velocity: U7

NoteOn

Fields

channel: Channel
key_number: KeyNumber
velocity: U7

PolyphonicKeyPressure

Fields

channel: Channel
key_number: KeyNumber
pressure_amount: U7

ControlChange

Fields

channel: Channel
controller_number: ControllerNumber
control_value: U7

ProgramChange

Fields

channel: Channel
program_number: U7

ChannelPressure

Fields

channel: Channel
pressure_amount: U7

PitchBendChange

Fields

channel: Channel
pitch_bend_value: U14

SystemExclusiveStart

TimeCodeQuarterFrame(TimeCodeQuarterFrame)

SongPositionPointer

Fields

position: U14

SongSelect

Fields

song_number: U7

TuneRequest

SystemExclusiveEnd

TimingClock

Start

Continue

Stop

ActiveSensing

SystemReset

SystemCommonUndefined1

SystemCommonUndefined2

SystemRealTimeUndefined1

SystemRealTimeUndefined2

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 returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the status byte.

Returns the first data byte.

Returns the second data byte.

Converts this message to a StructuredShortMessage, which is ideal for matching.

Returns the status byte and the two data bytes as a tuple. Read more

Converts this message to a short message of another type.

Returns the type of this message.

Returns the super type of this message.

Returns the main category of this message.

Returns whether this message is a note-on in a practical sense. That means, it also returns false if the message type is NoteOn but the velocity is zero. Read more

Returns whether this message is a note-off in a practical sense. That means, it also returns true if the message type is NoteOn but the velocity is zero. Read more

Returns whether this message is a note-on or note-off.

Returns the channel of this message if applicable.

Returns the key number of this message if applicable.

Returns the velocity of this message if applicable.

Returns the controller number of this message if applicable.

Returns the control value of this message if applicable.

Returns the program number of this message if applicable.

Returns the pressure amount of this message if applicable.

Returns the pitch bend value of this message if applicable.

Creates a MIDI message from the given bytes without checking the status byte. The tuple consists of the status byte, data byte 1 and data byte 2 in exactly this order. Read more

Creates a MIDI message from the given bytes. The tuple consists of the status byte, data byte 1 and data byte 2 in exactly this order. Read more

Creates this message from a MIDI message of another type.

Creates a Channel message. Read more

Creates a System Common message. Read more

Creates a System Real Time message. Read more

Creates a Note On message.

Creates a Note Off message.

Creates a Control Change message.

Creates a Program Change message.

Creates a Polyphonic Key Pressure message.

Creates a Channel Pressure message.

Creates a Pitch Bend Change message.

Creates the start of a System Exclusive message.

Creates a MIDI Time Code Quarter Frame message.

Creates a Song Position Pointer message.

Creates a Song Select message.

Creates a Tune Request message.

Creates the end of a System Exclusive message.

Creates a Timing Clock message.

Creates a Start message.

Creates a Continue message.

Creates a Stop message.

Creates an Active Sensing message.

Creates a System Reset message.

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 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.