MidiMessageSequence sorted?


Hi Jules,

I think I’ve found a bug in MidiMessageSequence or, at least, an inconsistency with the doc.

The sequence is, indeed, kept sorted, unless you modify the events in it in a way they change the order of the sequence.
For example, if I have two noteOn, then two noteOff and I move one noteOff inbetween the noteOn’s the sequence isn’t sorted by timestamp anymore : (first field is the time stamp, the second is the message number)

<Sequence>------------------- <Event>------------------- 0 144 60 100 </Event>------------------- <Event>------------------- 1920 144 72 100 </Event>------------------- <Event>------------------- 1189 128 60 64 </Event>------------------- <Event>------------------- 3109 128 72 64 </Event>------------------- </Sequence>-------------------

I can easily fix this by adding

MidiMessageSequenceSorter sorter; list.sort (sorter, true);

at the end of updateMatchedPairs() but I don’t want to touch juce code.

Would you mind , either adding that code to updateMatchedPairs, or create another method like

MidiMessageSequenceSorter sorter;
list.sort (sorter, true);

please ?


Thanks, good idea. Adding a sort() method seems like the best plan.


In my case it makes absolutely no difference, but I agree with you that it’s better in general. Don’t forget to update the docs :wink: