pub trait ShortMessageFactory: ShortMessage + Sized {
Show 25 methods unsafe fn from_bytes_unchecked(bytes: (u8, U7, U7)) -> Self; fn from_bytes(bytes: (u8, U7, U7)) -> Result<Self, FromBytesError> { ... } fn from_other(msg: &impl ShortMessage) -> Self { ... } fn channel_message(
        type: ShortMessageType,
        channel: Channel,
        data_1: U7,
        data_2: U7
    ) -> Self { ... } fn system_common_message(
        type: ShortMessageType,
        data_1: U7,
        data_2: U7
    ) -> Self { ... } fn system_real_time_message(type: ShortMessageType) -> Self { ... } fn note_on(channel: Channel, key_number: KeyNumber, velocity: U7) -> Self { ... } fn note_off(channel: Channel, key_number: KeyNumber, velocity: U7) -> Self { ... } fn control_change(
        channel: Channel,
        controller_number: ControllerNumber,
        control_value: U7
    ) -> Self { ... } fn program_change(channel: Channel, program_number: U7) -> Self { ... } fn polyphonic_key_pressure(
        channel: Channel,
        key_number: KeyNumber,
        pressure_amount: U7
    ) -> Self { ... } fn channel_pressure(channel: Channel, pressure_amount: U7) -> Self { ... } fn pitch_bend_change(channel: Channel, pitch_bend_value: U14) -> Self { ... } fn system_exclusive_start() -> Self { ... } fn time_code_quarter_frame(frame: TimeCodeQuarterFrame) -> Self { ... } fn song_position_pointer(position: U14) -> Self { ... } fn song_select(song_number: U7) -> Self { ... } fn tune_request() -> Self { ... } fn system_exclusive_end() -> Self { ... } fn timing_clock() -> Self { ... } fn start() -> Self { ... } fn continue() -> Self { ... } fn stop() -> Self { ... } fn active_sensing() -> Self { ... } fn system_reset() -> Self { ... }
}
Expand description

Static methods for creating short MIDI messages.

This trait is supposed to be implemented for structs that represent a short MIDI message and also support their creation. Only one method needs to be implemented, the rest is done by default methods.

Required Methods

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.

Safety

Callers must make sure that the given status byte is valid, otherwise an invalid MIDI message will be created.

Implementations can therefore assume that the given status byte is valid. This method is usually called by from_bytes, which checks the necessary preconditions.

Provided Methods

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.

Errors

If the given status byte is invalid, an error will be returned.

Design

Although one could argue that calling such a function with illegal input values is a violation of its contract, this function returns a result rather than panicking. It’s because - unlike the functions in test_util - this function is primarily intended to be used in real-world situations where the bytes come from somewhere else (e.g. from a DAW) and therefore acts a bit like a parse function where client code should be able to recover from wrong input.

Creates this message from a MIDI message of another type.

Creates a Channel message.

Panics

This function panics if the given type is not a channel message type.

Creates a System Common message.

Panics

This function panics if the given type is not a System Common message type.

Creates a System Real Time message.

Panics

This function panics if the given type is not a System Real Time message type.

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.

Implementors