WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sound and Media

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get and set the WAVE volume

Keywords:  Get set WAVE volume .wav volume control sound level

Sample Code:

Here's a snippet I used for my automatic mp3 volume adjuster program.
It gets and sets the WAVE volume, not the overall volume, but might
give you a step in the right direction. 

(I turned it into a
quick example, 500 isn't a huge volume adjustment when it can go up to
32768.)


DaDll=strcat(DirWindows(1),"WINMM.DLL")
bin1 = BinaryAlloc(4)
Gosub GetVolume
Message(LeftVolumeAmount, RightVolumeAmount)
LeftVolumeAmount = LeftVolumeAmount + 500
RightVolumeAmount = RightVolumeAmount - 500
Message(LeftVolumeAmount, RightVolumeAmount)
Gosub SetVolume
EXIT

****************************GetVolume******************************************
:GetVolume
WaveErr = DllCall(DaDll, long:"waveOutGetVolume",long:0,
lpbinary:bin1)
if WaveErr != 0
Message("error in waveOutGetVolume:", WaveErr)
exit
endif
BinaryEODSet(bin1, 4)
LeftVolumeAmount = BinaryPeek2(bin1,0)
RightVolumeAmount = BinaryPeek2(bin1,2)
RETURN

****************************SetVolume******************************************
:SetVolume
TempLeftVolumeAmount = LeftVolumeAmount
TempRightVolumeAmount = RightVolumeAmount
;;Gosub AdjustBalance

BinaryPoke2(bin1, 0, TempLeftVolumeAmount)
BinaryPoke2(bin1, 2, TempRightVolumeAmount)
NewVolume = BinaryPeek4(bin1, 0)
WaveErr = DllCall(DaDll, long:"waveOutSetVolume",long:0,
long:NewVolume)
if WaveErr != 0
Message("error in waveOutSetVolume:", WaveErr)
exit
endif
RETURN

*******************************************************************************



Article ID:   W14733
Filename:   Gets and set the WAVE volume.txt
File Created: 2001:05:11:15:07:56
Last Updated: 2001:05:11:15:07:56