move SoundVolume

This commit is contained in:
Glenn Maynard
2007-05-24 21:35:03 +00:00
parent 0b591bfb1f
commit dff267eccd
7 changed files with 24 additions and 31 deletions
-8
View File
@@ -240,7 +240,6 @@ PrefsManager::PrefsManager() :
m_sLastSeenVideoDriver ( "LastSeenVideoDriver", "" ),
m_sVideoRenderers ( "VideoRenderers", "" ), // StepMania.cpp sets these on first run:
m_bSmoothLines ( "SmoothLines", false ),
m_fSoundVolume ( "SoundVolume", 1.0f ),
m_iSoundWriteAhead ( "SoundWriteAhead", 0 ),
m_iSoundDevice ( "SoundDevice", "" ),
m_iSoundPreferredSampleRate ( "SoundPreferredSampleRate", 0 ),
@@ -482,13 +481,6 @@ RString PrefsManager::GetPreferencesSection() const
}
// wrappers
float PrefsManager::GetSoundVolume()
{
// return a resonable volume to that users of this method don't have to handle invalid values
return clamp(m_fSoundVolume.Get(),0.0f,1.0f);
}
// lua start
#include "LuaBinding.h"
-5
View File
@@ -216,7 +216,6 @@ public:
Preference<RString> m_sLastSeenVideoDriver;
Preference<RString> m_sVideoRenderers; // StepMania.cpp sets these on first run based on the card
Preference<bool> m_bSmoothLines;
Preference<float> m_fSoundVolume;
Preference<int> m_iSoundWriteAhead;
Preference<RString> m_iSoundDevice;
Preference<int> m_iSoundPreferredSampleRate;
@@ -244,10 +243,6 @@ public:
#endif
// wrappers
float GetSoundVolume();
void ReadPrefsFromIni( const IniFile &ini, const RString &sSection, bool bIsStatic );
void ReadGamePrefsFromIni( const RString &sIni );
void ReadDefaultsFromIni( const IniFile &ini, const RString &sSection );
+4 -4
View File
@@ -178,12 +178,12 @@ void RageSoundManager::AddLoadedSound( const RString &sPath_, RageSoundReader_Pr
m_mapPreloadedSounds[sPath] = pSound->Copy();
}
void RageSoundManager::SetMixVolume( float fMixVol )
{
ASSERT_M( fMixVol >= 0 && fMixVol <= 1, ssprintf("%f",fMixVol) );
static Preference<float> g_fSoundVolume( "SoundVolume", 1.0f );
void RageSoundManager::SetMixVolume()
{
g_SoundManMutex.Lock(); /* lock for access to m_fMixVolume */
m_fMixVolume = fMixVol;
m_fMixVolume = clamp( g_fSoundVolume.Get(), 0.0f, 1.0f );
g_SoundManMutex.Unlock(); /* finished with m_fMixVolume */
}
+1 -1
View File
@@ -30,7 +30,7 @@ public:
void Init();
float GetMixVolume() const { return m_fMixVolume; }
void SetMixVolume( float fMixVol );
void SetMixVolume();
float GetVolumeOfNonCriticalSounds() const { return m_fVolumeOfNonCriticalSounds; }
void SetVolumeOfNonCriticalSounds( float fVolumeOfNonCriticalSounds );
+16 -10
View File
@@ -457,11 +457,13 @@ static void SetSpeed()
void ChangeVolume( float fDelta )
{
float fVol = PREFSMAN->m_fSoundVolume;
Preference<float> *pRet = Preference<float>::GetPreferenceByName("SoundVolume");
float fVol = pRet->Get();
fVol += fDelta;
CLAMP( fVol, 0.0f, 1.0f );
PREFSMAN->m_fSoundVolume.Set( fVol );
SOUNDMAN->SetMixVolume( PREFSMAN->GetSoundVolume() );
pRet->Set( fVol );
SOUNDMAN->SetMixVolume();
}
@@ -725,11 +727,7 @@ class DebugLineShowMasks : public IDebugLine
Preference<bool> *GetPref()
{
IPreference *pPref = IPreference::GetPreferenceByName("ShowMasks");
ASSERT( pPref );
Preference<bool> *pRet = dynamic_cast<Preference<bool> *>(pPref);
ASSERT( pRet );
return pRet;
return Preference<bool>::GetPreferenceByName("ShowMasks");
}
};
@@ -1039,13 +1037,17 @@ class DebugLinePullBackCamera : public IDebugLine
class DebugLineVolumeUp : public IDebugLine
{
virtual RString GetDisplayTitle() { return VOLUME_UP.GetValue(); }
virtual RString GetDisplayValue() { return ssprintf("%.0f%%",PREFSMAN->m_fSoundVolume.Get()*100); }
virtual RString GetDisplayValue() { return ssprintf("%.0f%%", GetPref()->Get()*100); }
virtual bool IsEnabled() { return true; }
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
{
ChangeVolume( +0.1f );
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
}
Preference<float> *GetPref()
{
return Preference<float>::GetPreferenceByName("SoundVolume");
}
};
class DebugLineVolumeDown : public IDebugLine
@@ -1057,7 +1059,11 @@ class DebugLineVolumeDown : public IDebugLine
{
ChangeVolume( -0.1f );
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
sMessageOut += " - " + ssprintf("%.0f%%",PREFSMAN->m_fSoundVolume.Get()*100);
sMessageOut += " - " + ssprintf("%.0f%%",GetPref()->Get()*100);
}
Preference<float> *GetPref()
{
return Preference<float>::GetPreferenceByName("SoundVolume");
}
};
+1 -1
View File
@@ -146,7 +146,7 @@ void ScreenOptionsMaster::HandleScreenMessage( const ScreenMessage SM )
if( m_iChangeMask & OPT_APPLY_SOUND )
{
SOUNDMAN->SetMixVolume( PREFSMAN->GetSoundVolume() );
SOUNDMAN->SetMixVolume();
}
if( m_iChangeMask & OPT_APPLY_SONG )
+2 -2
View File
@@ -229,7 +229,7 @@ static bool CheckVideoDefaultSettings();
void StepMania::ResetPreferences()
{
PREFSMAN->ResetToFactoryDefaults();
SOUNDMAN->SetMixVolume( PREFSMAN->GetSoundVolume() );
SOUNDMAN->SetMixVolume();
CheckVideoDefaultSettings();
ApplyGraphicOptions();
}
@@ -1015,7 +1015,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();
SOUNDMAN->SetMixVolume( PREFSMAN->GetSoundVolume() );
SOUNDMAN->SetMixVolume();
SOUND = new GameSoundManager;
BOOKKEEPER = new Bookkeeper;
LIGHTSMAN = new LightsManager;