Skip to content

Commit

Permalink
Fix #318983: Custom Keysig - different accidentals per octaves
Browse files Browse the repository at this point in the history
- first added accidental takes whole space (all octaves)
- each other for same note (in different octave) changes only one octave

Backport of musescore#10549
  • Loading branch information
sammik authored and Jojo-Schmitz committed Feb 24, 2022
1 parent 3f88dd7 commit 207f1f0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions libmscore/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,24 @@ void AccidentalState::init(const KeySigEvent& keySig, ClefType clef)
{
if (keySig.custom()) {
memset(state, ACC_STATE_NATURAL, MAX_ACC_STATE);
bool used[7] = { false };
for (const KeySym& s : keySig.keySymbols()) {
AccidentalVal a = sym2accidentalVal(s.sym);
int line = int(s.spos.y() * 2);
int idx = absStep(line, clef) % 7;
for (int octave = 0; octave < (11 * 7); octave += 7) {
int i = idx + octave ;
if (i >= MAX_ACC_STATE)
break;
state[i] = int(a) - int(AccidentalVal::MIN);
int step = absStep(line, clef);
int idx = step % 7;
if (used[idx]) { // accidental for this step already used, so apply only to this octave
state[step] = int(a) - int(AccidentalVal::MIN);
}
else {
for (int octave = 0; octave < (11 * 7); octave += 7) {
int i = idx + octave;
if (i >= MAX_ACC_STATE)
break;
state[i] = int(a) - int(AccidentalVal::MIN);
}
}
used[idx] = true;
}
}
else {
Expand Down

0 comments on commit 207f1f0

Please sign in to comment.