Skip to content

Commit

Permalink
Merge pull request musescore#18500 from sammik/correct-playback-trans…
Browse files Browse the repository at this point in the history
…posing-instruments

Correct playback transposing instruments and tpcs
  • Loading branch information
RomanPudashkin committed Jul 10, 2023
2 parents 744f6d0 + cf0e237 commit b8c9211
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/engraving/libmscore/edit.cpp
Expand Up @@ -4980,6 +4980,7 @@ void Score::undoChangeFretting(Note* note, int pitch, int string, int fret, int
void Score::undoChangeKeySig(Staff* ostaff, const Fraction& tick, KeySigEvent key)
{
KeySig* lks = 0;
bool needsUpdate = false;

for (Staff* staff : ostaff->staffList()) {
if (staff->isDrumStaff(tick)) {
Expand All @@ -5000,12 +5001,14 @@ void Score::undoChangeKeySig(Staff* ostaff, const Fraction& tick, KeySigEvent ke
KeySig* ks = toKeySig(s->element(track));

Interval interval = staff->part()->instrument(tick)->transpose();
Interval oldStaffInterval = staff->transpose(tick);
KeySigEvent nkey = key;
bool concertPitch = score->style().styleB(Sid::concertPitch);

if (interval.chromatic && !concertPitch && !nkey.isAtonal()) {
interval.flip();
nkey.setKey(transposeKey(key.concertKey(), interval, staff->part()->preferSharpFlat()));
interval.flip();
}

updateInstrumentChangeTranspositions(key, staff, tick);
Expand All @@ -5024,6 +5027,13 @@ void Score::undoChangeKeySig(Staff* ostaff, const Fraction& tick, KeySigEvent ke
lks = nks;
}
}
if (interval != staff->transpose(tick) || interval != oldStaffInterval) {
needsUpdate = true;
}
}
if (needsUpdate) {
Fraction tickEnd = Fraction::fromTicks(ostaff->keyList()->nextKeyTick(tick.ticks()));
transpositionChanged(ostaff->part(), ostaff->transpose(tick), tick, tickEnd);
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/engraving/libmscore/note.cpp
Expand Up @@ -913,7 +913,12 @@ int Note::playingTpc() const
int result = tpc();

if (!concertPitch() && transposition()) {
result = transposeTpc(result);
int tpc1 = this->tpc1();
if (tpc1 == Tpc::TPC_INVALID) {
result = transposeTpc(result);
} else {
result = tpc1;
}
}

int steps = ottaveCapoFret();
Expand Down

0 comments on commit b8c9211

Please sign in to comment.