When in attract and not playing attract sounds, have SOUNDMAN only play sounds with RageSoundParams.m_bCriticalSound == true.

Currently, only the coin sound has RageSoundParams.m_bCriticalSound = true.
This commit is contained in:
Chris Danford
2005-10-04 06:51:06 +00:00
parent 7cb3a12722
commit 15880eafd6
13 changed files with 30 additions and 15 deletions
+1 -1
View File
@@ -1647,7 +1647,7 @@ bool GameState::OneIsHot() const
return false;
}
bool GameState::IsTimeToPlaySounds() const
bool GameState::IsTimeToPlayAttractSounds() const
{
if( !GAMESTATE->m_bDemonstrationOrJukebox )
return true;
+1 -1
View File
@@ -267,7 +267,7 @@ public:
// Attract stuff
//
int m_iNumTimesThroughAttract; // negative means play regardless of m_iAttractSoundFrequency setting
bool IsTimeToPlaySounds() const;
bool IsTimeToPlayAttractSounds() const;
void VisitAttractScreen( const CString sScreenName );
//
+4 -5
View File
@@ -29,7 +29,6 @@
#include "PrefsManager.h"
#include "arch/ArchHooks/ArchHooks.h"
#include "RageSoundUtil.h"
#include "GameState.h"
#include "RageSoundReader_Preload.h"
#include "RageSoundReader_Resample.h"
@@ -52,14 +51,12 @@ RageSoundParams::RageSoundParams():
m_LengthSeconds = -1;
m_FadeLength = 0;
m_Volume = 1.0f;
if( !GAMESTATE->IsTimeToPlaySounds() )
m_Volume = 0;
m_Balance = 0; // center
speed_input_samples = speed_output_samples = 1;
m_bAccurateSync = false;
StopMode = M_AUTO;
m_bIsCriticalSound = false;
}
RageSound::RageSound():
@@ -890,6 +887,8 @@ float RageSound::GetAbsoluteVolume() const
{
float f = m_Param.m_Volume;
f *= SOUNDMAN->GetMixVolume();
if( SOUNDMAN->GetPlayOnlyCriticalSounds() && !m_Param.m_bIsCriticalSound )
f *= 0;
return f;
}
+2
View File
@@ -72,6 +72,8 @@ struct RageSoundParams
M_CONTINUE,
M_AUTO
} StopMode;
bool m_bIsCriticalSound; // "is a sound that should be played even during attract"
};
class RageSound: public RageSoundBase
+9 -1
View File
@@ -32,6 +32,7 @@ RageSoundManager::RageSoundManager()
{
pos_map_queue.reserve( 1024 );
m_fMixVolume = 1.0f;
m_bPlayOnlyCriticalSounds = false;
}
void RageSoundManager::Init( CString sDrivers )
@@ -328,13 +329,20 @@ void RageSoundManager::PlayOnce( CString sPath )
DeleteSoundWhenFinished( pSound );
}
void RageSoundManager::SetPrefs( float fMixVol )
void RageSoundManager::SetMixVolume( float fMixVol )
{
g_SoundManMutex.Lock(); /* lock for access to m_fMixVolume */
m_fMixVolume = fMixVol;
g_SoundManMutex.Unlock(); /* finished with m_fMixVolume */
}
void RageSoundManager::SetPlayOnlyCriticalSounds( bool bPlayOnlyCriticalSounds )
{
g_SoundManMutex.Lock(); /* lock for access to m_bPlayOnlyCriticalSounds */
m_bPlayOnlyCriticalSounds = bPlayOnlyCriticalSounds;
g_SoundManMutex.Unlock(); /* finished with m_bPlayOnlyCriticalSounds */
}
/* Standalone helpers: */
void RageSoundManager::AttenuateBuf( int16_t *pBuf, int iSamples, float fVolume )
{
+5 -1
View File
@@ -29,7 +29,9 @@ public:
void Init( CString sDrivers );
float GetMixVolume() const { return m_fMixVolume; }
void SetPrefs( float fMixVol );
void SetMixVolume( float fMixVol );
bool GetPlayOnlyCriticalSounds() const { return m_bPlayOnlyCriticalSounds; }
void SetPlayOnlyCriticalSounds( bool bPlayOnlyCriticalSounds );
void Update( float fDeltaTime );
void StartMixing( RageSoundBase *snd ); /* used by RageSound */
@@ -72,6 +74,8 @@ private:
/* Prefs: */
float m_fMixVolume;
bool m_bPlayOnlyCriticalSounds;
struct queued_pos_map_t
{
int ID, pos, got_frames;
+3
View File
@@ -14,6 +14,7 @@
#include "GameSoundManager.h"
#include "CommonMetrics.h"
#include "InputEventPlus.h"
#include "RageSoundManager.h"
#define START_SCREEN(sScreenName) THEME->GetMetric (sScreenName,"StartScreen")
@@ -26,6 +27,7 @@ ScreenAttract::ScreenAttract( CString sName, bool bResetGameState ) : ScreenWith
GAMESTATE->Reset();
GAMESTATE->VisitAttractScreen( sName );
SOUNDMAN->SetPlayOnlyCriticalSounds( GAMESTATE->IsTimeToPlayAttractSounds() ); // mute attract sounds
}
@@ -70,6 +72,7 @@ void ScreenAttract::AttractInput( const InputEventPlus &input, ScreenWithMenuEle
SCREENMAN->PlayCoinSound();
pScreen->Cancel( SM_GoToStartScreen );
SOUNDMAN->SetPlayOnlyCriticalSounds( false ); // unmute attract sounds
break;
default:
ASSERT(0);
+1 -1
View File
@@ -333,7 +333,7 @@ void ChangeVolume( float fDelta )
fVol += fDelta;
CLAMP( fVol, 0.0f, 1.0f );
PREFSMAN->m_fSoundVolume.Set( fVol );
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume );
SOUNDMAN->SetMixVolume( PREFSMAN->m_fSoundVolume );
}
-2
View File
@@ -86,13 +86,11 @@ void ScreenDemonstration::HandleScreenMessage( const ScreenMessage SM )
}
else if( SM == SM_LoseFocus )
{
SOUNDMAN->SetPrefs( PREFSMAN->GetSoundVolume() ); // turn volume back on
}
else if( SM == SM_GoToNextScreen )
{
if( m_pSoundMusic )
m_pSoundMusic->Stop();
SOUNDMAN->SetPrefs( PREFSMAN->GetSoundVolume() ); // turn volume back on
}
ScreenJukebox::HandleScreenMessage( SM );
+1 -1
View File
@@ -1374,7 +1374,7 @@ float ScreenGameplay::StartPlayingSong(float MinTimeToNotes, float MinTimeToMusi
p.m_StartSecond = fStartSecond;
// Silence music if not playing attract sounds in demonstration.
if( !GAMESTATE->IsTimeToPlaySounds() )
if( !GAMESTATE->IsTimeToPlayAttractSounds() )
p.m_Volume = 0;
ASSERT( !m_pSoundMusic->IsPlaying() );
+1
View File
@@ -812,6 +812,7 @@ void ScreenManager::PlayCoinSound()
{
RageSoundParams p;
p.m_Volume = PREFSMAN->m_fSoundVolume;
p.m_bIsCriticalSound = true;
m_soundCoin.Play( &p );
}
+1 -1
View File
@@ -215,7 +215,7 @@ void ScreenOptionsMaster::HandleScreenMessage( const ScreenMessage SM )
if( m_iChangeMask & OPT_APPLY_SOUND )
{
SOUNDMAN->SetPrefs( PREFSMAN->GetSoundVolume() );
SOUNDMAN->SetMixVolume( PREFSMAN->GetSoundVolume() );
}
if( m_iChangeMask & OPT_APPLY_SONG )
+1 -1
View File
@@ -1098,7 +1098,7 @@ int main(int argc, char* argv[])
LOG->Info( "Sound writeahead has been overridden to %i", PREFSMAN->m_iSoundWriteAhead.Get() );
SOUNDMAN = new RageSoundManager;
SOUNDMAN->Init( PREFSMAN->GetSoundDrivers() );
SOUNDMAN->SetPrefs( PREFSMAN->GetSoundVolume() );
SOUNDMAN->SetMixVolume( PREFSMAN->GetSoundVolume() );
SOUND = new GameSoundManager;
BOOKKEEPER = new Bookkeeper;
LIGHTSMAN = new LightsManager( PREFSMAN->GetLightsDriver() );