80.5.2 Querying MIDI Output Devices

Before playing MIDI audio, you should call the midiOutGetDevCaps function to determine the capabilities of the MIDI output hardware present in the system. This function takes a pointer to a MIDIOUTCAPS structure that it fills with information on the capabilities of a given device. This information includes the manufacturer and product IDs, a product name for the device, and the version number of the device driver. In addition, the MIDIOUTCAPS structure provides information on the device technology, the number of voices and notes supported, the MIDI channels that the device responds to, and features supported by the driver.

The MMSYSTEM.H file defines the MIDIOUTCAPS structure as follows:

typedef struct midioutcaps_tag {

UINT wMid; /* manufacturer ID */

UINT wPid; /* product ID */

VERSION vDriverVersion; /* driver version */

char szPname[MAXPNAMELEN]; /* product name */

UINT wTechnology; /* device technology */

UINT wVoices; /* total simultaneous instruments */

UINT wNotes; /* total simultaneous notes */

UINT wChannelMask; /* channels device responds to */

DWORD dwSupport; /* features supported */

} MIDIOUTCAPS;

80.5.2.1 Determining the Technology of the Device

MIDI output devices can be either internal synthesizers or external MIDI output ports. The wTechnology field specifies the technology of the device. MMSYSTEM.H defines the following flags to identify device technology:

Flag Description

MOD_MIDIPORT The device is an external MIDI output port.
MOD_SQSYNTH The device is an internal square-wave synthesizer.
MOD_FMSYNTH The device is an internal FM synthesizer.
MOD_SYNTH The device is an internal synthesizer (generic).
MOD_MAPPER The device is the MIDI Mapper.

80.5.2.2 Determining Capabilities of Internal Synthesizers

If the device is an internal synthesizer, additional device information is available in the wVoices, wNotes, and wChannelMask fields. If the device is an external output port, these fields are unused.

The wVoices field specifies the number of voices the device supports. Each voice can have a different sound or timbre. Voices are differentiated by MIDI channel. For example, a four-voice synthesizer uses four MIDI channels. The wNotes field specifies the polyphony of the device—the maximum number of notes that can be played simultaneously. The wChannelMask field is a bit representation of the MIDI channels that the device responds to. For example, if the device responds to the first eight MIDI channels, wChannelMask is 0x00FF.

The dwSupport field of the MIDIOUTCAPS structure indicates if the device driver supports volume changes and patch caching. MMSYSTEM.H defines the following flags for the dwSupport field:

Flag Description

MIDICAPS_VOLUME Indicates the driver supports volume control.
MIDICAPS_LRVOLUME Indicates the driver supports individual volume control for the left and right channels.
MIDICAPS_CACHE Indicates the driver supports patch caching.

Volume changes are only supported by internal synthesizer devices. External MIDI output ports don't support volume changes. For information on changing volume, see “Changing Internal MIDI Synthesizer Volume,” later in this chapter.