ExportMidi::writeHeader() only write default C sig if no initial key sig found

• Mar 27, 2017 - 20:58
Reported version
2.1
Type
Functional
Severity
S4 - Minor
Status
closed
Project

Need to fix bug described in https://musescore.org/en/node/184296 which I'm not going to reporduce here entirely, but the problem was that ExportMidi::writeHeader() would incorrectly write a default C keysig at tick 0 for every single time that when through any repeat list without finding a key signature.

Bug is in 2.0.3 and lastest 2.1-dev 3523f8f (but I haven't tested 3.0-dev).

I'll include export-as-midi_full-meas-intro.mscx:

export-as-midi_full-meas-intro.png

as test file which when exported to midi should be like export-as-midi_full-meas-intro.mid, which when re-imported should looks like:

export-as-midi_full-meas-intro-ref.png

but which incorrectly looked like:

import-export-as-midi_full-meas-intro_.png

Which incorrectly appears to have no initial key sig, when it actually mistakenly had an initial Bb keysig followed immediately by an initial C key sig.


Comments

Status (old) patch (code needs review) fixed

Fixed in branch 2.1, commit 41ab3d292d

fix #184376 ExportMidi::writeHeader() initial keysig overwrite

ExportMidi::writeHeader() would incorrectly write a default C keysig at tick 0 for every iteration through the RepeatList that did not contain a keysig. This meant that if there was an initial keysig, it would have been effectively overwritten it any sections in the RepeatList do not contain any keysig element.

The fix is to only write the fall back default initial C key sig if no key sigs were found at tick 0.

Fixed in branch master, commit 4627c59003

fix #184376 ExportMidi::writeHeader() initial keysig overwrite

ExportMidi::writeHeader() would incorrectly write a default C keysig at tick 0 for every iteration through the RepeatList that did not contain a keysig. This meant that if there was an initial keysig, it would have been effectively overwritten it any sections in the RepeatList do not contain any keysig element.

The fix is to only write the fall back default initial C key sig if no key sigs were found at tick 0.