midiOutSetVolume

  MMRESULT midiOutSetVolume(wDeviceID, dwVolume)    
  UINT wDeviceID;    
  DWORD dwVolume;    

The midiOutSetVolume function sets the volume of a MIDI output device.

Parameters

wDeviceID

Identifies the MIDI output device.

dwVolume

Specifies the new volume setting. The low-order UINT contains the left channel volume setting, and the high-order UINT contains the right channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.

If a device does not support both left and right volume control, the dwVolume specifies the volume level, and the high-order UINT is ignored.

Return Value

Returns zero if the function was successful. Otherwise, it returns an error number. Possible error returns are:

Value Meaning

MMSYSERR_INVALHANDLE Specified device handle is invalid.
MMSYSERR_NOTSUPPORTED Function isn't supported.
MMSYSERR_NODRIVER The driver was not installed.

Comments

Not all devices support volume changes. To determine whether the device supports volume control, use the MIDICAPS_VOLUME flag to test the dwSupport field of the MIDIOUTCAPS structure (filled by midiOutGetDevCaps).

To determine whether the device supports volume control on both the left and right channels, use the MIDICAPS_LRVOLUME flag to test the dwSupport field of the MIDIOUTCAPS structure (filled by midiOutGetDevCaps).

Most devices do not support the full 16 bits of volume level control and will use only the high-order bits of the requested volume setting. For example, for a device that supports 4 bits of volume control,requested volume level values of 0x4000, 0x4fff, and 0x43be will all produce the same physical volume setting, 0x4000. The midiOutGetVolume function will return the full 16-bit setting set with midiOutSetVolume.

Volume settings are interpreted logarithmically. This means the perceived increase in volume is the same when increasing the volume level from 0x5000 to 0x6000 as it is from 0x4000 to 0x5000.

See Also

midiOutGetVolume