Skip to content

Commit

Permalink
When computing vgrp, consider relative-y in addition to default-y.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinellimarco committed Aug 8, 2023
1 parent b6cc525 commit 82824ca
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/iomusxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ void MusicXmlInput::ReadMusicXmlDirection(
if (containsWords && !containsTempo && !containsDynamics) {
pugi::xpath_node_set words = node.select_nodes("direction-type/*[self::words or self::coda or self::segno]");
defaultY = words.first().node().attribute("default-y").as_int();
defaultY += words.first().node().attribute("relative-y").as_int();
defaultY = (defaultY*10) + words.first().node().attribute("relative-y").as_int();
std::string wordStr = words.first().node().text().as_string();
if (wordStr.rfind("cresc", 0) == 0 || wordStr.rfind("dim", 0) == 0 || wordStr.rfind("decresc", 0) == 0) {
containsDynamics = true;
Expand All @@ -2129,7 +2129,7 @@ void MusicXmlInput::ReadMusicXmlDirection(
}

TextRendition(words, dir);
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 200;
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 2000;
dir->SetVgrp(defaultY);
m_controlElements.push_back({ measureNum, dir });
m_dirStack.push_back(dir);
Expand Down Expand Up @@ -2184,10 +2184,12 @@ void MusicXmlInput::ReadMusicXmlDirection(
}

TextRendition(dynamics, dynam);
if (defaultY == 0) defaultY = dynamics.first().node().attribute("default-y").as_int();
defaultY += dynamics.first().node().attribute("relative-y").as_int();
if (defaultY == 0) {
defaultY = dynamics.first().node().attribute("default-y").as_int();
defaultY = (defaultY*10) + dynamics.first().node().attribute("relative-y").as_int();
}
// parse the default_y attribute and transform to vgrp value, to vertically align dynamics and directives
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 200;
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 2000;
dynam->SetVgrp(defaultY);
m_controlElements.push_back({ measureNum, dynam });
m_dynamStack.push_back(dynam);
Expand Down Expand Up @@ -2287,9 +2289,9 @@ void MusicXmlInput::ReadMusicXmlDirection(
hairpin->SetStaff(hairpin->AttStaffIdent::StrToXsdPositiveIntegerList(std::to_string(1 + staffOffset)));
}
int defaultY = wedge->node().attribute("default-y").as_int();
defaultY += wedge->node().attribute("relative-y").as_int();
defaultY = (defaultY*10) + wedge->node().attribute("relative-y").as_int();
// parse the default_y attribute and transform to vgrp value, to vertically align hairpins
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 200;
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 2000;
hairpin->SetVgrp(defaultY);
// match new hairpin to existing hairpin stop
for (auto iter = m_hairpinStopStack.begin(); iter != m_hairpinStopStack.end(); ++iter) {
Expand Down Expand Up @@ -2391,9 +2393,9 @@ void MusicXmlInput::ReadMusicXmlDirection(
pedal->SetTstamp(timeStamp);
if (pedalType == "stop") pedal->SetTstamp(timeStamp - 0.1);
int defaultY = xmlPedal.attribute("default-y").as_int();
defaultY += xmlPedal.attribute("relative-y").as_int();
defaultY = (defaultY*10) + xmlPedal.attribute("relative-y").as_int();
// parse the default_y attribute and transform to vgrp value, to vertically align pedal starts and stops
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 200;
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 2000;
pedal->SetVgrp(defaultY);
m_controlElements.push_back({ measureNum, pedal });
m_pedalStack.push_back(pedal);
Expand Down Expand Up @@ -3301,8 +3303,8 @@ void MusicXmlInput::ReadMusicXmlNote(
// place
dynam->SetPlace(dynam->AttPlacementRelStaff::StrToStaffrel(xmlDynam.attribute("placement").as_string()));
int defaultY = xmlDynam.attribute("default-y").as_int();
defaultY += xmlDynam.attribute("relative-y").as_int();
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 200;
defaultY = (defaultY*10) + xmlDynam.attribute("relative-y").as_int();
defaultY = (defaultY < 0) ? std::abs(defaultY) : defaultY + 2000;
dynam->SetVgrp(defaultY);
std::string dynamStr;
for (pugi::xml_node xmlDynamPart : xmlDynam.children()) {
Expand Down

0 comments on commit 82824ca

Please sign in to comment.