Need some help with MidiPlayer Rectangle list
-
When using:
List = MidiPlayer.getNoteRectangleList(a);
I get an array with the area for all MidiNoteEvents, I wonder if the order of the areas follow a specific order, like [area based on noteon & off eventId0, area based on noteon & off eventId1, etc...]?
I ask because I need to use the MidiPlayer.getEventList() list to modify some stuff.I've checked the length of both arrays (NoteRectangleList && EventList), and the EventList is 2 times longer than the NoteRectangleList, and it should be right? because the EventList contains NoteOn and the corresponding NoteOff event.
How can I check that index number 10 in the NoteRectangle list is based on the the NoteOn and NoteOff event from index 19 and 20, or does it not work that way?
It would be great to have the EventId attached to the corresponding Rectangle area in the NoteRectangleList.
Any help is appreciated :)
-
@ulrik said in Need some help with MidiPlayer Rectangle list:
I get an array with the area for all MidiNoteEvents, I wonder if the order of the areas follow a specific order, like [area based on noteon & off eventId0, area based on noteon & off eventId1, etc...]?
The order seems to follow the NoteOn + EventId order.
I've checked the length of both arrays (NoteRectangleList && EventList), and the EventList is 2 times longer than the NoteRectangleList, and it should be right? because the EventList contains NoteOn and the corresponding NoteOff event.
Not necessarily. For instance if you have a Controller event, it won't be reflected in the rectangle list, so the index will be messed up.
Moreover, you can't count on the index anyway because you might have several NoteOn before having the first NoteOff event.
But if you filter the event list to keep only the NoteOn, then you should end up having the same order and same length as the rectangle list, and where the associated EventId should give you the rectangle index.How can I check that index number 10 in the NoteRectangle list is based on the the NoteOn and NoteOff event from index 19 and 20, or does it not work that way?
It would be great to have the EventId attached to the corresponding Rectangle area in the NoteRectangleList.
See above
Another way to do it is to make your own rectangle list derived from the eventList. This way you are certain the order is the exact same as you need
-
@ulrik Oh! I've just seen there's a
convertEventListToNoteRectangles
method which does exactly this :)@Christoph-Hart this function doesn't seem to benefit from your last bar rounding fix seeing that the
x
andwidth
values aren't the same. That is probably because the eventList doesn't have the bar length info which makes sense...Left ->
getNoteRectangleList([0,0,100,128])
Right ->convertEventListToNoteRectangles(eventList, [0,0,100,128])
(the 3rd beat is around 75% on the left which is expected compared to the right) -
@ustk thank you!