ExportMidi::writeHeader() should only write keysig meta events into first track

• Mar 28, 2017 - 13:19
Reported version
2.1
Type
Functional
Severity
S4 - Minor
Status
by design
Project

Current MuseScore::writeHeader() in 2.0.3 and 2.1 will iterate over all tracks: https://github.com/musescore/MuseScore/blob/8ff4a8f95eb5df55fc68e0ae96e…

and then export key sig for each track:
https://github.com/musescore/MuseScore/blob/8ff4a8f95eb5df55fc68e0ae96e…

So for instance diff-key-sigs-each-staff_.mscx which looks like:

diff-key-sigs-each-staff_.png

will produce midi like diff-key-sigs-each-staff_.mid which contains time sigs on every staff:

Screenshot at 2017-03-28 08-15-32.png

But those circled key sig meta events should not be there. Some programs will complain and pop up a warning when detect key sig meta events in tracks other than the first.

Please see discussion at https://musescore.org/en/node/184296#comment-685361

There is a question about what to do when conflicts occur. It seems the simplest programming solution is to just look at the first staff when searching for key sig events, and then only write key sigs from the first staff.


Comments

Note: I've had to modify:

mtest/libmscore/midi/testMidiPort-ref.mid
mtest/libmscore/midi/testBends2-ref.mid

so that they only had the initial (C) key sig in the first track.

OK, well to be honest, that is what my initial thought was, and indeed that is what the original '96 somplete_midi_96-1-3.pdf specs say. SO these other programs and these other specs which say that key sigs should only appear in the master track must be incorrect, and probably have diverged from the initial spec via the telephone game.