Change 3D Sound Volume in Real Time

(Chris Allar) #1

Hello, sorry if this has been answered but I cannot find it.

(Sorry, I cannot seem to add tags to this thread, but it is a Windows and C++ question)

I want to know how I can change the volume of a 3D positional sound while it is already playing.

I know that I can change the volume of any NEW 3D sound with channel->setVolume(), however I do not know how to access an existing 3D sound created with that same channel, and change its master volume.

For example, I want to be able to have users change the sound volume in my program’s options window, and have the 3D sound’s volume change immediately.

All other non-3D sounds work by calling the channel->setVolume() function, however the 3D sounds do not.

How to I access these sounds and change their volumes?

Here is the general code I use to set up and play the sounds:

//Sound setup
result = system->playSound(FMOD_CHANNEL_FREE, envSoundList[soundID], true, &channelList[soundID]);
result = channelList[soundID]->set3DAttributes(&pos, &vel);
result = channelList[soundID]->setPaused(false);
result = channelList[soundID]->setVolume( VGlobal::soundVolume );

//Called every frame
result = system->set3DListenerAttributes(0, &listenerpos, &vel, &forward, &up);


(リチャード清水) #2

Hi Chris,

It would be good to put all the 3D sounds’ channels you wish to adjust into a ChannelGroup and you can allow users to adjust the volume there.


(Chris Allar) #3

Thank you, channel groups seems to be the answer I needed. It seems to be working, thanks!