All you need to know about MIDI commands
>From the 1 Feb 1996 meeting of Music 120
Contents: commands | functions | Jaffe-Schloss
MIDI information is a stream of bytes. A byte is eight bits. A bit number
that can be either a 1 or a 0. These two numbers are transmitted perhaps as
two different voltages along the MIDI cable, so if you could see the data
directly, you might see: 10010001 00111100 01111111
which is a command to turn on the note middle C on channel 2 with
the maximum possible key velocity.
Looking at the binary digits is not too useful for humans, so it is
convienient to think of the data in hexidecimal (or base-16) numbers.
Every four bits of the binary representation can be represented with
one hexidecimal number:
base-2 base-16 base-10 base-2 base-16 base-10
0000 0 0 1000 8 8
0001 1 1 1001 9 9
0010 2 2 1010 A 10
0011 3 3 1011 B 11
0100 4 4 1100 C 12
0101 5 5 1101 D 13
0110 6 6 1110 E 14
0111 7 7 1111 F 15
Thus the previous stream of MIDI data would be: 91 3c 7f.
Commands have a 1 in the highest order bit of the byte (8 bits),
as in the first digit of 10110110, while data starts with a 0, as in
01101110. In hexidecimal notation one byte can be represented by two
digits. In C, hexidecimal digits are indicated by prepending the two
characters "0x" to the actual hexidecimal numbers. So commands in
hexidecimal notation start at 0x80 (128) and go through 0xff (255). Data
can be between 0x00 (0) and 0x7f (127).
- A MIDI data byte starts with 0 through 7.
A MIDI command byte starts with 8 through f.
All numbers below are hexidecimal.
- Note on: 9n kk vv
- The 9n is the command for a note on one of
the 16 channels. The "n" stands for the channel number
offset at zero. For example, to send a note on channel one,
the command would be "90"; for channel two, "91"; for channel 16,
- kk stands for the MIDI key number, middle
C is 3c, the C octave above is 48, and so on. Vaild values
of kk range from 00 to 7f.
- vv stands
for the loudness of the MIDI note. Ranges from 00 to 7f.
- Note off: 9n kk 00
- Similar to note on, except that the loudness of the
note is set to 00.
- Note off (alternate): 8n kk vv
- Works similar to the previous note off, except that the command
starts with an "8" instead of a "9". The velocity data is ignored
by most synths.
- Program change: cn pc
- this command starts with the number "c" followed by the zero offset
channel number. The data byte ranges between 00 and 7f.
Used for changing instruments on a channel in a synthesizer.
For example to change to instrument 10 on channel 4, the
command would be c3 10.
- Realtime controller: bn tt xx
- tt specifies the controller number (like 07 for volume)
and xx is the data value for that controller.
- Channel pressure: dn pp
- What is channel pressure? How does it differ from aftertouch?
- Key aftertouch: an kk pp
- similar to a realtime controller, but the key aftertouch is a
measure of how hard the key is being pressed down after there is a
- Pitch wheel: en LL MM
- Purpose? LL is the least significant byte, and
MM is the most significant byte.
- System exclusive: f0 xx yy ... f7
- a system exclusive message starts with the number f0 and ends with
the number f7, and can have any number of characters between. The data
can have a 1 or a 0 in the most significant bit, since everything
before the f7 byte is considered a data byte. Usually used to transfer
setup data from the computer to the synthesizer, like loading new voices.
- I am alive: fe or f8
- some sequencers and synthesizers periodically put out the byte fe
or f8 to show the world they are still working.
- Running status:
- If the same command is repeated, the command byte can be omitted.
For example, the following bytes would play the notes C (middle C), D
and E at maximum keyvelocity on channel 3:
92 3c 7f 3e 7f 40 7f
The command byte, 92, does not have to be repeated
for notes D and E. A command byte can be recognized because it has
bit #7 = 1. In all data bytes, bit #7 = 0.
m_send is a low level function with will send any byte you want.
m_play, for example, uses m_send three times: once to sent the command
byte for note on, once to send the MIDI keynumber byte, and once to send
the key velocity byte of the note.
- sends the least significant 8 bits of "a" as a MIDI character
(a single byte).
- b = m_poll()
- returns a midi character if one has been received. Character
occupies the least significant 8 bits of b. Returns -1 if no midi
character has been received. The MIDI driver buffers incoming bytes
in a fifo.
- m_play(n, keyno, keyvelocity)
- sends a note on (or off) command on channe n (offset by 0).
- m_cont(n, controller, value)
- sends value to controller on channel n.
- m_pc(n, pc)
- sends program change pc on channel n.
- clock maintained by the main midi program. It is a variable
that is updated every millisecond.
Starting up the Jaffe-Schloss Mode on the Radio Baton
The default mode of the radio baton is the conductor program, so to
use commands listed here for the Jaffe-Schloss mode, you must send this
system exclusive message to the radio baton:
f0 2d f7
Sending commands to the radio baton
Single byte commands sent from the computer to the radio baton are
made on the channel pressure in channel 16 followed by a one-byte
The various values of xx are:
- 01 for request to poll baton 1.
- 02 for request to poll baton 2.
- 03 for request to poll pots.
- 05 for request to exit Jaffe-Scholss mode.
- 06 for request to put the baton into thru mode.
- 07 for request to take the baton out of thru mode.
Receiving information from the radio baton
Information sent from the radio baton to the computer uses a
controller message and an after touch message in MIDI channel 16 with
running status to send 4 bytes of op
code and information:
bf xx yy af zz ww
Return values for the polling functions:
- bf is the continuous controller
command on channel 16. (not being used as a continuous controller
- xx is the op code.
- yy, zz, ww are the information bytes
- af is the after touch command on channel 16.
(not being used as an aftertouch here).
- Response to Baton 1 poll:
- xx = 65 (101 decimal)
- yy = x-position of baton 1 (from 00
- zz = y-position of baton 1 (from 00
- ww = z-position of baton 1 (from 00
- Response Baton 2 poll:
- xx = 66 (102 decimal)
- yy = x-position of baton 2 (from 00
- zz = y-position of baton 2 (from 00
- ww = z-position of baton 2 (from 00
- Response to potentiometers poll:
- xx = 67 (103 decimal)
- yy = position of pot 1 (from 00
- zz = position of pot 2 (from 00
- ww = position of pot 3 (from 00
- Trigger information for Baton 1:
- xx = 6f (111 decimal)
- yy = x-position of Baton 1 at trigger (from 00
- zz = y-position of Baton 1 at trigger (from 00
- ww = wack (trigger velocity) of Baton 1 at trigger (from
00 to 7f)
- Trigger information for Baton 2:
- xx = 70 (112 decimal)
- yy = x-position of Baton 2 at trigger (from 00
- zz = y-position of Baton 2 at trigger (from 00
- ww = wack (trigger velocity) of Baton 2 at trigger (from
00 to 7f)
- Button push trigger b14+:
- xx = 72 (114 decimal)
- yy = 00
- zz = 00
- ww = 00
- Button push trigger b15+:
- xx = 73 (115 decimal)
- yy = 00
- zz = 00
- ww = 00
© 2001 Guy Malachi, All Rights Reserved