Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MusicXML] Export harp pedal texts #26038

Merged
merged 7 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -5248,27 +5248,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