Goffredo Haus, editor
Fall 1995
© IEEE Computer Society Press.


System Real Time Messages

Table XX

System Real Time messages are used to synchronize clock-based MIDI equipment. These messages serve as uniform timing information and do not have channel numbers.
Real Time messages can be sent at any time and may be inserted anywhere in a MIDI data stream, including between Status and Data bytes of any other MIDI messages. Giving Real-Time messages high priority allows synchronization to be maintained while other operations are being carried out.
As most keyboard instruments do not have any use for Real-Time messages, such instruments should ignore them. It is especially important that Real-Time messages do not interrupt or affect the Running Status buffer. A Real-Time message should not be interpreted by a receiver as a new status.
TIMING CLOCK: Clock-based MIDI systems are synchronized with this message, which is sent at a rate of 24 per quarter note. If Timing Clocks (F8H) are sent during idle time they should be sent at the current tempo setting of the transmitter even while it is not playing. Receivers which are slaved to incoming Real Time messages (MIDI Sync mode) can thus phase lock their internal clocks while waiting for a Start (FAH) or Continue (FBH) command.
START: Start (FAH) is sent when a PLAY button on the master (sequencer or drum machine) is pressed. This message commands all receivers which are slaved to incoming Real Time messages (MIDI Sync mode) to start at the beginning of the song or sequence.
CONTINUE: Continue (FBH) is sent when a CONTINUE button is hit. A sequence will continue from its current location upon receipt of the next Timing Clock (F8H).
STOP: Stop (FCH) is sent when a STOP button is hit. Playback in a receiver should stop immediately.

Start Or Continue Messages

When a receiver is synchronized to incoming Real Time messages (MIDI Sync mode), the receipt of a Start (FAH) or Continue (FBH) message does not start the sequence until the next Timing Clock (F8H) is received. The FA and F8 should be sent with at least 1 millisecond time between them so the receiver has time to respond. However, a receiver should be able to respond immediately to the first F8H after receiving the Start or Continue. Neither the transmitter nor the receiver advances during the interval between FA and F8. When the receiver is operating off of its internal clock, it may or may not start or stop when it receives an FA or FB.

Stop Message

When a master sequencer is stopped it should send out the Stop message (FCH) immediately, so that any other devices slaved to it will also stop. The sequencer's internal location should be set as it was in when Stop was sent. This way, if Continue is pressed, all instruments connected to the master will continue from the same point in the song without need for a Song Position Pointer message. Upon receiving a Stop message (FCH), a receiver should stop playing and not increment its Song Position when subsequent Timing Clock messages are received. The current Song Position should be maintained in the event that a Continue is received and the sequence is continued from the point that it was stopped. If a Song Position Pointer message is received, the device should change its internal Song Position and prepare to begin playback from the new location.
If any Note Off messages have not been sent for corresponding Note On's sent before Stop was pressed, the transmitter should send the correct Note Off messages to shut off those notes. An All Notes Off message can also be sent, but this should not be sent in lieu of the corresponding Note Off messages as not every instrument responds to the All Notes Off message. In addition to note events, any controllers not in their initialized position (pitch wheels, sustain pedal, etc.) should be returned to their normal positions.
The following illustration shows a method to keep correct synchronization. These examples use an internal timebase of 96 pulses per 1/4 note, or 4 internal clocks per MIDI clock.

Figure 5 - Example of correct synchronization

Relationship between Clocks and Commands

A sequencer may echo incoming timing and voice information out the MIDI Out port while playing its own sequenced parts. System Real Time messages should always be given time priority when the data is merged in this manner. To accomplish this, it is permissible to change the actual order of bytes to accommodate Real Time messages. However, all Real Time bytes (F8H, FAH, FBH, FCH) must be sent in the order in which they are received.
In the example below, a Note On message is delayed slightly in order to give a priority to sending an F8H.

Figure 6 - Example of correct synchronization

In order to avoid displacing clock messages in time, in addition to reversing their order with a voice message (as shown above), they may be also be inserted between the bytes of voice, common, or other messages. At no time should either an incoming clock byte or any voice message be dropped, but their order can be changed to accommodate the need for accurate timing.
A sequencer may continue sending timing clock (F8H) while it is stopped. The advantage of this is that a slaved device can know the starting tempo of a sequence just as the Start command is received.

Priority of Commands

Redundant commands, such as receiving a Stop command while already stopped, or a Start or Continue command while already playing, should simply be ignored.
If a clock based device receives commands both from its front panel and via its MIDI In, priority should be given to the most recently received command. However, it is also acceptable for a device to ignore either its front panel or incoming Real Time commands depending on its current operating mode. For example, a device set to respond to incoming MIDI clocks and Real Time commands may ignore the commands received from its front panel. It may also ignore incoming Real Time commands while set to operate with its internal clock.

Active Sensing

Use of Active Sensing is optional for either receivers or transmitters. This byte (FE) is sent every 300 ms (max) whenever there is no other MIDI data being transmitted. If a device never receives Active Sensing it should operate normally. However, once the receiver recognizes Active Sensing (FE), it then will expect to get a message of some kind every 300 milliseconds. If no messages are received within this time period the receiver will assume the MIDI cable has been disconnected for some reason and should turn off all voices and return to normal operation.
The following algorithm shows the correct method of implementing Active Sensing:

{MIDI Reception Interrupt}
BEGIN
Receive Data;
Clear Timer;
IF FE THEN Set Flag ELSE Other Operation;
END;
{Timer Interrupt}
BEGIN
IF Flag & ne; 0 THEN
BEGIN
Increment Timer;
IF > 300 ms THEN
BEGIN
Turn All Notes Off;
Reset Flag;
END;
END;
END;

System Reset

System Reset commands all devices in a system to return to their initialized, power-up condition. This message should be used sparingly, and should typically be sent by manual control only. It should not be sent automatically upon power-up and under no condition should this message be echoed.
If System Reset is recognized, the following operations should be carried out:


[Index | Main Paragraph ]