The Multimedia extensions provide the following functions to query and set the volume level of internal MIDI synthesizer devices:
midiOutGetVolume
Gets the volume level of the specified internal MIDI synthesizer device.
midiOutSetVolume
Sets the volume level of the specified internal MIDI synthesizer device.
Not all MIDI output devices support volume changes. Some devices can sup-port individual volume changes on both the left and the right channels. See “Determining Capabilities of Internal Synthesizers,” earlier in this chapter, for information on how to determine if a particular device supports volume changes.
Note:
Unless your application is designed to be a master volume-control application providing the user with volume control for all audio devices in a system, you should open an audio device before changing its volume. You should also query the volume level before changing it and restore the volume level to its previous level as soon as possible.
Volume is specified in a DWORD; the upper 16 bits specify the relative volume of the right channel, and the lower 16 bits specify the relative volume of the left channel, as shown in the following illustration.
For devices that don't support individual volume changes on both the left and right channels, the lower 16 bits specify the volume level, and the upper 16 bits are ignored. Values for the volume level range from 0x0 (silence) to 0xFFFF (maximum volume) and are interpreted logarithmically. The perceived volume increase is the same when increasing the volume level from 0x5000 to 0x6000 as it is from 0x4000 to 0x5000.
When querying using midiOutGetVolume, the volume is returned in a DWORD location specified by a far pointer parameter.