Getting the length of a MIDI Note ON Event

Hi guys,

I'm trying to get the length of a midi note ON event from a MIDI file I'm reading in using the JUCE midi libraries. However, I'm not sure the best way to do this. I don't see any functions in the documentation that specifically can get the length of a midi note on event (could be blind though, tends to be the case for me).

Would the following psuedocode be the best way to do this, or is there some built-in way (like a getLength() function that I probably missed when looking)?

for (i in list of midi note events) 
{
   noteLength = midiNoteEvent(i+1).timestamp - midiNoteEvent(i).timestamp();
}

Thanks in advance!

You need to compute this manually.

do a map of each note on you find parsing the file, and when you find the corresponding note off, assign its length

Actually, the MidiMessageSequence class handles the task of matching note ons + offs.