Skip to content

Commit

Permalink
fix #305745: playback of "add" chords
Browse files Browse the repository at this point in the history
The algorithm for constructing the realized harmony for a chord symbol
was missing a handler for the "add" keyword.
Additions can also be specified using parensthesis,
but this yields an spurious assertion failure in debug mode,
so that is fixed here as well.
  • Loading branch information
MarcSabatella committed May 25, 2020
1 parent 0c9c651 commit 510f012
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions libmscore/realizedharmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,19 @@ RealizedHarmony::PitchMap RealizedHarmony::getIntervals(int rootTpc, bool litera
bool modded = false;
for (int c = 0; c < s.length(); ++c) {
if (s[c].isDigit()) {
Q_ASSERT(c > 0); //we shouldn't have just a number

int alter = 0;
int cutoff = c;
int deg = s.right(s.length() - c).toInt();
//account for if the flat/sharp is stuck to the end of add
if (s[c-1] == '#') {
cutoff -= 1;
alter = +1;
}
else if (s[c-1] == 'b') {
cutoff -= 1;
alter = -1;
if (c) {
if (s[c-1] == '#') {
cutoff -= 1;
alter = +1;
}
else if (s[c-1] == 'b') {
cutoff -= 1;
alter = -1;
}
}
QString extType = s.left(cutoff);
if (extType == "" || extType == "major") { //alteration
Expand All @@ -335,6 +335,12 @@ RealizedHarmony::PitchMap RealizedHarmony::getIntervals(int rootTpc, bool litera
omit |= 1 << deg;
modded = true;
}
else if (extType == "add") {
ret.insert(step2pitchInterval(deg, alter) + RANK_MULT*RANK_ADD, tpcInterval(rootTpc, deg, alter));
omit |= 1 << deg;
modded = true;
}
break;
}
}

Expand Down

0 comments on commit 510f012

Please sign in to comment.