Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MusicXML] import ornament as ornament #729

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 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 == "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
//---------------------------------------------------------
Expand All @@ -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));
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down
Loading