Skip to content

Correct playback transposing instruments and tpcs #18500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/engraving/libmscore/edit.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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