Using the MCI MIDI Sequencer

The MCI MIDI sequencer plays standard MIDI files and RIFF MIDI files (RMID files). Standard MIDI files conform to the “Standard MIDI Files 1.0” specification. See Chapter 3, “Introduction to Audio,” for information on this specification. Because RMID files are standard MIDI files with a RIFF header, information on standard MIDI files also applies to RMID files.

There are currently three variations of standard MIDI files. The MCI sequencer plays only two of these: Format 0 and Format 1 MIDI files.

Querying for Sequence Division Types

The division type of a MIDI sequence refers to the technique used to represent the time between MIDI events in the sequence. Use the MCI_STATUS command and set the dwItem field of the MCI_STATUS_PARMS parameter block to MCI_SEQ_STATUS_DIVTYPE to determine the division type of a sequence.

If the MCI_STATUS command is successful, the dwReturn field of the MCI_STATUS_PARMS parameter block contains one of the following values to indicate the division type:

Value Division Type

MCI_SEQ_DIV_PPQN PPQN (parts-per-quarter note)
MCI_SEQ_DIV_SMPTE_24 SMPTE, 24 fps (frames per second)
MCI_SEQ_DIV_SMPTE_25 SMPTE, 25 fps
MCI_SEQ_DIV_SMPTE_30 SMPTE, 30 fps
MCI_SEQ_DIV_SMPTE_30DROP SMPTE, 30 fps drop frame

You must know the division type of a sequence to change or query its tempo. You can't change the division type of a sequence using the MCI sequencer.

Querying and Setting the Tempo

Use the MCI_STATUS command and set the dwItem field of the MCI_STATUS_PARMS parameter block to MCI_SEQ_STATUS_TEMPO to get the tempo of a sequence. If the MCI_STATUS command is successful, the dwReturn field of the MCI_STATUS_PARMS parameter block contains the current tempo.

To change tempo, use the MCI_SET command with the MCI_SEQ_SET_PARMS parameter block. Specify the MCI_SEQ_SET_TEMPO flag and set the dwTempo field of the parameter block to the desired tempo. MMSYSTEM.H defines the MCI_SEQ_SET_PARMS parameter block as follows:

typedef struct {
    DWORD   dwCallback;                /* callback for MCI_NOTIFY flag */
    DWORD   dwTimeFormat;        /* time format */
    DWORD   dwAudio;                /* audio channel (not used by sequencer) */
    DWORD   dwTempo;                /* tempo */
    DWORD   dwPort;                        /* output port */
    DWORD   dwSlave;                /* slave sync type */
    DWORD   dwMaster;                /* master sync type */
    DWORD   dwOffset;                /* SMPTE offset */
} MCI_SEQ_SET_PARMS;

Summary: Tempo Representation and Division Type

The way tempo is represented depends on the division type of the sequence. If the division type is PPQN, the tempo is represented in beats per minute. If the division type is one of the SMPTE division types, the tempo is represented in frames per second. See the previous section, “Querying for Sequence Division Types,” for information on determining the division type of a sequence.

Changing Sequencer Synchronization

To change the synchronization mode of a sequencer device, use the MCI_SET command along with the MCI_SEQ_SET_MASTER and MCI_SEQ_SET_SLAVE flags. Two fields in the MCI_SEQ_SET_PARMS parameter block, dwMaster and dwSlave, are used to specify the master and slave synchronization modes.

The master synchronization mode controls synchronization information sent by the sequencer to an output port. The slave synchronization mode controls where the sequencer gets its timing information to play a MIDI file. The following table shows the different modes for master and slave synchronization and the corre-sponding constant for the dwMaster and dwSlave fields:

Synchronization Mode   Constant  

Master   ^  
  MIDI Sync—Send timing information to output port using MIDI timing clock messages   MCI_SEQ_MIDI
  SMPTE Sync—Send timing information to output port using MIDI quarter frame messages   MCI_SEQ_SMPTE
  No Sync—Send no timing information   MCI_SEQ_NONE
Slave   ^  
  File Sync—Get timing information from MIDI file   MCI_SEQ_FILE
  MIDI Sync—Get timing information from input port using MIDI timing clock messages   MCI_SEQ_MIDI
  SMPTE Sync—Get timing information from input port using MIDI quarter frame messages   MCI_SEQ_SMPTE
  No Sync—Get timing information from MCI commands only and ignore timing information such as tempo changes that are in the MIDI file   MCI_SEQ_NONE

Note:

Currently, for master synchronization, the MCI MIDI sequencer supports only the “no synchronization” mode (MCI_SEQ_NONE). For slave synchronization, it only supports the file synchronization mode (MCI_SEQ_FILE) and the “no synchronization” mode (MCI_SEQ_NONE).