diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index dd04813367..fb323f2c2b 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -107,7 +107,10 @@ PrefsManager::PrefsManager() m_sSoundDrivers = DEFAULT_SOUND_DRIVER_LIST; m_fSoundVolume = DEFAULT_SOUND_VOLUME; - + /* This is experimental: let's see if preloading helps people's skipping. + * If it doesn't do anything useful, it'll be removed. */ + m_bSoundPreloadAll = false; + m_bAllowSoftwareRenderer = false; m_sDefaultNoteSkin = "default"; @@ -171,6 +174,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame ) ini.GetValueB( "Options", "EasterEggs", m_bEasterEggs ); ini.GetValueB( "Options", "MarvelousTiming", m_bMarvelousTiming ); ini.GetValueF( "Options", "SoundVolume", m_fSoundVolume ); + ini.GetValueB( "Options", "SoundPreloadAll", m_bSoundPreloadAll ); ini.GetValueI( "Options", "CoinMode", (int&)m_CoinMode ); ini.GetValueI( "Options", "CoinsPerCredit", m_iCoinsPerCredit ); ini.GetValueB( "Options", "JointPremium", m_bJointPremium ); @@ -250,6 +254,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() ini.SetValueB( "Options", "ChangeBannersWhenFast", m_bChangeBannersWhenFast ); ini.SetValueB( "Options", "EasterEggs", m_bEasterEggs ); ini.SetValueB( "Options", "MarvelousTiming", m_bMarvelousTiming ); + ini.SetValueB( "Options", "SoundPreloadAll", m_bSoundPreloadAll ); ini.SetValueI( "Options", "CoinMode", (int&)m_CoinMode ); ini.SetValueI( "Options", "CoinsPerCredit", m_iCoinsPerCredit ); ini.SetValueB( "Options", "JointPremium", m_bJointPremium ); diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index 7a8e3f8ba0..674ac65853 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -88,6 +88,7 @@ public: CString m_sSoundDrivers; float m_fSoundVolume; + bool m_bSoundPreloadAll; bool m_bAllowSoftwareRenderer; /* Game-specific prefs: */ diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index 4e55918e0b..278f7e56f7 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -39,6 +39,8 @@ #include "RageException.h" #include "RageTimer.h" +#include "PrefsManager.h" + #include "RageSoundReader_SDL_Sound.h" #include "RageSoundReader_Preload.h" @@ -171,6 +173,9 @@ bool RageSound::Load(CString sSoundFilePath, int precache) RageException::Throw( "RageSoundManager::RageSoundManager: error opening sound %s: %s", sSoundFilePath.GetString(), NewSample->GetError().c_str()); + if(PREFSMAN->m_bSoundPreloadAll) + precache = true; + /* Try to precache. */ if(precache) { diff --git a/stepmania/src/RageSoundReader_Preload.cpp b/stepmania/src/RageSoundReader_Preload.cpp index be31f3a25a..08ccebe6de 100644 --- a/stepmania/src/RageSoundReader_Preload.cpp +++ b/stepmania/src/RageSoundReader_Preload.cpp @@ -1,5 +1,6 @@ #include "global.h" #include "RageSoundReader_Preload.h" +#include "PrefsManager.h" const int channels = 2; const int samplesize = 2 * channels; /* 16-bit */ @@ -22,7 +23,8 @@ bool SoundReader_Preload::Open(SoundReader *source) float secs = len / 1000.f; int pcmsize = int(secs * samplerate * samplesize); /* seconds -> bytes */ - if(pcmsize > max_prebuf_size) + if(!PREFSMAN->m_bSoundPreloadAll && + pcmsize > max_prebuf_size) return false; /* Don't bother trying to preload it. */ buf.get_owned().reserve(pcmsize); diff --git a/stepmania/src/ScreenSoundOptions.cpp b/stepmania/src/ScreenSoundOptions.cpp index 5048b4d47b..488bf870b4 100644 --- a/stepmania/src/ScreenSoundOptions.cpp +++ b/stepmania/src/ScreenSoundOptions.cpp @@ -25,11 +25,18 @@ enum { - SO_MASTER_VOLUME, +// SO_MASTER_VOLUME, + SO_PRELOAD_SOUND, NUM_SOUND_OPTIONS_LINES }; OptionRow g_SoundOptionsLines[NUM_SOUND_OPTIONS_LINES] = { - OptionRow( "Master\nVolume", "MUTE","20%","40%","60%","80%","100%" ), + /* Err. This shouldn't be here. m_fSoundVolume is not the master volume, + * it's the internal attenuation before mixing; we don't have control over + * the master volume. m_fSoundVolume was never intended to be changed by + * users, except to troubleshoot clipping; that's why I didn't put it in + * the options to begin with. */ +// OptionRow( "Master\nVolume", "MUTE","20%","40%","60%","80%","100%" ), + OptionRow( "Preload\nSounds", "NO","YES" ), }; ScreenSoundOptions::ScreenSoundOptions() : @@ -52,14 +59,16 @@ void ScreenSoundOptions::Input( const DeviceInput& DeviceI, const InputEventType void ScreenSoundOptions::ImportOptions() { float fVolPercent = PREFSMAN->m_fSoundVolume; - m_iSelectedOption[0][SO_MASTER_VOLUME] = (int)(fVolPercent*5); +// m_iSelectedOption[0][SO_MASTER_VOLUME] = (int)(PREFSMAN->m_fSoundVolume*5); + m_iSelectedOption[0][SO_PRELOAD_SOUND] = PREFSMAN->m_bSoundPreloadAll; } void ScreenSoundOptions::ExportOptions() { - float fVolPercent = m_iSelectedOption[0][SO_MASTER_VOLUME] / 5.f; - SOUNDMAN->SetPrefs(fVolPercent); - PREFSMAN->m_fSoundVolume = fVolPercent; +// float fVolPercent = m_iSelectedOption[0][SO_MASTER_VOLUME] / 5.f; +// SOUNDMAN->SetPrefs(fVolPercent); +// PREFSMAN->m_fSoundVolume = fVolPercent; + PREFSMAN->m_bSoundPreloadAll = !!m_iSelectedOption[0][SO_PRELOAD_SOUND]; } void ScreenSoundOptions::GoToPrevState()