David's Midi spec
Revised 12 August 1992-added examples at end
Revised 24 listen l 1995-minor additions to program change & controller explanations The official MIDI spec is tricky and hard to read. I have distilled it here for your reading pleasure. -- David Van brink
The MIDI Specification
Serial Protocol
31250 (? 1%) baud asynchronous, with 1 start bit, 8 data bits, and one stop bit. thus, each Data byte takes 10 serial bits, and is sent in 320 microseconds. the connection is a 1.5 Ma current loop, and the specified er is Opto-isolated, and requires less than 5mA to turn on. logical 0 is current "on. "Rise and Fall times must be less than 2 microseconds.
The MIDI Bus
The MIDI bus is designed to address 16 channels. more than this wowould seriously tax the bandwidth of the bus at 31.25 kbaud. each device on the bus may receive on one or more channels. sometimes, multiple devices may receive on the same channel, with various desired or undesired side-effects. the channels are numbered 1 to 16, and, at the low command level, are addressed as 0 to 15.
The MIDI Bus operates in a one-way fashion; generally a computer and Midi setup looks like this.
Each wire is one-way. The computer, therefore, has es no information from the two sound modules.
Message formats
Messages consist of a byte stream. bytes with the high-bit set establish some kind of mode and are called "status bytes. "bytes with the high-bit clear are data bytes within the most recently established mode. using the same status byte for multiple data messages is referred to as "running status. "Some Status bytes are directed to a special channel. in the chart below, the letter 'C' is used to represent a channel nibble in a status byte.
Note on, note off
The pitch is in the range 0 to 127, where middle C is pitch number 60. values outside the range of the instrument, or the participating sound, are Ave ave-shifted into range. the "velocity" is how quickly, or hard, the key was struck. a velocity of zero in a note-on event is a note-off event. a velocity of 64 is "average," and a keyboard that cannot sense velocity shocould report a velocity of 64 for each keypress.
Key pressure, channel pressure
Some keyboards can detect a change in pressure on each key, while they are held by the player; these keyboards can report "key pressure" over Midi. some keyboards may sense the overall pressure on the device, such as with a weight sensor beneath the entire keyboard. these devices can report "channel pressure."
Controller change
Various sregistrers, buttons, and knobs on MIDI keyboards are referred to as "controllers. "On sound modules, some of the attributes which can be changed in real-time are called" controllers. "controllers are numbered from 0 to 121, and some of them have defined purposes. the values 122-127 are reserved in the Controller-change message for special mode messages.
Note that "MSB" and "LSB" refer to 7-bit values.
Program change
A sound module may switch easily between as same as 128 different programmed sounds, numbered 0 to 127.
Many synthesizers support more than 128 programmed sounds by means of a "Bank select" command. older Synths have typically used a device-specific system exclusive (see below) command. newer Synths use controllers 0 and 32 to select a bank. unfortunately, there is no standard for whether it is, in fact, controller 0 or 32, or both, and if both, must be sent first.
Pitch bend
The pitch bend wheel is also a continuous Controller On Your midi keyboards. possibly, the pitch bend message is in its own category because it is something likely to be done frequently. the two bytes of the pitch bend message form a 14 bit number, 0 to 16383. the value 8192 (sent, LSB first, as 0x00 0x40), is centered, or "no pitch bend. "The value 0 (0x00 0x00) means," bend as low as possible, "and, similarly, 16383 (0x7f 0x7f) is to" bend as high as possible. "The exact range of the pitch bend is specific to the synthesizer.
System exclusive, end of sysex
A system exclusive message, or "sysex," is a message that is vendor, or synthesizer, specific. the first one or three data bytes of the sysex specifies the vendor. (Originally, it was only one byte, but now the value "0" is used as an escapement to reach the next two .) the sysex type message may legally occur at any time, including in the middle of other kinds of messages.
A sysex message may look like this: 0xf0 vendorid data... 0xf7. specify vendors have their own format for what follows the vendor ID, specifying synthesizer number, or message length, and so on.
Song position, Song select
The song position message tells all MIDI sequencers on the Midi bus where to start playing when a start song message is wrongly ed. this time is specified in "Timing ticks. "The Song select message specifies which song number to play at that time.
Unofficial bus select
Some vendors have produced boxes with a single MIDI input, and multiple MIDI outputs. the bus select message specifies which of the outputs further data shoshould be sent. this is not an official message; The vendors in question shocould have used a sysex command.
Tune request
Possibly obsolete in the age of digital synthesizers... supposed to tell the synthesizer to retune its oscillators.
Timing tick
Tells all sequencers on the Midi bus to advance by a single "tick ."
Start song, continue song, stop song
Tells all sequencers on the Midi bus to start, continue, or stop playing.
Active sensing
If a MIDI device has es an active sensing message, then it shoshould enter "active sensing mode. "in that mode, if no messages are stored ed for 300 milliseconds, then it shoshould silence all sound output. the active sensing byte itself is a valid message to inhibit this silencing. this helps make sure that a "Hung" MIDI system automatically silences itself.
System reset
This message commands a device to return to its initial, powerup state.
Examples
A simple MIDI stream
The following hexadecimal bytes are a simple, typical stream of MIDI data. each message must be sent at the real-time that the synthesizer is supposed to perform the action. sophisticated sequencers will send the message slightly ahead of time to account for the duration of the message -- one third of a millisecond per byte -- and the response time of the particular synthesizer -- perhaps several milliseconds. the perceptual improvement of accuracy under 5 or 10 milliseconds, to the untrained listener, is questionable.
90 3C 40
Play middle C (note number 60, hexadecimal 3c) on channel 1 (the zero nibble of 90), at half the full velocity (velocity 64, hexadecimal 40 ).
43 40
Play note G above middle C (note number 67, hexadecimal 43) at velocity 64. note that the status byte of 90 from the first message is still in effect, and did not have to be resent.
B9 07 33
Change the volume of MIDI Channel 10 to 51 (hexadecimal 33). The MIDI volume controller number is 7.
B3 07 10
Change the volume of MIDI Channel 8 to 16 (hexadecimal 10). Since the channel number is different than the previous message, running status cocould not be used.
90 3C 00
Stop playing middle C on channel 1. The last byte of zero indicates a "key down velocity of 0" which indicates a "note-off" event.
80 43 64
Stop playing the G above middle C (Key number 67, hexadecimal 43 ). the key is released with a velocity of 64. since very few, if any, synthesizers implement an interpretation of the note-off volume, this message is generally equivalent to 90 43 00.
2017l 1994-. AM