Skip to content

Commit

Permalink
Fix #318631: Tablature fingering order not always correct
Browse files Browse the repository at this point in the history
Resolves: https://musescore.org/en/node/318631

Duplicate of musescore#8000, resp. back port of musescore#8001
  • Loading branch information
mattmcclinch authored and Jojo-Schmitz committed Mar 5, 2023
1 parent a7a7ac5 commit 107d5a0
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions libmscore/chord.cpp
Expand Up @@ -518,20 +518,30 @@ void Chord::add(Element* e)
case ElementType::NOTE:
{
Note* note = toNote(e);
bool tab = staff() && staff()->isTabStaff(tick());
bool found = false;

// _notes should be sorted by line position,
// but it's often not yet possible since line is unknown
// use pitch instead, and line as a second sort criteria.

for (unsigned idx = 0; idx < _notes.size(); ++idx) {
if (note->pitch() <= _notes[idx]->pitch()) {
if (note->pitch() == _notes[idx]->pitch() && note->line() >= _notes[idx]->line())
_notes.insert(_notes.begin()+idx+1, note);
else
_notes.insert(_notes.begin()+idx, note);
found = true;
break;
if (tab) {
// _notes should be sorted by string
if (note->string() > _notes[idx]->string()) {
_notes.insert(_notes.begin() + idx, note);
found = true;
break;
}
}
else {
// _notes should be sorted by line position,
// but it's often not yet possible since line is unknown
// use pitch instead, and line as a second sort criteria.
if (note->pitch() <= _notes[idx]->pitch()) {
if (note->pitch() == _notes[idx]->pitch() && note->line() >= _notes[idx]->line())
_notes.insert(_notes.begin() + idx + 1, note);
else
_notes.insert(_notes.begin() + idx, note);
found = true;
break;
}
}
}
if (!found)
Expand Down

0 comments on commit 107d5a0

Please sign in to comment.