The MIDI Forum

  1. Jan Kučera
  2. MIDI Specifications
  3. Sunday, 31 January 2016
  4.  Subscribe via email
Hello,

so my understanding is that if I don't support or don't know particular MIDI event, I can simply ignore it - and all the data following, until the next status byte. That also means losing the running status data, but that is probably fine. However, in SMF, if I start ignoring either status or even just normal messages/data, how am I supposed to recover? When I don't know how many bytes to ignore, I don't know whether I am still reading the message or already delta time of another one... and missing a delta time means the rest of the file will have wrong timing.

For example, let's say I run into this:
00 F4 05 02 40 7F 80 3C 40 ...

Well my intention was
00 | F4 05
02 | 40 7F
80 3C | 40 ...

But it could alo mean
00 | F4 05 02 40
7F | 80 3C 40 ...

What is the file reader supposed to do?
Comment
There are no comments made yet.
Accepted Answer Pending Moderation
0
Votes
Undo
In a 'raw' stream of MIDI bytes, status and data bytes can be differentiated by the most significant bit.

In SMF files, both status bytes and timestamps can use bytes with the MSB set, so parsing them requires knowing the length of messages.

F4 is invalid, and must not appear as an event in SMF files. (In theory, to send an F4 byte out of the MIDI port, an SMF file would have to use an escaped event (F7).)

When you encounter an invalid event, such as F4, the best you can do is to abort parsing and return an error.
Comment
There are no comments made yet.
  1. more than a month ago
  2. MIDI Specifications
  3. # 1
Accepted Answer Pending Moderation
0
Votes
Undo
If I understand the question correctly, I would say you can't ignore any event, you can just ignore events by not interpreting it. To parse a Standard MIDI File, you need to know how many data bytes comes with a message. There are the one with variable length quantities, which can all be parsed the same way while not interpreting it. And there are the ones with a varying number of payload bytes, ranging from zero data byte to two data bytes. There are just a few of these, so that cost nothing for an application to know it.

To properly parse a Standard MIDI File, an application needs to be aware of the format of four cases: three variable length quantity messages (0xF0, 0xF7, 0xFF), height system messages (0xF2, 0xF3, 0xF6, 0xF8, 0xFA, 0xFB, 0xFC, 0xFE), seven channel messages (0x8n, 0x9n, 0xAn, 0xBn, 0xCn, 0xDn, 0xEn), channel message using running status data bytes (< 0x80 and be aware of running status cancellation condition). That's a bit simplified (0xF0 and 0xF7 needs to be distinguished), but close to the what it is.

Ignoring, yes, but not entirely, as minimum handling is required for parsing.
Comment
There are no comments made yet.
  1. more than a month ago
  2. MIDI Specifications
  3. # 2
Accepted Answer Pending Moderation
0
Votes
Undo
[…]

When you encounter an invalid event, such as F4, the best you can do is to abort parsing and return an error.

There are five of these (as far as I know): 0xF1, 0xF4, 0xF5, 0xF9, 0xFD
Comment
There are no comments made yet.
  1. more than a month ago
  2. MIDI Specifications
  3. # 3
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.