Changing Auxiliary Audio-Device Volume

The Multimedia extensions provide the following functions to query and set the volume for auxiliary audio devices:

auxGetVolume

Gets the volume level of the specified auxiliary audio device.

auxSetVolume

Sets the volume level of the specified auxiliary audio device.

Not all auxiliary audio devices support volume changes. Some devices can support individual volume changes on both the left and the right channels. See “Determining Capabilities of Auxiliary Audio Devices,” 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.

The volume level is specified as in the waveform and MIDI volume-control functions: in a DWORD with the upper 16 bits specifying the relative volume of the right channel and the lower 16 bits specifying the relative volume of the left channel. For devices that don't support individual volume control 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. This means 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 with auxGetVolume, the volume is returned in a DWORD location specified by a far pointer parameter.