Key signature not restored correctly when toggling concert pitch
The new scheme for specifying whether a staff should prefer flats or sharps when transposed is welcome and mostly seems to work well. However, there is a case that is not handled so well, leading to loss of information. This same problem could happen before the new option, but it will happen in new situations now. Here is a new case:
1) new score for Bb clarinet, key of B concert (will display as C#)
2) toggle to concert pitch and back and verify the key is B
3) staff properties, set to prefer flats
4) verify key signature now display as Db, which is good
4) turn off concert pitch
Result: key is now Cb. The "prefer sharps/flats" setting really should only apply to the display when concert pitch is off. When concert pitch is on, it should always reflect the "real" key, but this information is now lost. Once we change the C# to Db, there is no more record that the original concert pitch key was B. And the same thing happens if you try adding key changes after making this setting. A B major (concert) key signature cannot be made to happen on a staff set to prefer flats. You'll get Cb. The prefer flats setting should only apply to the transposed key.
I said it was possible to get a similar bug before. For that, you'd need an Eb instrument. So, Eb alto saxophone, key of B concert again. Here, even without the new prefer sharps/flats setting, MuseScore has no choice but to display the transposed key as Ab. And then there is no getting back to B when you turn concert pitch on.
I'm not sure there is a good fix for this. Once we've displayed the transposed key as Db, we've lost all record of the fact that the concert pitch key is actually supposed to be B. Even if we ignore the prefer sharps/flats setting when reverting to concert pitch, we're going to end up with Cb because that's the literally correct transposition of Db by major second. Similarly for the case of the Eb instrument that is displaying Ab as the transposed key - there's just no way to know this started out as B major in concert pitch.
The real solution is to maintain the equivalent of separate TPC1 and TPC2 for the key, just like we do for notes. And for that matter, we should do this for chord symbols too. But that may or may not be feasible without a file format change. Maybe we can do it in a way where the info might be lost when reading the score in older versions, but at least is maintained for 3.5 and up? Another somewhat hackier solution would be to look for a staff that doesn't transpose and "steal" the concert key signature from it. Doesn't help when writing for saxophone quartet, though.
Workaround is, I guess, toggle the prefer sharps/flats setting as needed. It's clumsy, but all in all, I'll still take the increase in occurrences of bug as a fair price to pay for the new feature, which will be welcome by many I'm sure. Will be good to get feedback from others on that matter, though.
See also #280835: Transposing instruments handle difficult key signatures incorrectly which covers the existing case with respect to Eb instruments, also #18147: When silently changing the key to enharmonic equivalent during transposition, change notes too which is kind of related I guess.
Comments
Came up again https://musescore.org/en/node/309388
I disagree that this is a bug, it is a necessity.
In your alto sax example, if you were to enter the notes for the transposed key of Ab into a score with the concert pitch of B, when you switch to transposed pitch, the accidentals would become chaotic due to everything being entered in a key with sharps rather than flats, especially in the case of courtesy accidentals. Other considerations in the realm of accidentals is that the keys of B, F# & C#, you are likely to have double sharps in the score while in their enhamonic keys you are likely to have double flats. The translations between these would end up rather chaotic as well.
So in my opinion, the current behavior should remain the default. I'm never opposed to flexibility, so allowing the user to ctrl+drag the other concert pitch key signature and MuseScore making it stick is something I would enthusiastically support.
The trouble is it doesn't stick.
Here is a scale of G# harmonic minor (so we have an accidental) for an alto sax with concert pitch on
And now with concert pitch off
And now with concert pitch on again
The problem is that MuseScore doesn't "remember" that the original key signature was 5 sharps rather than 7 flats.
@SteveBlower I said that.
See https://musescore.org/en/node/309388#comment-1022101 for the real workaround to this situation. While actually composing, there is rarely a need to actually switch between concert and transposed pitch. If you must, then see the comment I linked to. The requirement to submit a concert pitch score is rare and the requirement to use an enharmonic key signature is even less.
Also, I did say that I would support making the fix for Richard Cooke an option.
In reply to @SteveBlower I said that… by mike320
You also said " in my opinion, the current behavior should remain the default.". While the current behaviour may be by (bad) design rather than a bug, surely toggling from concert pitch and back should leave you where you were key signature-wise, rather than with an enharmonically changed key signature - unless that enharmonic change was made by the user of course.
I also called it necessary. This because not setting the concert pitch key signature to the same type (sharp or flat) as the transposed instruments leads to situations like the example you gave.
I believe the fundamental issue is that we don't remember both keysigs, just the current one. Unlike with notes, where we always record both in case the spellings differ. We really should do that for keys too, and chord symbols.
In reply to I believe the fundamental… by Marc Sabatella
" not setting the concert pitch key signature to the same type (sharp or flat) as the transposed instruments leads to situations like the example you gave." I don't know that I have ever seen a concert pitch score with different enharmonic key signatures for different instruments, but then concert pitch score are not that common. Are there examples out there with 5 sharps for flute and 7 flats for "flat" transposing instruments?
I've seen few published concert pitch scores (compared to transposed) and none with so many sharps or flats that this became an issue, so the primary issue here is how MuseScore handles this situation. Since changing between the harmonic key signatures leads to every note having an accidental on it the default needs to take this into consideration, which is what the current code does. I totally agree that MuseScore does need to allow for the other situation but the user will need to intervene to get the proper notes into the parts unless someone wants to write code that may or may not guess correctly for what the user wants.
The concert pitch scores I have seen are mostly for music in which no key signature at all is used.
That's what I remember as well.
In reply to That's what I remember as… by mike320
My most recent encounter with a concert pitch orchestral score is a Russian edition of Peter and the Wolf. That has identical key signatures for all instruments (even the horns) ranging from 4 flats to 5 sharps. It is available on IMSLP but is marked as likely non-PD in US and EU.