Can someone show me how I can Iterate thru the midiMessages? What is the exact syntax for the midibuffer Iterator. At the moment I just need to know when keys were pressed and what they were, any help or examples would be appreciated.
MidiMessage message (0);
MidiBuffer::Iterator i (midiMessages);
int messageFrameRelativeTothisProcess;
while (i.getNextEvent (message, messageFrameRelativeTothisProcess))
{
// here you typically use message
if (message.isNoteOnOrOff ())
{
int note = message.getNoteNumber ();
message.setNoteNumber (note + 12); // transpose it
}
}
a midi message with just zeroes is not valid, it has to begin with one of predefined bytes, though i think that MidiMessage (0) should be valid to indicate a uninitialized midi messages, because 0xf0 is a completely valid message and this object can’t be distinguished from a uninitialized message.