Jump to content

Global option Sound volume in the engine


ArBuZ
 Share

Recommended Posts

Hi!

I want to implement an option Sound and Music volume in my game. And Ive found that its not as simple as it should be :)

There is no any global parameter in the engine, only SetSourceVolume. But then I have to go through all my sources and set it's volume.

Have anyone done this before?

 

Thanks in advance.

Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64

3ds max / photoshop CS3 / C++

http://www.arbuznikov.com

Link to comment
Share on other sites

I would try something like the following. First make groups of sounds and sound sources.

--load sound
music1	= LoadSound("abstract::music1.OGG")
music2	= LoadSound("abstract::music2.OGG")
sound1  = LoadSound("abstract::sound1.OGG")
sound2	= LoadSound("abstract::sound2.OGG")

-- create sources
source_music1 =CreateSource (music1)
source_music2 =CreateSource (music2)
source_sound1 =CreateSource (sound1)
source_sound2 =CreateSource (sound2)

--declare 2 sound variables
MusicVolume = 5
SoundVolume = 5

-- 2 functions for setting the volume
function SetVolumeOfMusic ()
  source_music1:SetVolume( MusicVolume )
  source_music2:SetVolume( MusicVolume )
end

function SetVolumeOfSound ()
  source_Sound1:SetVolume( SoundVolume )
  source_Sound2:SetVolume( SoundVolume )
end

It would be even better if you could add a source to a Sound group. This way you wouldn't even have to place all sources in to the function.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...