According to the MIDI Standard, a ‘MIDI System Reset’ message is 1 byte message with a status byte of 0xFF.
However, when MidiBufferHelpers::findActualEventLength() encounters a status byte of 0xFF it reads it as a variable length message and seems to return garbage:
else if (byte == 0xff)
{
s32 n;
const s32 bytesLeft = MidiMessage::readVariableLengthVal (data + 1, n);
size = jmin (maxBytes, n + 2 + bytesLeft);
}
Any idea what the intention is here? Is 0xFF used as some special sentinel value in MidiBuffer?
OK, after a bit more research I found this:
Note on status byte 0xFF
The reset message (a system realtime message) carries the same status byte as a meta message: 0xFF. By convention, the MIDI reset message is never placed in MIDI files but is only sent over MIDI ports upon a request by the user. Thus, if a MIDI device receives the status byte 0xFF over a MIDI port, the device will interpret it as a “reset” message. If the MIDI device reads the status byte 0xFF from within some MIDI file, the device will interpret the message as a meta message.
So the answer seems to be to never add a MIDI System Reset message to a MidiBuffer.
1 Like