diff --git a/src/importexport/musicxml/internal/musicxml/exportxml.cpp b/src/importexport/musicxml/internal/musicxml/exportxml.cpp index 480cb00500f1b..059ce6722c06d 100644 --- a/src/importexport/musicxml/internal/musicxml/exportxml.cpp +++ b/src/importexport/musicxml/internal/musicxml/exportxml.cpp @@ -391,6 +391,7 @@ class ExportMusicXml : public muse::Injectable double getTenthsFromInches(double) const; double getTenthsFromDots(double) const; Fraction tick() const { return m_tick; } + void writeInstrumentChange(const InstrumentChange* instrChange); void writeInstrumentDetails(const Instrument* instrument, const bool concertPitch); static bool canWrite(const EngravingItem* e); @@ -6365,7 +6366,7 @@ static bool commonAnnotations(ExportMusicXml* exp, const EngravingItem* e, staff // optionally writing the associated staff text is done below if (e->isInstrumentChange()) { const InstrumentChange* instrChange = toInstrumentChange(e); - exp->writeInstrumentDetails(instrChange->instrument(), false); + exp->writeInstrumentChange(instrChange); instrChangeHandled = true; } @@ -7731,6 +7732,45 @@ static void writeStaffDetails(XmlWriter& xml, const Part* part) } } +//--------------------------------------------------------- +// writeInstrumentChange +//--------------------------------------------------------- + +/** + Write the instrument change. + */ + +void ExportMusicXml::writeInstrumentChange(const InstrumentChange* instrChange) +{ + const Instrument* instr = instrChange->instrument(); + const Part* part = instrChange->part(); + const size_t partNr = muse::indexOf(m_score->parts(), part); + const int instNr = muse::value(m_instrMap, instr, -1); + const String longName = instr->nameAsPlainText(); + const String shortName = instr->abbreviatureAsPlainText(); + + m_xml.startElement("print"); + if (!longName.isEmpty()) { + m_xml.startElement("part-name-display"); + writeDisplayName(m_xml, longName); + m_xml.endElement(); + } + if (!shortName.isEmpty()) { + m_xml.startElement("part-abbreviation-display"); + writeDisplayName(m_xml, shortName); + m_xml.endElement(); + } + m_xml.endElement(); + + writeInstrumentDetails(instr, m_score->style().styleB(Sid::concertPitch)); + + m_xml.startElement("sound"); + m_xml.startElement("instrument-change"); + scoreInstrument(m_xml, static_cast(partNr) + 1, instNr + 1, instr->trackName(), instr); + m_xml.endElement(); + m_xml.endElement(); +} + //--------------------------------------------------------- // writeInstrumentDetails //--------------------------------------------------------- diff --git a/src/importexport/musicxml/tests/data/testChangeTranspose-no-diatonic_ref.xml b/src/importexport/musicxml/tests/data/testChangeTranspose-no-diatonic_ref.xml index 1258193551636..3a1951910a203 100644 --- a/src/importexport/musicxml/tests/data/testChangeTranspose-no-diatonic_ref.xml +++ b/src/importexport/musicxml/tests/data/testChangeTranspose-no-diatonic_ref.xml @@ -100,12 +100,27 @@ 2 + + + A Clarinet + + + A Cl. + + -1 -2 + + + + B♭ Clarinet + + + To B♭ Clarinet diff --git a/src/importexport/musicxml/tests/data/testChangeTranspose.xml b/src/importexport/musicxml/tests/data/testChangeTranspose.xml index b690658f66625..d4c72d1a3e1c9 100644 --- a/src/importexport/musicxml/tests/data/testChangeTranspose.xml +++ b/src/importexport/musicxml/tests/data/testChangeTranspose.xml @@ -100,12 +100,27 @@ 2 + + + A Clarinet + + + A Cl. + + -1 -2 + + + + B♭ Clarinet + + + To B♭ Clarinet diff --git a/src/importexport/musicxml/tests/data/testInstrumentChangeMIDIportExport_ref.xml b/src/importexport/musicxml/tests/data/testInstrumentChangeMIDIportExport_ref.xml index e11f4cda0f3bc..a7938d6c8997b 100644 --- a/src/importexport/musicxml/tests/data/testInstrumentChangeMIDIportExport_ref.xml +++ b/src/importexport/musicxml/tests/data/testInstrumentChangeMIDIportExport_ref.xml @@ -1060,6 +1060,21 @@ + + + Voice + + + Vo. + + + + + + Voice + + + Voice diff --git a/src/importexport/musicxml/tests/data/testMultiInstrumentPart1.xml b/src/importexport/musicxml/tests/data/testMultiInstrumentPart1.xml index fddb90c401dae..78bd5afd99eb8 100644 --- a/src/importexport/musicxml/tests/data/testMultiInstrumentPart1.xml +++ b/src/importexport/musicxml/tests/data/testMultiInstrumentPart1.xml @@ -83,6 +83,21 @@ + + + Piano + + + Pno. + + + + + + Flute + + + Flute diff --git a/src/importexport/musicxml/tests/data/testMultiInstrumentPart2.xml b/src/importexport/musicxml/tests/data/testMultiInstrumentPart2.xml index 3118a5e2d7076..3138a4b4e4c97 100644 --- a/src/importexport/musicxml/tests/data/testMultiInstrumentPart2.xml +++ b/src/importexport/musicxml/tests/data/testMultiInstrumentPart2.xml @@ -107,6 +107,21 @@ + + + Piano + + + Pno. + + + + + + Flute + + + Flute @@ -246,6 +261,21 @@ + + + Voice + + + Vo. + + + + + + C Trumpet + + + Trumpet diff --git a/src/importexport/musicxml/tests/data/testMultiInstrumentPart3_ref.xml b/src/importexport/musicxml/tests/data/testMultiInstrumentPart3_ref.xml index 1d5d86cc1e518..58a0036dbc75e 100644 --- a/src/importexport/musicxml/tests/data/testMultiInstrumentPart3_ref.xml +++ b/src/importexport/musicxml/tests/data/testMultiInstrumentPart3_ref.xml @@ -168,12 +168,31 @@ -3 + + + B + flat + Clarinet + + + B + flat + Cl. + + -1 -2 + + + + B♭ Clarinet + + + B♭ Clarinet