Skip to content

Commit

Permalink
Merge pull request #3541 from gregchapman-dev/gregc/fixesNov2023
Browse files Browse the repository at this point in the history
Three Humdrum input fixes
  • Loading branch information
craigsapp authored Nov 6, 2023
2 parents e671927 + 25728a2 commit 6f73f7a
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/iohumdrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6820,7 +6820,7 @@ void HumdrumInput::setTimeSig(StaffDef *part, const std::string &timesig, const
vrvmeter->SetVisible(BOOLEAN_false);
}
}
if (timetok->find("yy") != std::string::npos) {
if (timetok && timetok->find("yy") != std::string::npos) {
vrvmeter->SetVisible(BOOLEAN_false);
}

Expand Down Expand Up @@ -24880,8 +24880,8 @@ template <class ELEMENT> void HumdrumInput::convertVerses(ELEMENT element, hum::
hre.replaceDestructive(value, "&#xFC;", "u2", "g"); // u-umlaut
hre.replaceDestructive(value, "&#xE4;", "a2", "g"); // a-umlaut
hre.replaceDestructive(value, "&#xF6;", "o2", "g"); // o-umlaut
hre.replaceDestructive(value, "\\s+$", ""); // trailing spaces
hre.replaceDestructive(value, "^\\s+", ""); // leading spaces
hre.replaceDestructive(value, "", "\\s+$"); // trailing spaces
hre.replaceDestructive(value, "", "^\\s+"); // leading spaces
hre.replaceDestructive(value, "-", "\\s+-$"); // trailing space before hyphen
hre.replaceDestructive(value, "-", "^-\\s+"); // leaning spaces after hyphen
if (!value.empty()) {
Expand Down Expand Up @@ -25353,6 +25353,7 @@ template <class ELEMENT> void HumdrumInput::setRhythmFromDuration(ELEMENT elemen
template <class ELEMENT>
void HumdrumInput::setVisualAndGesturalRhythmFromDuration(ELEMENT element, hum::HumNum visdur, hum::HumNum gesdur)
{
bool durGesSet = false;
pair<data_DURATION, int> visDurAndDots = getDurAndDots(visdur);
element->SetDur(visDurAndDots.first);
if (visDurAndDots.second != 0) {
Expand All @@ -25361,8 +25362,14 @@ void HumdrumInput::setVisualAndGesturalRhythmFromDuration(ELEMENT element, hum::
pair<data_DURATION, int> gesDurAndDots = getDurAndDots(gesdur);
if (gesDurAndDots.first != visDurAndDots.first) {
element->SetDurGes(gesDurAndDots.first);
durGesSet = true;
}
if (!durGesSet) {
if (gesDurAndDots.second != visDurAndDots.second) {
element->SetDotsGes(gesDurAndDots.second);
}
}
if (gesDurAndDots.second != visDurAndDots.second) {
else {
element->SetDotsGes(gesDurAndDots.second);
}
}
Expand Down Expand Up @@ -25419,14 +25426,15 @@ template <class ELEMENT> hum::HumNum HumdrumInput::convertRhythm(ELEMENT element

if (!vstring.empty()) {
int visualdotcount = characterCountInSubtoken(vstring, '.');
if (visualdotcount > 0) {
element->SetDots(visualdotcount);
}
int gesturaldotcount = characterCountInSubtoken(tstring, '.');
if (gesturaldotcount != visualdotcount) {
element->SetDotsGes(gesturaldotcount);
// It would be prettier to avoid @dots.ges="0" if @dots is not set,
// but we cannot tell from here whether @dots will be set (the
// call to setRhythmFromDuration() can set @dots unexpectedly).
// So we always set @dots.ges if @dur.ges is going to be set.
if (visualdotcount != 0) {
element->SetDots(visualdotcount);
}
element->SetDotsGes(gesturaldotcount);
}
else {
int dotcount = characterCountInSubtoken(tstring, '.');
Expand All @@ -25450,9 +25458,10 @@ template <class ELEMENT> hum::HumNum HumdrumInput::convertRhythm(ELEMENT element
dur /= 4; // convert duration to whole-note units
int logicaldurdots = (int)std::count(logicaldur.begin(), logicaldur.end(), '.');
int visualdurdots = (int)std::count(visualdur.begin(), visualdur.end(), '.');
if (visualdurdots != logicaldurdots) {
element->SetDotsGes(logicaldurdots);
if (visualdurdots != 0) {
element->SetDots(visualdurdots);
}
element->SetDotsGes(logicaldurdots);
std::string typestring = token->getValue("auto", "MEI", "type");
if (typestring.empty()) {
element->SetType("overfill");
Expand Down

0 comments on commit 6f73f7a

Please sign in to comment.