I see that this has sort of come up before on the forums but I couldn't see any resolution.
I'm writing a MIDI editor and started considering the use of MidiMessageSequence as a container for events but I'm now wondering if that's the wrong choice. The main problem is that the class doesn't continuously enforce matched note on/off pairs. eg:
- You can remove a note off event without removing the note on.
- Copying the sequence to another one doesn't copy the matched pair info
- addSequence() has no intelligence about adding mismatched pairs (ie. it'll happily copy over note ons without their corresponding note offs if they fall outside range, and note offs without note ons).
- updateMatchedPairs() always discards any current pairing info and begins from scratch. It also does some odd things by artificially adding extra note offs as soon as it encounters a note on with the same note number before that note has been turned off. Although I agree that the note on will need a note off somewhere, it doesn't need to occur before another note on, and presumably this action will often leave the 'real' note off for that event still hanging around somewhere later on in the sequence. The one situation where I would expect it to add extra note offs is where it comes to the end of the sequence and finds there are more ons than offs (ie. hanging notes) but it doesn't do this.
Maybe I could wrap it in a higher level class to enforce a more strict behaviour? I'd be also tempted to modify MidiMessage sequence so that MidiEventHolders are doubly linked - ie. those containing note off messages also have a 'back link' to the corresponding note on, in the same way the holder with the note on has a forward link to the note off.
What I'm asking in a rambling way is, has anyone else applied MidiMessageSequence successfully to anything other than holding fairly static MIDI file data, and did you encounter/solve any of these problems?