musicxml/elements/
score_instrument.rs

1use super::{Ensemble, InstrumentAbbreviation, InstrumentName, InstrumentSound, Solo, VirtualInstrument};
2use crate::datatypes::Id;
3use alloc::{string::String, vec::Vec};
4use musicxml_internal::*;
5use musicxml_macros::*;
6
7/// Attributes pertaining to the [ScoreInstrument] element.
8#[derive(Debug, PartialEq, Eq, AttributeDeserialize, AttributeSerialize)]
9pub struct ScoreInstrumentAttributes {
10  /// Specifies an ID that is unique to the entire document.
11  pub id: Id,
12}
13
14/// Contents of the [ScoreInstrument] element.
15#[derive(Debug, PartialEq, Eq, ContentDeserialize, ContentSerialize)]
16pub struct ScoreInstrumentContents {
17  /// The [InstrumentName] element specifies the name of the instrument.
18  pub instrument_name: InstrumentName,
19  /// The [InstrumentAbbreviation] element specifies the abbreviation for the instrument name.
20  pub instrument_abbreviation: Option<InstrumentAbbreviation>,
21  /// The [InstrumentSound] element specifies the sound of the instrument.
22  pub instrument_sound: Option<InstrumentSound>,
23  /// The [Solo] element specifies the solo instrument.
24  pub solo: Option<Solo>,
25  /// The [Ensemble] element specifies the ensemble instrument.
26  pub ensemble: Option<Ensemble>,
27  /// The [VirtualInstrument] element specifies the virtual instrument.
28  pub virtual_instrument: Option<VirtualInstrument>,
29}
30
31/// The [ScoreInstrument] element represents a single instrument within a [ScorePart][super::ScorePart].
32///
33/// As with the [ScorePart][super::ScorePart] element, each [ScoreInstrument] has a required ID attribute, a name, and an optional abbreviation.
34///
35/// A [ScoreInstrument] element is also required if the score specifies MIDI 1.0 channels, banks, or programs. An initial
36/// [MidiInstrument][super::MidiInstrument] assignment can also be made here. MusicXML software should be able to automatically assign reasonable channels and
37/// instruments without these elements in simple cases, such as where part names match General MIDI instrument names.
38///
39/// The [ScoreInstrument] element can also distinguish multiple instruments of the same type that are on the same part, such as Clarinet 1 and
40/// Clarinet 2 instruments within a Clarinets 1 and 2 part.
41#[derive(Debug, PartialEq, Eq, ElementDeserialize, ElementSerialize)]
42#[rename("score-instrument")]
43pub struct ScoreInstrument {
44  /// Element-specific attributes
45  pub attributes: ScoreInstrumentAttributes,
46  #[flatten]
47  /// Element-specific content
48  pub content: ScoreInstrumentContents,
49}