Skip to content

Commit

Permalink
Merge pull request #26038 from rettinghaus/xml/harppedal
Browse files Browse the repository at this point in the history
[MusicXML] Export harp pedal texts
  • Loading branch information
RomanPudashkin authored Jan 10, 2025
2 parents 4b586cc + 7af62d2 commit 7020aab
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/engraving/dom/harppedaldiagram.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class HarpPedalDiagram final : public TextBase
String screenReaderInfo() const override;

void setIsDiagram(bool diagram);
bool isDiagram() { return m_isDiagram; }
bool isDiagram() const { return m_isDiagram; }

std::array<PedalPosition, HARP_STRING_NO> getPedalState() const { return m_pedalState; }
void setPedalState(std::array<PedalPosition, HARP_STRING_NO> state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5306,27 +5306,24 @@ void ExportMusicXml::rehearsal(RehearsalMark const* const rmk, staff_idx_t staff

void ExportMusicXml::harpPedals(HarpPedalDiagram const* const hpd, staff_idx_t staff)
{
if (hpd->textStyleType() != TextStyleType::HARP_PEDAL_DIAGRAM) {
return;
}

directionTag(m_xml, m_attr, hpd);
m_xml.startElement("direction-type");
XmlWriter::Attributes harpPedalAttrs;
if (!hpd->isStyled(Pid::PLACEMENT)) {
harpPedalAttrs.push_back({ "placement", (hpd->placement() == PlacementV::BELOW) ? "below" : "above" });
}
addColorAttr(hpd, harpPedalAttrs);
m_xml.startElement("harp-pedals", harpPedalAttrs);
const std::vector <String> pedalSteps = { u"D", u"C", u"B", u"E", u"F", u"G", u"A" };
for (size_t idx = 0; idx < pedalSteps.size(); idx++) {
m_xml.startElement("pedal-tuning");
m_xml.tag("pedal-step", pedalSteps.at(idx));
m_xml.tag("pedal-alter", static_cast<int>(hpd->getPedalState().at(idx)) - 1);
if (hpd->isDiagram()) {
m_xml.startElement("harp-pedals", harpPedalAttrs);
const std::vector <String> pedalSteps = { u"D", u"C", u"B", u"E", u"F", u"G", u"A" };
for (size_t idx = 0; idx < pedalSteps.size(); idx++) {
m_xml.startElement("pedal-tuning");
m_xml.tag("pedal-step", pedalSteps.at(idx));
m_xml.tag("pedal-alter", static_cast<int>(hpd->getPedalState().at(idx)) - 1);
m_xml.endElement();
}
m_xml.endElement();
} else {
m_xml.tag("words", harpPedalAttrs, hpd->plainText());
}
m_xml.endElement();
m_xml.endElement();
const int offset = calculateTimeDeltaInDivisions(hpd->tick(), tick(), m_div);
if (offset) {
m_xml.tag("offset", offset);
Expand Down
7 changes: 5 additions & 2 deletions src/importexport/musicxml/tests/data/testHarpPedals.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,19 @@
<Measure>
<voice>
<HarpPedalDiagram>
<isDiagram>0</isDiagram>
<pedalState>
<string name="0">1</string>
<string name="0">0</string>
<string name="1">2</string>
<string name="2">1</string>
<string name="3">1</string>
<string name="4">2</string>
<string name="5">2</string>
<string name="6">1</string>
</pedalState>
<text><sym>harpPedalCentered</sym><sym>harpPedalLowered</sym><sym>harpPedalCentered</sym><sym>harpPedalDivider</sym><sym>harpPedalCentered</sym><sym>harpPedalLowered</sym><sym>harpPedalLowered</sym><sym>harpPedalCentered</sym></text>
<style>harp_pedal_text_diagram</style>
<text>G<sym>csymAccidentalSharp</sym>
D<sym>csymAccidentalFlat</sym> </text>
</HarpPedalDiagram>
<Rest>
<durationType>measure</durationType>
Expand Down
36 changes: 4 additions & 32 deletions src/importexport/musicxml/tests/data/testHarpPedals_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</attributes>
<direction placement="below">
<direction-type>
<harp-pedals placement="below" color="#0096FF">
<harp-pedals color="#0096FF">
<pedal-tuning>
<pedal-step>D</pedal-step>
<pedal-alter>-1</pedal-alter>
Expand Down Expand Up @@ -209,38 +209,10 @@
</note>
</measure>
<measure number="4">
<direction placement="above">
<direction placement="below">
<direction-type>
<harp-pedals>
<pedal-tuning>
<pedal-step>D</pedal-step>
<pedal-alter>0</pedal-alter>
</pedal-tuning>
<pedal-tuning>
<pedal-step>C</pedal-step>
<pedal-alter>1</pedal-alter>
</pedal-tuning>
<pedal-tuning>
<pedal-step>B</pedal-step>
<pedal-alter>0</pedal-alter>
</pedal-tuning>
<pedal-tuning>
<pedal-step>E</pedal-step>
<pedal-alter>0</pedal-alter>
</pedal-tuning>
<pedal-tuning>
<pedal-step>F</pedal-step>
<pedal-alter>1</pedal-alter>
</pedal-tuning>
<pedal-tuning>
<pedal-step>G</pedal-step>
<pedal-alter>1</pedal-alter>
</pedal-tuning>
<pedal-tuning>
<pedal-step>A</pedal-step>
<pedal-alter>0</pedal-alter>
</pedal-tuning>
</harp-pedals>
<words>G
D </words>
</direction-type>
<staff>1</staff>
</direction>
Expand Down

0 comments on commit 7020aab

Please sign in to comment.