Skip to main content

Instruction

Enum Instruction 

Source
pub enum Instruction {
    PlayNote {
        midi_note: MidiNote,
        len: u32,
        channel_id: u8,
    },
    StartNote {
        midi_note: MidiNote,
        channel_id: u8,
    },
    StopNote {
        midi_note: MidiNote,
        channel_id: u8,
    },
    SendCC {
        channel_id: u8,
        parameter: u8,
        value: u8,
    },
    StopAllNotes,
    MidiMessage {
        midi_message: MidiMessage,
    },
    Continue,
    Start,
    Stop,
}
Expand description

Represents instructions that can be interpreted and processed by the MidiController.

These instructions are used to generate and send MIDI messages.

Variants§

§

PlayNote

Plays a note for a specified duration on a given MIDI channel.

Fields

§midi_note: MidiNote

The MIDI note to play.

§len: u32

Duration of the note in MIDI clock ticks (1 tick = 1/24 of a quarter note at the current BPM).

§channel_id: u8

The MIDI channel to send the message on (1–16).

§

StartNote

Starts playing a MIDI note without specifying a duration.

Requires a corresponding Instruction::StopNote to stop the note.

Fields

§midi_note: MidiNote

The MIDI note to start.

§channel_id: u8

MIDI channel (1–16) to use.

§

StopNote

Stops a previously started MIDI note.

Fields

§midi_note: MidiNote

The MIDI note to stop.

§channel_id: u8

MIDI channel (1–16) used when the note was started.

§

SendCC

Sends a MIDI Control Change (CC) message.

Fields

§channel_id: u8

MIDI channel (1–16).

§parameter: u8

The controller number (0–127).

§value: u8

The controller value (0–127).

§

StopAllNotes

Stops all currently playing notes.

§

MidiMessage

Sends a raw MIDI message directly.

Fields

§midi_message: MidiMessage

The raw MIDI message to send.

§

Continue

Sends a MIDI Continue message to resume playback.

This instruction is not intended to be called manually. Prefer calling crate::Context::resume instead.

§

Start

Sends a MIDI Start message to begin playback from the start.

This instruction is not intended to be called manually. Prefer calling crate::Context::start instead.

§

Stop

Sends a MIDI Stop message to halt playback.

This instruction is not intended to be called manually. Prefer calling crate::Context::pause instead.

Implementations§

Source§

impl Instruction

Source

pub fn transpose(&mut self, semitones: i8)

Transposes the note in the instruction by the given number of semitones.

This function is only applicable when the Instruction variant is Instruction::PlayNote, Instruction::StartNote, or Instruction::StopNote.

Trait Implementations§

Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Instruction

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Instruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Instruction

Source§

fn eq(&self, other: &Instruction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Instruction

Source§

impl StructuralPartialEq for Instruction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.