Skip to content

Commit

Permalink
Fix GH musescore#19770: Add missing MusicXML import for fermatas on b…
Browse files Browse the repository at this point in the history
…arlines

Backport of musescore#20213

(Needs a part from musescore#19132, the curlew export)
  • Loading branch information
rettinghaus authored and Jojo-Schmitz committed Nov 27, 2023
1 parent ba87541 commit a2dc1ae
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 252 deletions.
3 changes: 3 additions & 0 deletions importexport/musicxml/exportxml.cpp
Expand Up @@ -1812,6 +1812,9 @@ static void fermata(const Fermata* const a, XmlWriter& xml)
else if (id == SymId::fermataShortHenzeAbove || id == SymId::fermataShortHenzeBelow) {
xml.tag(tagName, "half-curve");
}
else if (id == SymId::curlewSign) {
xml.tag(tagName, "curlew");
}
else
qDebug("unknown fermata sim id %d", int(id));
}
Expand Down
75 changes: 49 additions & 26 deletions importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -1238,6 +1238,33 @@ static bool convertArticulationToSymId(const QString& mxmlName, SymId& id)
}
}

//---------------------------------------------------------
// convertFermataToSymId
//---------------------------------------------------------

/**
Convert a MusicXML fermata name to a MuseScore fermata.
*/

static SymId convertFermataToSymId(const QString& mxmlName)
{
QMap<QString, SymId> map; // map MusicXML fermata name to MuseScore symbol
map["normal"] = SymId::fermataAbove;
map["angled"] = SymId::fermataShortAbove;
map["square"] = SymId::fermataLongAbove;
map["double-angled"] = SymId::fermataVeryShortAbove;
map["double-square"] = SymId::fermataVeryLongAbove;
map["double-dot"] = SymId::fermataLongHenzeAbove;
map["half-curve"] = SymId::fermataShortHenzeAbove;
map["curlew"] = SymId::curlewSign;

if (map.contains(mxmlName))
return map.value(mxmlName);
else
qDebug("unknown fermata %s", qPrintable(mxmlName));
return SymId::fermataAbove;
}

//---------------------------------------------------------
// convertNotehead
//---------------------------------------------------------
Expand Down Expand Up @@ -4466,6 +4493,20 @@ void MusicXMLParserPass2::barline(const QString& partId, Measure* measure, const
printEnding = _e.attributes().value("print-object").toString() != "no";
endingText = _e.readElementText();
}
else if (_e.name() == "fermata") {
const QColor fermataColor = _e.attributes().value("color").toString();
const QString fermataType = _e.attributes().value("type").toString();
const auto segment = measure->getSegment(SegmentType::EndBarLine, tick);
const int track = _pass1.trackForPart(partId);
Fermata* fermata = new Fermata(measure->score());
fermata->setSymId(convertFermataToSymId(_e.readElementText()));
fermata->setTrack(track);
segment->add(fermata);
if (fermataColor.isValid())
fermata->setColor(fermataColor);
if (fermataType == "inverted")
fermata->setPlacement(Placement::BELOW);
}
else if (_e.name() == "repeat") {
repeat = _e.attributes().value("direction").toString();
count = _e.attributes().value("times").toString();
Expand Down Expand Up @@ -7724,29 +7765,11 @@ void MusicXMLParserPass2::stem(Direction& sd, bool& nost)
void MusicXMLParserNotations::fermata()
{
Notation notation = Notation::notationWithAttributes(_e.name().toString(), _e.attributes(), "notations");
const auto fermataText = _e.readElementText();

if (fermataText == "normal" || fermataText == "")
notation.setSymId(SymId::fermataAbove);
else if (fermataText == "angled")
notation.setSymId(SymId::fermataShortAbove);
else if (fermataText == "square")
notation.setSymId(SymId::fermataLongAbove);
else if (fermataText == "double-angled")
notation.setSymId(SymId::fermataVeryShortAbove);
else if (fermataText == "double-square")
notation.setSymId(SymId::fermataVeryLongAbove);
else if (fermataText == "double-dot")
notation.setSymId(SymId::fermataLongHenzeAbove);
else if (fermataText == "half-curve")
notation.setSymId(SymId::fermataShortHenzeAbove);
const QString fermataText = _e.readElementText();

if (notation.symId() != SymId::noSym) {
notation.setText(fermataText);
_notations.push_back(notation);
}
else
_logger->logError(QString("unknown fermata '%1'").arg(fermataText), &_e);
notation.setSymId(convertFermataToSymId(fermataText));
notation.setText(fermataText);
_notations.push_back(notation);
}

//---------------------------------------------------------
Expand All @@ -7759,10 +7782,10 @@ void MusicXMLParserNotations::fermata()

void MusicXMLParserNotations::tuplet()
{
QString tupletType = _e.attributes().value("type").toString();
// QString tupletPlacement = _e.attributes().value("placement").toString(); not used (TODO)
QString tupletBracket = _e.attributes().value("bracket").toString();
QString tupletShowNumber = _e.attributes().value("show-number").toString();
const QString tupletType = _e.attributes().value("type").toString();
// const QString tupletPlacement = _e.attributes().value("placement").toString(); not used (TODO)
const QString tupletBracket = _e.attributes().value("bracket").toString();
const QString tupletShowNumber = _e.attributes().value("show-number").toString();

// ignore possible children (currently not supported)
_e.skipCurrentElement();
Expand Down
138 changes: 0 additions & 138 deletions mtest/musicxml/io/testBarlineFermatas.mscx

This file was deleted.

126 changes: 126 additions & 0 deletions mtest/musicxml/io/testBarlineFermatas.xml
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
<work>
<work-title>Fermatas on barlines</work-title>
</work>
<identification>
<creator type="composer">K. Rettinghaus</creator>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="no"/>
<supports element="print" attribute="new-system" type="no"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name></part-name>
<score-instrument id="P1-I1">
<instrument-name></instrument-name>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>1</midi-channel>
<midi-program>42</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>C</sign>
<line>3</line>
</clef>
</attributes>
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<fermata type="upright"/>
</barline>
</measure>
<measure number="2">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style>light-light</bar-style>
<fermata type="inverted" color="#FF2600">angled</fermata>
</barline>
</measure>
<measure number="3">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<fermata type="upright" color="#0096FF">square</fermata>
</barline>
</measure>
<measure number="4">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style>light-light</bar-style>
<fermata type="upright">double-dot</fermata>
<fermata type="inverted">double-dot</fermata>
</barline>
</measure>
<measure number="5">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<fermata type="upright">half-curve</fermata>
</barline>
</measure>
<measure number="6">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style>dashed</bar-style>
<fermata type="upright" color="#24680B">double-square</fermata>
<fermata type="inverted" color="#F0A2CC">curlew</fermata>
</barline>
</measure>
<measure number="7">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
<fermata type="upright">double-angled</fermata>
</barline>
</measure>
</part>
</score-partwise>

0 comments on commit a2dc1ae

Please sign in to comment.