diff --git a/importexport/musicxml/importmxmlpass2.cpp b/importexport/musicxml/importmxmlpass2.cpp index 287611c09bc8c..4d00d7ed8addc 100644 --- a/importexport/musicxml/importmxmlpass2.cpp +++ b/importexport/musicxml/importmxmlpass2.cpp @@ -1184,23 +1184,49 @@ static void addMordentToChord(const Notation& notation, ChordRest* cr) if (articSym != SymId::noSym) { const QString place = notation.attribute("placement"); const QColor color = notation.attribute("color"); - Articulation* na = new Articulation(cr->score()); - na->setSymId(articSym); + Articulation* mordent = new Articulation(cr->score()); + mordent->setSymId(articSym); if (place == "above") - na->setAnchor(ArticulationAnchor::TOP_CHORD); + mordent->setAnchor(ArticulationAnchor::TOP_CHORD); else if (place == "below") - na->setAnchor(ArticulationAnchor::BOTTOM_CHORD); + mordent->setAnchor(ArticulationAnchor::BOTTOM_CHORD); else - na->setAnchor(ArticulationAnchor::CHORD); + mordent->setAnchor(ArticulationAnchor::CHORD); if (color.isValid()/* && preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTLAYOUT)*/) - na->setColor(color); - cr->add(na); + mordent->setColor(color); + cr->add(mordent); } else qDebug("unknown ornament: name '%s' long '%s' approach '%s' departure '%s'", qPrintable(name), qPrintable(attrLong), qPrintable(attrAppr), qPrintable(attrDep)); // TODO } +//--------------------------------------------------------- +// addTurnToChord +//--------------------------------------------------------- + +/** + Add Turn to Chord. + */ + +static void addTurnToChord(const Notation& notation, ChordRest* cr) + { + const SymId turnSym = notation.symId(); + const QColor color = notation.attribute("color"); + const QString place = notation.attribute("placement"); + Articulation* turn = new Articulation(cr->score()); + turn->setSymId(turnSym); + if (place == "above") + turn->setAnchor(ArticulationAnchor::TOP_CHORD); + else if (place == "below") + turn->setAnchor(ArticulationAnchor::BOTTOM_CHORD); + else + turn->setAnchor(ArticulationAnchor::CHORD); + if (color.isValid()/* && preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTLAYOUT)*/) + turn->setColor(color); + cr->add(turn); + } + //--------------------------------------------------------- // addOtherOrnamentToChord //--------------------------------------------------------- @@ -1218,11 +1244,11 @@ static void addOtherOrnamentToChord(const Notation& notation, ChordRest* cr) if (sym != SymId::noSym) { const QColor color = notation.attribute("color"); - Articulation* na = new Articulation(cr->score()); - na->setSymId(sym); + Articulation* ornam = new Articulation(cr->score()); + ornam ->setSymId(sym); if (color.isValid()/* && preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTLAYOUT)*/) - na->setColor(color); - cr->add(na); + ornam->setColor(color); + cr->add(ornam); } else { qDebug("unknown ornament: name '%s': '%s'.", qPrintable(name), qPrintable(symname)); @@ -7622,7 +7648,7 @@ void MusicXMLParserNotations::ornaments() SymId id { SymId::noSym }; if (convertArticulationToSymId(_e.name().toString(), id)) { Notation notation = Notation::notationWithAttributes(_e.name().toString(), - _e.attributes(), "articulations", id); + _e.attributes(), "ornaments", id); _notations.push_back(notation); _e.skipCurrentElement(); // skip but don't log } @@ -8325,6 +8351,8 @@ void MusicXMLParserNotations::addNotation(const Notation& notation, ChordRest* c addBreath(notation, cr); else if (notation.name() == "fermata") addFermataToChord(notation, cr); + else if (notation.parent() == "ornament") + addTurnToChord(notation, cr); else addArticulationToChord(notation, cr); } diff --git a/mtest/musicxml/io/testOrnaments.xml b/mtest/musicxml/io/testOrnaments.xml new file mode 100644 index 0000000000000..3b35a25ddfff4 --- /dev/null +++ b/mtest/musicxml/io/testOrnaments.xml @@ -0,0 +1,342 @@ + + + + + Ornaments import test + + + Klaus Rettinghaus + + MuseScore 4.5.0 + 2024-12-19 + + + + + + + + + + Piano + Pno. + + Piano + + + + 1 + 1 + 78.7402 + 0 + + + + + + + 1 + + 0 + + + + F + 4 + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + + C + 3 + + 2 + 1 + half + up + + + + + + + + light-heavy + + + + diff --git a/mtest/musicxml/io/testOrnaments_ref.mscx b/mtest/musicxml/io/testOrnaments_ref.mscx new file mode 100644 index 0000000000000..7c030d30494ef --- /dev/null +++ b/mtest/musicxml/io/testOrnaments_ref.mscx @@ -0,0 +1,348 @@ + + + + + 0 + 480 + + 1 + 1 + 1 + 0 + + Klaus Rettinghaus + + + + + + + + + Ornaments import test + + + + stdNormal + + 3 + + Piano + + Piano + Pno. + Piano + 21 + 108 + 21 + 108 + keyboard.piano + F + + 100 + 95 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 150 + 100 + + + 150 + 50 + + + 120 + 50 + + + 120 + 100 + + + + + + + + + + 10 + + + Ornaments import test + + + + Klaus Rettinghaus + + + + + + F + F + + + 4 + 4 + + + half + + ornamentTurn + + up + + 48 + 14 + + + + half + + ornamentTurnInverted + + up + + 48 + 14 + + + + + + + + half + + ornamentTrill + + up + + 48 + 14 + + + + half + + ornamentShortTrill + + up + + 48 + 14 + + + + + + + + half + + ornamentMordent + + up + + 48 + 14 + + + + half + + ornamentTurn + + up + + 48 + 14 + + + + + + + + half + + ornamentTremblement + + up + + 48 + 14 + + + + half + + ornamentPrallMordent + + up + + 48 + 14 + + + + + + + + half + + ornamentUpPrall + + up + + 48 + 14 + + + + half + + ornamentPrecompMordentUpperPrefix + + up + + 48 + 14 + + + + + + + + half + + ornamentDownMordent + + up + + 48 + 14 + + + + half + + ornamentPrallDown + + up + + 48 + 14 + + + + + + + + half + + ornamentPrallUp + + up + + 48 + 14 + + + + half + + ornamentPrecompMordentUpperPrefix + + up + + 48 + 14 + + + + + + + + half + + ornamentPrecompSlide + + up + + 48 + 14 + + + + half + + ornamentTrill + + up + + 48 + 14 + + + + + + + + half + + ornamentTremblementCouperin + + up + + 48 + 14 + + + + half + + ornamentPinceCouperin + + up + + 48 + 14 + + + + end + + + + + + diff --git a/mtest/musicxml/io/tst_mxml_io.cpp b/mtest/musicxml/io/tst_mxml_io.cpp index a5de697cdc573..6cbcf8f1509a5 100644 --- a/mtest/musicxml/io/tst_mxml_io.cpp +++ b/mtest/musicxml/io/tst_mxml_io.cpp @@ -256,6 +256,7 @@ private slots: void notesRests2() { mxmlIoTest("testNotesRests2"); } void numberedLyrics() { mxmlIoTestRef("testNumberedLyrics"); } void numerals() { mxmlIoTest("testNumerals"); } + void ornaments() { mxmlImportTestRef("testOrnaments"); } void overlappingSpanners() { mxmlIoTest("testOverlappingSpanners"); } void partNames() { mxmlImportTestRef("testPartNames"); } void partNames2() { mxmlIoTest("testPartNames2"); }