Underflow bug in MIDI export with negative playback end offsets

Dorico Pro 2.2.20.1286 (Apr 18 2019), Windows 10 x86_64.

When doing MIDI export, notes with a negative “playback end offset” property that would put the end time before the start time, instead underflow and put the end time at some arbitrary future time, either the end of the score, before the next time the same note appears, or some unknown time between them. This causes corrupted MIDI output. Perhaps this issue also occurs if the “playback start offset” is set to a large enough positive number that the note has negative length, I haven’t tried this.

To reproduce:
Input the pictured score.
Select the first eight notes and set their “playback end offset” to -1000.
Export as MIDI (also attached) and import into your favorite DAW or MIDI editor.
Obtain the following result:


Expected behavior:
I’m not sure what should be the expected behavior for notes with negative length–probably they should just be omitted, but since this is most likely a situation the user does not want to exist, perhaps a warning to the user would be helpful. Alternatively, the warning could ask the user whether they want to omit notes with negative length, or to ignore the playback start and end offsets for those notes and just export them as written visually. Another alternative would be to prohibit notes from having offset values which would lead to negative lengths–this might be more difficult to implement because there are many edit operations which could change the note’s value, and hence change a legal set of offsets into an illegal one.

Problem genesis:
I wrote the majority of a score as MIDI in a DAW, then imported it into Dorico for fixes and cleanup as well as engraving. I did not pay any attention to the playback start and end offsets which had been set upon MIDI import, because they didn’t affect the appearance in Dorico. However, evidently I edited the length of some of these notes in such a way that resulted in negative lengths when taking into account their end offsets. Then, when exporting MIDI back to my DAW, there were mysterious very long notes that stretched across long lengths of time.

The resulting MIDI file (forum does not allow upload of .mid, so I had to zip it):
underflow.zip (342 Bytes)

Thanks very much for the clear bug report. I can confirm the problem and we’ll take care of it in a future version of the software.

This happens to me regardless of start and end offsets. Exporting MIDI and opening in Cakewalk results in long notes that last for the entire file that have to be manually shortened. More worryingly, Dorico sets many notes as almost zero length when entered, these won’t playback as they are simply too short to get triggered, I thought this was caused by adding staccato dots, but other runs of staccato play back OK while some notes (seemingly at random) end up zero length. I’m using the PC keyboard/mouse to enter notes into Dorico BTW. The only way to fix them once in my DAW is to zoom in and manually extend them to a playable length. I’m exporting MIDI to my DAW as its editing features are more developed than Dorico’s at present.

Can’t praise the development team enough for such an amazing programme, but inevitably there will be things like this that can take time to investigate. I need MIDI export to work so hoping you can look into this strange behaviour. Thanks.

If you can provide us with some test data, Nick, then we will gladly look into it. Please attach the problematic files here (the source Dorico projects, of course, rather than the MIDI files) rather with a description of where you see the problems, and we’ll take a look.

Thanks for the reply Daniel. I managed to get it to do it again so included just the Dorico Project file of the section of score that caused it. As requested I’ve not included the MIDI file, but have attached a DAW screen grab to show the results I’m getting. Pretty sure this isn’t a Cakewalk issue as I’ve never seen this before.
MIDI Export TEST File.rar (397 KB)

Thanks, Nick. This is indeed exactly the same issue as that reported by the original poster in this thread. The viola and cello pizz. notes in bar 4 each have negative end offsets in playback of -240 ticks, which gives them zero duration (Dorico uses 480 ticks per quarter note), and that will trigger a problem in MIDI export. In future, such notes will be exported with a 1 tick duration, though I question the value of setting notes to have negative or zero durations in this way in any case: if you want to prevent the note from playing back at all, I recommend using the ‘Muted’ property in the Common group of the Properties panel instead.