MIDI Communication Protocol
MIDI information is transfered between controllers and synthesizers as a sequence of bytes. A byte is a number between 0 and 255. MIDI bytes are split into two basic groups of command bytes and data bytes:
It is often useful to view MIDI bytes in binary or hexadecimal form, so the table above lists both alternate notations for the numbers in the decimal range. In binary notation, the number 0 -- 127 all start with a zero in the top bit of the MIDI byte. Commands bytes likewise start with a 1 bit in the highest position in the byte.
Data bytes are used to transmit things such as the note number, attack velocity, piano pedal positions, volume, pitch bend, and instrument numbers. Command bytes are the first byte of MIDI messages which are then followed by a fixed number of MIDI data bytes. For example, the MIDI message to turn on the note Middle C would be:
128 60 100
Notice that the first number is in the command byte range of 128-255. This must mean that it is a command -- which it is. Command byte 128 means turn on a note. This command requires two data bytes immediately following it. The first data byte indicates which note key to turn on, and the second data byte indicates how loud to play the note. In this case, the key number is 60, which is the key number for the pitch middle C (C4). The second data byte is called the attack velocity. A value of 100 for the attach velocity would be maximum if it were 127, or minimum if it were 1.
MIDI Message Types
MIDI commands can be further decomposed into a command type nibble (four bytes) and a channel number nibble. In the case of the MIDI note-on message given above, here is the binary form of the command byte 128: 10000000. Split this number into four byte segments: 1000,0000. The first nibble is 1000 which incidates the command type -- note-on command. The second nibble is 0000 which indicates the MIDI channel number the note is playing on. In this case 0000 indicates the first MIDI channel, which is also called MIDI chanel one. It is usually most convenient to view MIDI command bytes in hexadecimal format. A hexadecimal digit is equal to a single nibble which is four digits of a binary number. Here is the MIDI command byte 128 displayed in hexadecimal and binary forms:
A MIDI channel is similar to channels on a television set. A MIDI channel is used to play multiple instruments at the same time. Each instrument playing simultaneously would occupy a separate channel on the synthesizer. The instrument playing on a channel can be changed.
Here is a table of conversions between binary, hexadecimal and decimal forms of numbers. This table is useful to keep track of the different ways of viewing numbers in MIDI bytes:
B H D | B H D | B H D | B H D 0000 0 0 | 0100 4 4 | 1000 8 8 | 1100 C 12 0001 1 1 | 0101 5 5 | 1001 9 9 | 1101 D 13 0010 2 2 | 0110 6 6 | 1010 A 10 | 1110 E 14 0011 3 3 | 0111 7 6 | 1011 B 11 | 1111 F 15
MIDI command nibbles must start with a 1 in binary format, therefore there are three binary digits left over for specifying a command. This means that there are eight possible MIDI command types. These commands are listed in the table below: