diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index e0ec4f2ade..9de9beed7e 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -350,8 +350,6 @@ void RageSound::StartPlaying() m_bPlaying = true; - if( !m_Param.m_bIsCriticalSound && SOUNDMAN->GetPlayOnlyCriticalSounds() ) - m_Param.m_Volume = 0; ApplyParams(); /* Don't lock while calling SOUNDMAN driver calls. */ @@ -586,6 +584,8 @@ void RageSound::ApplyParams() m_pSource->SetProperty( "FadeSeconds", m_Param.m_fFadeOutSeconds ); float fVolume = m_Param.m_Volume * SOUNDMAN->GetMixVolume(); + if( !m_Param.m_bIsCriticalSound ) + fVolume *= SOUNDMAN->GetVolumeOfNonCriticalSounds(); m_pSource->SetProperty( "Volume", fVolume ); switch( GetStopMode() ) diff --git a/stepmania/src/RageSoundManager.cpp b/stepmania/src/RageSoundManager.cpp index 832b4233fc..04727ece97 100644 --- a/stepmania/src/RageSoundManager.cpp +++ b/stepmania/src/RageSoundManager.cpp @@ -40,7 +40,7 @@ RageSoundManager *SOUNDMAN = NULL; RageSoundManager::RageSoundManager() { m_fMixVolume = 1.0f; - m_bPlayOnlyCriticalSounds = false; + m_fVolumeOfNonCriticalSounds = 1.0f; } static LocalizedString COULDNT_FIND_SOUND_DRIVER( "RageSoundManager", "Couldn't find a sound driver that works" ); @@ -187,11 +187,11 @@ void RageSoundManager::SetMixVolume( float fMixVol ) g_SoundManMutex.Unlock(); /* finished with m_fMixVolume */ } -void RageSoundManager::SetPlayOnlyCriticalSounds( bool bPlayOnlyCriticalSounds ) +void RageSoundManager::SetVolumeOfNonCriticalSounds( float fVolumeOfNonCriticalSounds ) { - g_SoundManMutex.Lock(); /* lock for access to m_bPlayOnlyCriticalSounds */ - m_bPlayOnlyCriticalSounds = bPlayOnlyCriticalSounds; - g_SoundManMutex.Unlock(); /* finished with m_bPlayOnlyCriticalSounds */ + g_SoundManMutex.Lock(); /* lock for access to m_fVolumeOfNonCriticalSounds */ + m_fVolumeOfNonCriticalSounds = fVolumeOfNonCriticalSounds; + g_SoundManMutex.Unlock(); /* finished with m_fVolumeOfNonCriticalSounds */ } /* diff --git a/stepmania/src/RageSoundManager.h b/stepmania/src/RageSoundManager.h index e4a12c6436..31e1303191 100644 --- a/stepmania/src/RageSoundManager.h +++ b/stepmania/src/RageSoundManager.h @@ -31,8 +31,8 @@ public: float GetMixVolume() const { return m_fMixVolume; } void SetMixVolume( float fMixVol ); - bool GetPlayOnlyCriticalSounds() const { return m_bPlayOnlyCriticalSounds; } - void SetPlayOnlyCriticalSounds( bool bPlayOnlyCriticalSounds ); + float GetVolumeOfNonCriticalSounds() const { return m_fVolumeOfNonCriticalSounds; } + void SetVolumeOfNonCriticalSounds( float fVolumeOfNonCriticalSounds ); void Update(); void StartMixing( RageSoundBase *snd ); /* used by RageSound */ @@ -52,7 +52,7 @@ private: /* Prefs: */ float m_fMixVolume; - bool m_bPlayOnlyCriticalSounds; + float m_fVolumeOfNonCriticalSounds; }; extern RageSoundManager *SOUNDMAN; diff --git a/stepmania/src/ScreenAttract.cpp b/stepmania/src/ScreenAttract.cpp index 2a567af349..e29280603f 100644 --- a/stepmania/src/ScreenAttract.cpp +++ b/stepmania/src/ScreenAttract.cpp @@ -26,7 +26,10 @@ ScreenAttract::ScreenAttract( bool bResetGameState ) void ScreenAttract::Init() { - SOUNDMAN->SetPlayOnlyCriticalSounds( !GAMESTATE->IsTimeToPlayAttractSounds() ); // mute attract sounds + if( GAMESTATE->IsTimeToPlayAttractSounds() ) + SOUNDMAN->SetVolumeOfNonCriticalSounds( 1.0f ); // unmute attract sounds + else + SOUNDMAN->SetVolumeOfNonCriticalSounds( 0.0f ); // mute attract sounds GAMESTATE->VisitAttractScreen( m_sName ); @@ -71,7 +74,7 @@ void ScreenAttract::AttractInput( const InputEventPlus &input, ScreenWithMenuEle if( input.MenuI != MENU_BUTTON_COIN ) SCREENMAN->PlayCoinSound(); - SOUNDMAN->SetPlayOnlyCriticalSounds( false ); // unmute attract sounds + SOUNDMAN->SetVolumeOfNonCriticalSounds( 1.0f ); // unmute attract sounds pScreen->Cancel( SM_GoToStartScreen ); break; default: diff --git a/stepmania/src/ScreenDemonstration.cpp b/stepmania/src/ScreenDemonstration.cpp index 74b4920d3f..507dcc1a0c 100644 --- a/stepmania/src/ScreenDemonstration.cpp +++ b/stepmania/src/ScreenDemonstration.cpp @@ -19,7 +19,10 @@ REGISTER_SCREEN_CLASS( ScreenDemonstration ); ScreenDemonstration::ScreenDemonstration() { m_bDemonstration = true; - SOUNDMAN->SetPlayOnlyCriticalSounds( !GAMESTATE->IsTimeToPlayAttractSounds() ); // mute attract sounds + if( GAMESTATE->IsTimeToPlayAttractSounds() ) + SOUNDMAN->SetVolumeOfNonCriticalSounds( 1.0f ); // unmute attract sounds + else + SOUNDMAN->SetVolumeOfNonCriticalSounds( 0.0f ); // mute attract sounds } void ScreenDemonstration::Init()