waveOutSetVolume Function

Declare Function waveOutSetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, ByVal dwVolume As Long) As Long

Platforms: Win 95/98, Win NT

waveOutSetVolume sets the volume level for a waveform output device. Depending on the capabilities of the device, this function either sets the independent left and right channel volumes or the overall volume. Each volume setting must be in the range between &H0 (silence) and &HFFFF (maximum volume). The function returns 0 if successful, or a non-zero error code if and error occured.

uDeviceID
Either the device identifier or a handle to the waveform output device to set the volume of.
dwVolume
The new volume setting(s) for the device. If separate left/right volumes are supported, the low-order word is the left channel volume and the high-order word is the right channel volume. If not, the low-order word contains the overall volume and the high-order word is ignored.

Example:

' Set the volume on waveform output device #0 to 50% of maximum.  
' Note how we don't care if there are separate volumes or not -- we set both to the
' setting and, if only one channel volume exists, the extra data is ignored.
Dim retval As Long  ' return value

' First, verify that waveform output device #0 does exist.
retval = waveOutGetNumDevs()  ' get number of such devices
If retval >= 1 Then  ' at least one exists, so device #0 is there!
  ' Set the volume for all channels to &H7FFF (50%)
  retval = waveOutSetVolume(0, &H7FFF7FFF)  ' for both channels, if needed
End If

See Also: waveOutGetVolume
Category: Audio

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/w/waveoutsetvolume.html