Skip to main content

MidiInstrumentModel

Struct MidiInstrumentModel 

Source
pub struct MidiInstrumentModel {
    pub program: Option<u8>,
    pub channel: Option<u8>,
    pub volume_cc: Option<u8>,
    pub pan_cc: Option<u8>,
    pub midi_unpitched: Option<u8>,
    pub span: Span,
}
Expand description

A score-level MIDI instrument projected from a voice’s %%MIDI program / channel / control / midi-unpitched directives.

%%MIDI is an abc2midi convention, not part of ABC 2.1; the score-meaningful fields (instrument identity, channel, CC7 volume, CC10 pan, unpitched percussion key) are forward-translated to MusicXML <score-instrument> / <midi-instrument> while the raw directive text stays in ScoreMetadata::preserved_directives for round-trip / formatter use.

Fields§

§program: Option<u8>

General MIDI program number exactly as written in the directive (0-based, abc2midi/GM convention). The MusicXML <midi-program> is this value plus one (1-based). None when no program was declared.

§channel: Option<u8>

MIDI channel (1-16) from the two-integer program <chan> <prog> form or a sibling %%MIDI channel directive in the same voice. None when no channel was declared.

§volume_cc: Option<u8>

MIDI CC7 (channel volume) value 0-127 from %%MIDI control 7 <n>, rendered as <midi-instrument><volume> (n / 1.27). None when unset.

§pan_cc: Option<u8>

MIDI CC10 (pan) value 0-127 from %%MIDI control 10 <n>, rendered as <midi-instrument><pan> (n / 127 * 180 - 90). None when unset.

§midi_unpitched: Option<u8>

MusicXML <midi-unpitched> value for unpitched percussion playback (1-128). None when the instrument is pitched or unspecified.

§span: Span

Source span of the directive that last set this instrument.

Implementations§

Source§

impl MidiInstrumentModel

Source

pub fn has_content(&self) -> bool

True when this projection carries at least one field worth emitting as a MusicXML <score-instrument> / <midi-instrument>.

Trait Implementations§

Source§

impl Clone for MidiInstrumentModel

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for MidiInstrumentModel

Source§

impl Debug for MidiInstrumentModel

Source§

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

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

impl Eq for MidiInstrumentModel

Source§

impl PartialEq for MidiInstrumentModel

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MidiInstrumentModel

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.