Skip to content

Commit

Permalink
[MusicXML] import ornament as ornament
Browse files Browse the repository at this point in the history
Backport of musescore#25870
  • Loading branch information
rettinghaus authored and Jojo-Schmitz committed Dec 18, 2024
1 parent f00df7a commit 7a5f3a0
Showing 1 changed file with 42 additions and 11 deletions.
53 changes: 42 additions & 11 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 == u"above")
turn->setAnchor(ArticulationAnchor::TOP_CHORD);
else if (place == u"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
//---------------------------------------------------------
Expand All @@ -1217,9 +1243,12 @@ static void addOtherOrnamentToChord(const Notation& notation, ChordRest* cr)
sym = Sym::name2id(symname);

if (sym != SymId::noSym) {
Articulation* na = new Articulation(cr->score());
na->setSymId(sym);
cr->add(na);
const QColor color { notation.attribute("color") };
Articulation* ornam = new Articulation(cr->score());
ornam ->setSymId(sym);
if (color.isValid()/* && preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTLAYOUT)*/)
ornam->setColor(color);
cr->add(ornam);
}
else {
qDebug("unknown ornament: name '%s': '%s'.", qPrintable(name), qPrintable(symname));
Expand Down Expand Up @@ -8251,6 +8280,8 @@ void MusicXMLParserNotations::addNotation(const Notation& notation, ChordRest* c
if (notation.symId() != SymId::noSym) {
if (notation.name() == "fermata")
addFermataToChord(notation, cr);
else if (notation.name() == "turn")
addTurnToChord(notation, cr);
else
addArticulationToChord(notation, cr);
}
Expand Down Expand Up @@ -8360,7 +8391,7 @@ void MusicXMLParserPass2::stem(Direction& sd, bool& nost)

void MusicXMLParserNotations::fermata()
{
Notation notation = Notation::notationWithAttributes(_e.name().toString(), _e.attributes(), "notations");
Notation notation = Notation::notationWithAttributes(_e.name().toString(), _e.attributes(), "ornaments");
const QString fermataText = _e.readElementText();

notation.setSymId(convertFermataToSymId(fermataText));
Expand Down

0 comments on commit 7a5f3a0

Please sign in to comment.