Skip to content

Commit

Permalink
Merge pull request #20224 from rettinghaus/fix/pedal
Browse files Browse the repository at this point in the history
fix pedal import/export for MusicXML
  • Loading branch information
cbjeukendrup authored Dec 4, 2023
2 parents a5eb785 + 132491e commit 7d2cae5
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 596 deletions.
6 changes: 3 additions & 3 deletions src/importexport/musicxml/internal/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5155,12 +5155,12 @@ void ExportMusicXml::pedal(Pedal const* const pd, staff_idx_t staff, const Fract
pedalType = "change";
break;
case HookType::NONE:
pedalType = "resume";
pedalType = pd->lineVisible() ? "resume" : "start";
break;
default:
pedalType = "start";
}
signText = pd->beginText() == "" ? " sign=\"no\"" : " sign=\"yes\"";
signText = pd->beginText().isEmpty() ? " sign=\"no\"" : " sign=\"yes\"";
} else {
if (!pd->endText().isEmpty() || pd->endHookType() == HookType::HOOK_90) {
pedalType = "stop";
Expand All @@ -5169,7 +5169,7 @@ void ExportMusicXml::pedal(Pedal const* const pd, staff_idx_t staff, const Fract
}
// "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
Original file line number Diff line number Diff line change
Expand Up @@ -3552,6 +3552,8 @@ void MusicXMLParserDirection::pedal(const QString& type, const int /* number */,
p->setBeginText(u"<sym>keyboardPedalPed</sym>");
p->setContinueText(u"(<sym>keyboardPedalPed</sym>)");
} else {
p->setBeginText(u"");
p->setContinueText(u"");
p->setBeginHookType(type == "resume" ? HookType::NONE : HookType::HOOK_90);
}
p->setEndHookType(HookType::NONE);
Expand Down Expand Up @@ -3596,6 +3598,10 @@ void MusicXMLParserDirection::pedal(const QString& type, const int /* number */,
} else {
p->setLineVisible(false);
}
if (sign == "no") {
p->setBeginText(u"");
p->setContinueText(u"");
}
if (color.isValid()) {
p->setColor(color);
}
Expand Down
4 changes: 2 additions & 2 deletions src/importexport/musicxml/tests/data/testDirections1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<measure number="2">
<direction placement="above">
<direction-type>
<pedal type="resume" line="no" sign="yes"/>
<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="resume" line="no" sign="yes"/>
<pedal type="start" line="no" sign="yes"/>
</direction-type>
</direction>
<note>
Expand Down
4 changes: 2 additions & 2 deletions src/importexport/musicxml/tests/data/testDirections1_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<measure number="2">
<direction placement="above">
<direction-type>
<pedal type="resume" line="no" sign="yes"/>
<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="resume" line="no" sign="yes"/>
<pedal type="start" line="no" sign="yes"/>
</direction-type>
</direction>
<note>
Expand Down
Loading

0 comments on commit 7d2cae5

Please sign in to comment.