Breath Bug in Export Midi

• Jun 17, 2018 - 19:03
Reported version
S3 - Major

While playing in the gui is proper, when exporting to midi, the tempo from the fermata is applied to the repeated measures when a breath is present...

Attachment Size
BreathBug.mid 231 bytes
BreathBug.mscz 4.27 KB


Found a second bug in breath implementation in export midi. When the breath occurs before a time signature change, skew is introduced into the measure breaks. That is, the time signature change does not occur between measures. This is because the delta-time tick count in the breath uses the new measure size before the time signature change has been processed.

Attachment Size
BreathBug2.mid 104 bytes
BreathBug2.mscz 3.21 KB
Type Wording/Translation Functional
Reported version 2.2 3.0
Regression No
Reproducibility Always
Workaround No

These bugs persist in version 3.0. The attached regression files demonstrate the bug(s). Both appear to be due to the implementation of the pause found in ExportMidi::PauseMap::calculate() in mscore/exportmidi.cpp. The pause is implemented the final block of the function and occurs at the end of a measure on a measure boundary. The problem is that if a subsequent time-signature or tempo change (either a fermata or an explicit tempo change) occurs at the same measure boundary but is intended for the next measure it corrupts the pause implementation. The implementation incorrectly assumes that the upcoming time-signature or tempo was valid during the ending measure prior to the pause. The two small files previously attached still demonstrate the bug.

Severity S4 - Minor S3 - Major

As I transition into production, the severity of these bugs is increasing...

Here's a midi snippet related to Breath Bug 2 as annotated by my software. Midi division is 480 ticks per quarter.

 (meta te0 (event e0 (deltatime 0) (timesignature 3 2 24 8)))
 (meta te8 (event e0 (deltatime 73) (settempo 500000)))
 (meta te9 (event e0 (deltatime 480) (timesignature 1 2 24 8)))
 (meta te10 (event e0 (deltatime 0) (settempo 500000)))

Deltatime 480 is indicative of the problem!

Meta events te8 and te10 implement the breath pause. This pause occurs at the end of a measure and the next measure introduces a time change. While dirty but not the bug, the time change meta event needlessly occurs in the middle of the pause. The bug is that the deltatime of the pause is only 480 when it should be 1440 and the tempo at te8 should then be a third its value. That is, the new time signature (te9) is being used in the calculation of the pause tempo and duration before it has been recognized.

As currently implemented, the time signature change is occurring mid-measure (one quarter note into a 3/4 measure). The release notes for export midi advertised that its implementation preserved measure boundaries by inserting whole measures. In this case it does not, only a partial measure is inserted, and measure skew is introduced!

Note, Breath Bug 1 is different. In that bug, the pause implementation can leave the track playing at the wrong tempo.

Similar issue here I guess. See attached screenshot with midi export opened on the right side. Mesures 17 et 18, la durée de la noire pointée est 480 (noire) au lieu de 719.
Update - please ignore this message : issue was probably due to inconsistencies in the mscz file

Attachment Size
midi export.jpg 240.32 KB