Add an option to force preloading. This only preloads sounds

that are loaded in advance, which excludes sample music
and some announcers.

Disable "sound volume".  That's not what that variable is for; setting
it to higher values will result in clipping on a lot of hardware, causing
people to report it as a "bug" (which it's not).  Setting it to lower values
results in lower quality sound.  To do this correctly, we'd need to add
an interface for accessing the real hardware mixer volume, which I
don't really want to do right now ...
This commit is contained in:
Glenn Maynard
2003-03-31 21:21:23 +00:00
parent ea5a77e47e
commit 0ae6236f7c
5 changed files with 30 additions and 8 deletions
+6 -1
View File
@@ -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 );
+1
View File
@@ -88,6 +88,7 @@ public:
CString m_sSoundDrivers;
float m_fSoundVolume;
bool m_bSoundPreloadAll;
bool m_bAllowSoftwareRenderer;
/* Game-specific prefs: */
+5
View File
@@ -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)
{
+3 -1
View File
@@ -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);
+15 -6
View File
@@ -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()