From 18f75a4bd0896b8b592364abdae98b160f0aa629 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 11 Apr 2012 11:24:48 +0200 Subject: [PATCH] Changed: #1459 Use effects group controller for ryzom client effects volume control --HG-- branch : sound_dev --- code/nel/include/nel/sound/group_controller.h | 2 ++ code/nel/include/nel/sound/u_group_controller.h | 2 ++ code/ryzom/client/src/sound_manager.cpp | 13 ++++++++++--- code/ryzom/client/src/sound_manager.h | 3 +++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/code/nel/include/nel/sound/group_controller.h b/code/nel/include/nel/sound/group_controller.h index d93fb8683..c3ac4838f 100644 --- a/code/nel/include/nel/sound/group_controller.h +++ b/code/nel/include/nel/sound/group_controller.h @@ -75,6 +75,8 @@ public: virtual void setUserGain(float gain) { NLMISC::clamp(gain, 0.0f, 1.0f); m_UserGain = gain; updateSourceGain(); } virtual float getUserGain() { return m_UserGain; } + + virtual void setGain(float devGain, float userGain) { NLMISC::clamp(devGain, 0.0f, 1.0f); NLMISC::clamp(userGain, 0.0f, 1.0f); m_DevGain = devGain; m_UserGain = userGain; updateSourceGain(); } //@} inline float getFinalGain() const { return m_FinalGain; } diff --git a/code/nel/include/nel/sound/u_group_controller.h b/code/nel/include/nel/sound/u_group_controller.h index 533f29936..54a28b835 100644 --- a/code/nel/include/nel/sound/u_group_controller.h +++ b/code/nel/include/nel/sound/u_group_controller.h @@ -56,6 +56,8 @@ public: virtual void setUserGain(float gain) = 0; virtual float getUserGain() = 0; + virtual void setGain(float devGain, float userGain) = 0; + protected: virtual ~UGroupController() { } diff --git a/code/ryzom/client/src/sound_manager.cpp b/code/ryzom/client/src/sound_manager.cpp index b15a5269b..a82e4b422 100644 --- a/code/ryzom/client/src/sound_manager.cpp +++ b/code/ryzom/client/src/sound_manager.cpp @@ -138,9 +138,11 @@ CSoundManager::~CSoundManager() // detach the sound from the particule system NL3D::UParticleSystemSound::setPSSound(NULL); + _GroupControllerEffects = NULL; + // free the audio mixer (and delete all sources) - if (_AudioMixer) - delete _AudioMixer; + delete _AudioMixer; + _AudioMixer = NULL; // release sound anim properly releaseSoundAnim(); @@ -404,6 +406,8 @@ void CSoundManager::reset () NL3D::UParticleSystemSound::setPSSound(NULL); + _GroupControllerEffects = NULL; + delete _AudioMixer; _AudioMixer = NULL; @@ -477,6 +481,9 @@ void CSoundManager::init(IProgressCallback *progressCallBack) */ new CSoundAnimManager(_AudioMixer); + // get the controller group for effects + _GroupControllerEffects = _AudioMixer->getGroupController("effects"); + // restore the volume SoundMngr->setSFXVolume(ClientCfg.SoundSFXVolume); SoundMngr->setGameMusicVolume(ClientCfg.SoundGameMusicVolume); @@ -1536,7 +1543,7 @@ void CSoundManager::updateVolume() _AudioMixer->setEventMusicVolume(_GameMusicVolume); // update sfx volume - _AudioMixer->getListener()->setGain(_SFXVolume*_FadeSFXVolume); + _GroupControllerEffects->setGain(_FadeSFXVolume, _SFXVolume); } } diff --git a/code/ryzom/client/src/sound_manager.h b/code/ryzom/client/src/sound_manager.h index 260ab6e81..e5db85648 100644 --- a/code/ryzom/client/src/sound_manager.h +++ b/code/ryzom/client/src/sound_manager.h @@ -332,6 +332,9 @@ private: /// Pointer on the audio mixer object NLSOUND::UAudioMixer *_AudioMixer; + /// The root effects group controller for volume settings + NLSOUND::UGroupController *_GroupControllerEffects; + /// Pointer on the root of the environmental sounds tree (if any) NLSOUND::UEnvSound *_EnvSoundRoot;