Skip to content

Commit

Permalink
Add support for the sostenuto pedal signs to MusicXML import/export
Browse files Browse the repository at this point in the history
Backport of (the MusicXML part of) musescore#20219
  • Loading branch information
rettinghaus authored and Jojo-Schmitz committed Dec 2, 2023
1 parent 4d9efea commit beccff5
Show file tree
Hide file tree
Showing 7 changed files with 1,652 additions and 940 deletions.
8 changes: 5 additions & 3 deletions importexport/musicxml/exportxml.cpp
Expand Up @@ -4732,15 +4732,17 @@ void ExportMusicXml::pedal(Pedal const* const pd, int staff, const Fraction& tic
break;
case HookType::NONE:
if (pd->beginText() == "") {
pedalType = "resume";
pedalType = pd->lineVisible() ? "resume" : "start";
break;
}
// FALLTHROUGH
default:
pedalType = "start";
}
signText = pd->beginText() == "" ? " sign=\"no\"" : " sign=\"yes\"";
signText = pd->beginText().isEmpty() ? " sign=\"no\"" : " sign=\"yes\"";
signText += color2xml(pd);
if (pd->beginText() == "<sym>keyboardPedalSost</sym>" || pd->beginText() == "<sym>keyboardPedalS</sym>")
pedalType = "sostenuto";
}
else {
if (!pd->endText().isEmpty() || pd->endHookType() == HookType::HOOK_90)
Expand All @@ -4749,7 +4751,7 @@ void ExportMusicXml::pedal(Pedal const* const pd, int staff, const Fraction& tic
pedalType = "discontinue";
// "change" type is handled only on the beginning of pedal lines

signText = pd->endText() == "" ? " sign=\"no\"" : " sign=\"yes\"";
signText = pd->endText().isEmpty() ? " sign=\"no\"" : " sign=\"yes\"";
}
QString pedalXml = QString("pedal type=\"%1\"").arg(pedalType);
pedalXml += lineText;
Expand Down
15 changes: 13 additions & 2 deletions importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -4149,7 +4149,7 @@ void MusicXMLParserDirection::pedal(const QString& type, const int /* number */,
sign = "no"; // MusicXML 2.0 compatibility
}
auto& spdesc = _pass2.getSpanner({ ElementType::PEDAL, number });
if (type == "start" || type == "resume") {
if (type == "start" || type == "resume" || type == "sostenuto") {
if (spdesc._isStarted && !spdesc._isStopped) {
// Previous pedal unterminated—likely an unrecorded "discontinue", so delete the line.
// TODO: if "change", create 0-length spanner rather than delete
Expand All @@ -4164,9 +4164,16 @@ void MusicXMLParserDirection::pedal(const QString& type, const int /* number */,
if (!p->lineVisible() || sign == "yes") {
p->setBeginText("<sym>keyboardPedalPed</sym>");
p->setContinueText("(<sym>keyboardPedalPed</sym>)");
if (type == "sostenuto") {
p->setBeginText("<sym>keyboardPedalSost</sym>");
p->setContinueText("(<sym>keyboardPedalSost</sym>)");
}
}
else
else {
p->setBeginText("");
p->setContinueText("");
p->setBeginHookType(type == "resume" ? HookType::NONE : HookType::HOOK_90);
}
p->setEndHookType(HookType::NONE);

if (color.isValid()/* && preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTLAYOUT)*/)
Expand Down Expand Up @@ -4211,6 +4218,10 @@ void MusicXMLParserDirection::pedal(const QString& type, const int /* number */,

if (color.isValid()/* && preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTLAYOUT)*/)
p->setLineColor(color);
if (sign == "no") {
p->setBeginText("");
p->setContinueText("");
}
starts.append(MusicXmlSpannerDesc(p, ElementType::PEDAL, number));
}
else if (type == "continue") {
Expand Down
4 changes: 2 additions & 2 deletions mtest/musicxml/io/testDirections1.xml
Expand Up @@ -102,7 +102,7 @@
<measure number="2">
<direction placement="above">
<direction-type>
<pedal type="start"/>
<pedal type="start" line="no" sign="yes"/>
</direction-type>
</direction>
<note>
Expand Down Expand Up @@ -132,7 +132,7 @@
</note>
<direction placement="below">
<direction-type>
<pedal type="start"/>
<pedal type="start" line="no" sign="yes"/>
</direction-type>
</direction>
<note>
Expand Down

0 comments on commit beccff5

Please sign in to comment.