Notes entered with wrong enharmonic spelling from MIDI input or "R" command in note input
In midi input, the default accidental choices are not in accord with some key signatures. For example, in Ab Major, G# and C# are chosen over Ab and Db.
Steps to reproduce:
1. create score with key signature of 4 flats.
2. Enter Ab Major scale using midi keyboard
Expected result: Ab and Db should be notated as part of the scale
Actual result: G# and C# are notated
Using c7b7d35
Windows 7
Attachment | Size |
---|---|
key_sig_test-1.png | 331.78 KB |
key_sig_test.mscz | 2.2 KB |
Comments
It's not just MIDI input, I think it's anything that relies on Score::addPitch(). Another way to reproduce the issue:
1) new score, key of Ab
2) note input, "D R"
Result: the "R" should repeat the D (which is actually Db due to key signature), but instead it enters C#.
I see it is also called from "Cursor::addNote()" - I guess that would affect plugins?
This would also happen for notes added automatically as a result of the "tie" command, but that code explicitly copies line & tpc from the starting note.
This is all a bit too interconnected for me to want to try to fix it myself...
A little more digger shows that Note::setNval() is *trying* to do the right thing:
https://github.com/musescore/MuseScore/blob/master/libmscore/note.cpp#L…
However, staff()->key() is always returning 0 - the key map is apparently empty.
In any case, merely checking the key isn't really good enough. Consider, even in the case of C major, if you go to note input, type "D Down R", the "D Down" gives you a Db and the "R" should repeat that, but if you are basing your TPC decision solely on key, you'll still end up with C#. I think the "R" code should probably do like the tie code and explicitly override the TPC according to the note being repeated.
MIDI input would be trickier to get right in the case of accidentals. If you are in the key of C and play a C#/Db, it will be spelled as C# by default. Press "J" to respell as Db. If you then press the same C#/Db key again on your MIDI keyboard, it would be nice if MuseScore would have "learned" that you want it spelled Db. But I understand that's asking a bit much. Still, it's got to work for key signatures. Playing Db in the key of Ab has got to spell it as Db. Getting staff()->key() to return the correct value would fix that.
Fixed in f3caba78f6
Automatically closed -- issue fixed for 2 weeks with no activity.