[midi import] Failure to detect non-aligned triplet

• Sep 30, 2015 - 15:58
S4 - Minor

Sometimes it happens that MuseScore 2.0.2 fails to detect triplets. In this particular case, a note of the same length as a quarter note starts at a 2/3 beat offset. The first part is correct, thenit replaces the following triplet by an 3:1 quarter note split ratio. See attached MIDI file. The track has already been quantized in qtractor (the cursor in the screenshot is located at the first of the affected measures), so the track should be fine without any quantization (I suspect MuseScore destroys information by quantize to 1/16). Is there a way to disable quantization when importing MIDI.

Attachment Size
bad-result.png 31.75 KB
swingit-sax.mid 457 bytes
track-in-qtractor.png 6.94 KB


Would it be a good starting point to see what happens in `MidiTuplet::findAllTuplets`? I would really like to see why it is failing. Is there any basic outline of the MIDI import algorithm? It is strange that it passes basicQuant to the tuplet routines, when basicQuant cannot be set to a value that is suitable for the tuplet length it is trying to detect.

basicQuant only defines the max allowed quantization. During the tuplet detection, quntization values individual for all tuplets, are calculated. These quantization values cannot be greater than the basicQuant value, but they can be smaller and, of course, depend on the tuplet value (3, 5, 7, ...).

The failing example has only a single note in the triplet - the first is missing because of the tietied, the second is missing because the first (tied) note is a quarter rather than an eighth. Could that be the key?

Probably, but not definitely. However, indeed, if the second note in 5-plet in the text example is removed and the last tied note of the previous tuplet is lengthened to the beginning of the 3rd note of the 5-plet, then that example is not passed.