How to control sound's volume ??

Hi to all experts:

i'm using   waveOutOpen() ,  waveOutWrite() , waveOutClose() , ....
to play some wave sounds in my own game , and it works fine.
my problem is to control the volume for these sounds,
if i'm using  waveOutSetVolume function ,  it changes the wave master volume
and it also change the music volume at the background ( which is not good ).
so my question is how can i change a specific sound's volume without changing
the wave master volume and without effecting any thing else.

thanks alot
Who is Participating?
Jose ParrotConnect With a Mentor Graphics ExpertCommented:

waveOutxxxx() reffers to the output device, so the command is always a "master" command to any wave send to it. To circumvect the problem, you can try to check if the system has more than one wave output device capable of running your wave files (game sounds and background music). This can be cheched with    WAVE_FORMAT_QUERY   and    WAVE_MAPPED . Take a look at
for a MS help on that.

Another approach is to use different sound formats, say, MIDI for the music and WAVE for the sounds.
The noises and other game sounds remain using waveOutxxx() and the music uses
midiOutSetVolume() as described in

A third ioption is to use wave for both sounds, with pre-recoderd music and noises at selected volumes, say:
MUSIC#1:  music1volume1.wav,  music1volume2.wav, music1volume3.wav
MUSIC#2: m2v1.wav, m2v2.wv
NOISE#1: n1v1.wav, etc. etc.
where v1, is lower and v3 is higher.
And programaticaly you can chose the desired combinations

All Courses

From novice to tech pro — start learning today.