Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

Your way would work for simple solutions. But in complex solutions with classes (C++) when for example Source is a member of class, things become more complicated and handling all sources of all objects in scene is very tricky.

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

3ds max / photoshop CS3 / C++

http://www.arbuznikov.com

Posted

Hey arbuz,

you could write the lights into an array and then loop throught all of them.

You can also use EmitSound if you want, because there you can set the volume directly =)

 

Hope it'll help you

Dustin

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.

×
×
  • Create New...