The Midi Parser
State Diagram
Here is a simplified state diagram for the MIDI parser:
in graphviz format until graphviz plugin is installed:
digraph G
{
size="7,7";
rankdir = LR;
fontsize="5";
node [ shape="box" ];
POWER_ON;
FIND_STATUS;
FIRST_OF_ONE;
FIRST_OF_TWO;
SECOND_OF_TWO;
FIRST_OF_ONE_NORUN;
SYSEX_DATA;
POWER_ON -> FIND_STATUS;
FIND_STATUS -> FIND_STATUS [ label="A" ];
FIND_STATUS -> FIRST_OF_ONE [ label="B" ];
FIND_STATUS -> FIRST_OF_TWO [ label="C" ];
FIND_STATUS -> SYSEX_DATA [ label="D" ];
SYSEX_DATA -> SYSEX_DATA [ label="K" ];
SYSEX_DATA -> FIND_STATUS [ label="E" ];
FIND_STATUS -> FIRST_OF_ONE_NORUN [ label="F" ];
FIRST_OF_ONE_NORUN -> FIND_STATUS [ label="G" ];
FIRST_OF_TWO -> SECOND_OF_TWO [ label="H"];
SECOND_OF_TWO -> FIRST_OF_TWO [ label="J"];
FIRST_OF_ONE -> FIRST_OF_ONE [ label="L" ];
}
| Note | Description |
| A | Ignore all bytes less than 0x80 |
| B | Control Change, Program Change, Channel Aftertouch |
| C | Note On, Note Off, Bender, Note Aftertouch |
| D | Sysex start 0xf0 |
| E | Sysex end, or any status byte aborts |
| F | Midi Time Code, 0xf1 |
| G | Always |
| H | As long as byte is less than 0x80 |
| J | Running Status if byte is less than 0x80 |
| K | Any sysex data byte less than 0x80 |
| L | Running Status if byte is less than 0x80 |
Also note that ANY byte 0x80 or larger is always dispatched via the FIND_STATUS state, as the status byte can always reset the state machine to this point.
Header Source
/trunk/libjdkmidi/trunk/include/jdkmidi/parser.h
