MMPM/2 Device Driver Reference:Types of MIDI Messages

There are three types of MIDI system messages: System-common messages are intended for all receivers, regardless of channel. System-exclusive messages are defined by the manufacturer and are not limited in length. System-real-time messages can interrupt other messages because they carry timing information. For example, a long system message might have an embedded timer message within it. Other MIDI events cannot occur within a system message or nested system message; however, a system message can occur in the middle of other MIDI events.
 * System common
 * System exclusive
 * System real time

While in MIDI mode, almost all functions provided by audio device drivers can be controlled by the application by using system-exclusive messages.

General Format of System-Exclusive Messages
The general format of system-exclusive messages is shown in the following table: The following list contains the categories of system exclusive messages:
 * 
 * 
 * 
 * 
 * 
 * 

Device Driver Control Messages
The following are types of device driver control messages:
 * Balance
 * Generic sound selection
 * Master volume
 * Tempo
 * Timing generation
 * Volume

Balance Control
This message sets the balance level for the audio device driver: F0 00 00 3A  03  08  bl  dl  dm  F7 bb = Balance level (0 = full left, 40 = middle, 7F = full right) dl = Duration LSB dm = Duration MSB Balance is specified as a relative value from 0 - 7F, where 0 is full left, 40 is middle, 7F is full right. The duration specifies the length of time (in tenths of a second) necessary to gradually go from the current level to the target level. For example, to set the balance to full right (7F) with duration set to 10 to gradually move the new balance to the right over a one-second period, the balance control message would be: F0 00 00 3A  03 08 7F 0A 00 F7

Generic Sound Selection
This message selects the generic sound for an instrument: F0 00 00 3A  03  03  ii  tt  ss  F7 ii = Instrument number tt = Sound type (0 = Musical instrument, 1 = sound effects) ss = Sound ID There are 128 generic musical instrument sounds and 128 sound effects types. When a requested sound is not available on a device, the nearest available sound is used. It is recommended that general MIDI mode be used instead of this message.

Master Volume Control
This message sets the master volume level for the audio device driver: F0 00 00 3A  03  09  vl  vm  00  F7 vl = Master Volume LSB vm = Master Volume MSB Master volume is intended to permit immediate control of overall volume without interfering with the current volume setting as set by the volume control message, described in Volume Control below. Volume is specified as a relative value from 0 - 3FFF. For example, to set the volume to maximum (3FFF) the master volume control message would be: F0 00 00 03 03 09 7F 7F 00 F7 This message causes a MIDI volume control change message to be generated. Any subsequent volume control change messages encountered are scaled proportionately. Actual volume is the product of volume and master volume.

Tempo Control
This message sets the tempo for system real-time timing clock generation: F0 00 00 3A 03  02  tl  tm  dd  F7

tl = Tempo LSB tm = Tempo MSB dd = Duration Notice that tempo is expressed as 1/10 beats per minute. The duration specifies the length of time (in tenths of a second) necessary to go gradually from the current tempo to the specified tempo. For example, to set the tempo to 120 beats per minute, with duration set to 0 to make the new tempo effective immediately, the tempo control message would be: 120 bpm = 1200 1/10 increments 1200 decimal = 00000100 10110000 binary 7 bit MSB (tm) = 000100 1       = hex 9 7 bit LSB (tl) =        0110000 = hex 30

F0 00 00 3A 03 02 30 09 00 F7

Timing Generation Control
This message tells the device driver what timing information to generate: F0 00 00 3A  03  01  tt  pp  00  F7

tt = System real-time control flags (default 08H) 0x1x xxxx Output timing clocks to MIDI-Out 0x0x xxxx Do not output timing clocks to MIDI-Out (default) 0xx1 xxxx Merge timing clocks with MIDI-In 0xx0 xxxx Do not pass timing clocks to MIDI-In (default) 0xxx 1xxx Synchronize output to timing clocks (default) 0xxx 0xxx Disable output synchronization 0xxx x1xx Perform timing data compression 0xxx x0xx Disable timing data compression (default) 0xxx xxRR Reserved bits - always 0

pp = System real-time 24 CPQN rate prescaler 00dd dddd Multiply by dddddd+1 (1-64) for 24 to 1536 ppq 01dd dddd Divide by dddddd+1*3 (3-192) for 8 to 1/8 ppq By default, device drivers utilize real-time messages at a rate of 24 per quarter note (beat) and 120 beats per minute internally for performing output synchronization. However, they do not queue timing clocks to either MIDI-Out or MIDI-In (Read data).

Volume Control
This message sets the volume level for the audio device driver. Volume is specified as a relative value from 0-7F. F0 00 00 3A  03  07  vv  dl  dm  F7

vv = Volume (0-7F) dl = Duration LSB dm = Duration MSB The duration specifies the length of time (in tenths of a second) necessary to gradually go from the current level to the target level. For example, to set the volume to maximum (7F) with duration set to 0 to make the new volume effective immediately, the volume control message would be: F0 00 00 3A 03 07 7F 00 00 F7 This message causes subsequent MIDI volume control change messages to be generated. Any subsequent volume control change message encountered will be scaled proportionately. Notice that the actual volume is the product of volume and master volume.

Device Driver Query Messages
The following are types of device driver query messages:
 * Query device capability
 * Query Device ID
 * Query output queue size

Query Device Capability
This message is issued to a device driver by an application to query the basic capability of a device driver: F0 00 00 3A 04  01  F7 The device driver responds to this message by returning a device capability response message (see ).

Query Device ID
This message is issued to a device driver by an application to request the identity of the device driver: F0 00 00 3A 04  04  F7 The device driver responds to this message by returning a device ID response message, which identifies the device (see ).

Query Output Queue Size
This message is issued to a device driver by an application to request the size of the output queue: F0 00 00 3A 04  02  F7 The device driver responds to this message by returning a queue size response message (see )

Device Driver Response Messages
The following are types of device driver response messages:
 * Device capability
 * Device ID
 * Queue size

Device Capability Response
This message is sent by a device driver in response to a query device capability message (see ). It indicates the basic MIDI capability of the device driver. F0 00 00 3A 05  01  ii mm 00 F7

ii = Number of sound generators (instruments) mm = MIDI capability flags 01xx xxxx MIDI input is supported 0x1x xxxx MIDI output is supported 0xx1 xxxx System real-time Timing clocks are supported

Device ID Response
This message identifies the device and is sent by a device driver in response to a query device ID message (see ). F0 00 00 3A 05  04  b1 b2 b3 F7

b1 = 1st byte of Device ID b2 = 2nd byte of Device ID b3 = 3rd byte of Device ID This message is provided to permit applications to perform device unique operations such as issuing device-specific system exclusive messages.

Queue Size Response
This message is sent by a device driver in response to a query output queue size message (see ). It indicates the total output queue size in bytes. F0 00 00 3A 05  02  ll mm 00 F7

ll = Lower 7 bits of queue size mm = Upper 7 bits of queue size (Queue Size in bytes = 00mm mmmm mlll llll) For example, if the device driver's output queue is 512 bytes in length, the returned data is: F0 00 00 3A 05  02  00  04  00  F7

Sound Generator Commands Messages
These messages are specific to a certain device. Although not part of the audio device driver's architecture, they are included here. Notice in the following example that the 6th MIDI byte identifies the specific IBM device that is addressed:

M-ACPA (IBM Audio Capture & Playback Adapter)

Program Change Enable
This message instructs the M-ACPA synthesizer to honor or ignore MIDI program change messages (Cn). F0 00 00 3A  02  01  01  ee  00  F7

ee = Program Changes Enable (0 = disabled, 1 = enabled; default) By default, program changes are honored. Notice that this message does not affect generic sound selection messages, which are always honored.

Timbre Parameter Messages
Timbre parameter messages are provided to permit interrogating and changing of the parameters that control the timbre of a given voice. Parameters are addressed using three 7-bit bytes (that is, 21 bits), enabling approximately two million parameters to be addressed. In most cases, these parameters are divided into units such as banks, voices, and so forth. Parameter values are passed in two 7-bit bytes, allowing up to 14-bits per parameter.

The following are types of timbre parameter messages:
 * Query timbre parameter
 * Request timbre block
 * Set timbre parameter
 * Timbre block
 * Timbre parameter response
 * Write timbre block

Query Timbre Parameter
This message is issued to a device driver by an application to request the current setting of a timbre parameter: F0 00 00 3A 06  01  hh  mm  ll  F7

hh = High 7-bits parameter # mm = Middle 7-bits parameter # ll = Low 7-bits parameter # The device driver responds to this message by returning a timbre parameter response message (see below).

Request Timbre Block
This message is issued to a device driver by an application to request a block of timbre data. F0 00 00 3A 06  04  hh  mm  00  F7

hh = High 7-bits block # mm = Middle 7-bits block # The device driver responds to this message by returning a timbre block message (see below).

Set Timbre Parameter
This message is used to set or change a timbre parameter: F0 00 00 3A 06  03  hh mm ll dl dm F7

hh = High 7-bits parameter # mm = Middle 7-bits parameter # ll = Low 7-bits parameter # dl = Parameter data LSB (0-127) dm = Parameter data MSB

Timbre Block
This message is issued by a device driver in response to a request timber block message (see above). It transfers blocks of timbre data from a device driver to an application. F0 00 00 3A 06  05  hh  mm  ll   F7

hh = High 7-bits block # mm = Middle 7-bits block # ll = Length of 7-bit data = Variable length (7-bit) data block

Timbre Parameter Response
This message is sent by a device driver in response to a query timbre parameter message (see above). It returns the current value of a timbre parameter. F0 00 00 3A 06  02  hh mm ll dl dm F7

hh = High 7-bits parameter # mm = Middle 7-bits parameter # ll = Low 7-bits parameter # dl = Parameter data LSB (0-127) dm = Parameter data MSB

Write Timbre Block
This message is issued to a device driver by an application to write a block of timbre data: F0 00 00 3A 06  06  hh  mm  ll  &lt; len &gt;  F7

hh = High 7-bits block # mm = Middle 7-bits block # ll = Length of 7-bit data = Variable length (7-bit) data block

Timing Compression Messages
These messages are used to compress sequential timing clocks (F8) into a single system exclusive message. Up to 16383 (that is, F8 Timing clocks can be compressed into a single 6- or 8-byte message, which can be written to a device driver to cause a delay between output events if output synchronizing is enabled (see ). F0 00 00 3A  01  ll  mm  F7  (Long version) F0  00 00 3A  nn  F7          (Short version)

ll = Number of System Real Time Timing Clocks LSB mm = Number of System Real Time Timing Clocks MSB nn = Number of System Real Time Timing Clocks (nn = 7 through 127)

The short version can be used to represent durations of from 7 - 127 clocks. Longer durations can be represented with the long version, where the number of timing clocks that have occurred is calculated by combining the low 7-bits of mm with the low 7-bits of ll to produce a single 16-bit value: 0mmm mmmm + 0lll llll = 00mm mmmm mlll llll