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 musescore#20219
  • Loading branch information
rettinghaus authored and Jojo-Schmitz committed Nov 27, 2023
1 parent ba87541 commit 75a740c
Show file tree
Hide file tree
Showing 7 changed files with 1,578 additions and 703 deletions.
8 changes: 5 additions & 3 deletions importexport/musicxml/exportxml.cpp
Expand Up @@ -4671,14 +4671,16 @@ 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\"";
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 @@ -4687,7 +4689,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\"";
}
pedalXml = QString("pedal type=\"%1\"").arg(pedalType);
pedalXml += lineText;
Expand Down
15 changes: 12 additions & 3 deletions importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -4130,7 +4130,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 @@ -4144,10 +4144,15 @@ void MusicXMLParserDirection::pedal(const QString& type, const int /* number */,
p->setLineVisible(false);
if (!p->lineVisible() || sign == "yes") {
p->setBeginText("<sym>keyboardPedalPed</sym>");
p->setContinueText("(<sym>keyboardPedalPed</sym>)");
p->setContinueText("<sym>keyboardPedalUp</sym>");
if (type == "sostenuto")
p->setBeginText("<sym>keyboardPedalSost</sym>");
}
else
else {
p->setBeginText("");
p->setContinueText("");
p->setBeginHookType(type == "resume" ? HookType::NONE : HookType::HOOK_90);
}
p->setEndHookType(HookType::NONE);
starts.append(MusicXmlSpannerDesc(p, ElementType::PEDAL, number));
}
Expand Down Expand Up @@ -4185,6 +4190,10 @@ void MusicXMLParserDirection::pedal(const QString& type, const int /* number */,
p->setLineVisible(true);
else
p->setLineVisible(false);
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
55 changes: 2 additions & 53 deletions mtest/musicxml/io/testPedalChanges.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.1">
<work>
<work-title>Pedal Changes</work-title>
Expand All @@ -16,46 +16,7 @@
<supports element="stem" type="yes"/>
</encoding>
</identification>
<defaults>
<scaling>
<millimeters>7</millimeters>
<tenths>40</tenths>
</scaling>
<page-layout>
<page-height>1697.14</page-height>
<page-width>1200</page-width>
<page-margins type="even">
<left-margin>85.7143</left-margin>
<right-margin>85.7143</right-margin>
<top-margin>85.7143</top-margin>
<bottom-margin>85.7143</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>85.7143</left-margin>
<right-margin>85.7143</right-margin>
<top-margin>85.7143</top-margin>
<bottom-margin>85.7143</bottom-margin>
</page-margins>
</page-layout>
<word-font font-family="Edwin" font-size="10"/>
<lyric-font font-family="Edwin" font-size="10"/>
</defaults>
<credit page="1">
<credit-type>title</credit-type>
<credit-words default-x="600" default-y="1611.86" justify="center" valign="top" font-size="22">Pedal Changes</credit-words>
</credit>
<credit page="1">
<credit-type>subtitle</credit-type>
<credit-words default-x="600" default-y="1554.72" justify="center" valign="top" font-size="16">MuseScore Testcase</credit-words>
</credit>
<credit page="1">
<credit-type>composer</credit-type>
<credit-words default-x="1114.29" default-y="1511.86" justify="right" valign="top">Henry Ives</credit-words>
</credit>
<part-list>
<part-group type="start" number="1">
<group-symbol>none</group-symbol>
</part-group>
<score-part id="P1">
<part-name>Piano</part-name>
<part-abbreviation>Pno.</part-abbreviation>
Expand All @@ -73,19 +34,7 @@
<part-group type="stop" number="1"/>
</part-list>
<part id="P1">
<measure number="1" width="208.61">
<print>
<system-layout>
<system-margins>
<left-margin>50.00</left-margin>
<right-margin>0.00</right-margin>
</system-margins>
<top-system-distance>170.00</top-system-distance>
</system-layout>
<staff-layout number="2">
<staff-distance>65.00</staff-distance>
</staff-layout>
</print>
<measure number="1">
<attributes>
<divisions>1</divisions>
<key number="2">
Expand Down

0 comments on commit 75a740c

Please sign in to comment.