I’m trying to create something like a piano roll. So I thought that I could do it with a MidiMessageSequence and a ownedarray of a Note class (which is a simple Component with a pointer to its MidiMessageSequence’s MidiEventHolder).
However when I want to add a new ‘Note’, as it must have the pointer, in first place I must add a couple of MidiMessage to MidiMessageSequence. But once I add it with addEvent the MidiMessageSequence arranges itself according to their timestamps, so I lose the track of the last added MidiMessage. In this point I have two options:
Adding the couple of the events to the end of the sequence (with higher timestamps), take the pointer, and modify the timestamps of the MidiEventHolder. But I don’t know if doing this could broke something (does MidiMessageSequence rearrange itself when I modify any of the MidiEventHolders?)
Comb the OwnedArray and the MidiMessageSequence to look for what MidiEventHolder don’t have been assigned to a Note object. This seems tedious and slow however. I could save some CPU time combing the MidiMessageSequence only in the timestamp where I added the lastest event.
Please, what should I do here? the first one, the second one or do you have a better idea?