Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Music & Sound FX / playing multiple wave files simultaneously with different volumes

Author
Message
changoo
User Banned
Posted: 11th Nov 2010 10:04
Hi,

i'd like to play 2 audio files at the same time, but want them to have different volumes. i found a way to play them with wavOutOpen, Prepare Header...

but if i try to adjust the volume, the master wave-volume of both files are changed. that means both audio files have the same volume.

is there a way to set volume for those waves individually?

thx for any help

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 11th Nov 2010 20:46 Edited at: 11th Nov 2010 20:47
What language are you using?
With DarkBASIC the following would work:


With pure API calls / the standard windows header files (C / C++) I'm not sure, but I'd throw a guess that what you want to do is create two audio buffers and then set their individual volumes (of the buffers that is), if there is support for that. That's basically how it works with the DirectX audio library.

A simple, although not very practical approach is to just step through all the wave data manually and multiply it by a set factor (if you attempt to increase the volume rather than decrease it in this way you'll want to watch out so that you don't overflow the maximum sample amplitude).
Some pseudo code in C-style language:


Hope that can be of some help
Note that the last approach will change the volume of the wave data definitively, while the previous approaches most likely uses the same method only when transmitting the audio data to the sound card for playback (and thus won't affect the source audio data).

Login to post a reply

Server time is: 2024-03-28 14:09:53
Your offset time is: 2024-03-28 14:09:53