@ -252,6 +252,19 @@ void OptionSharewareChanged()
gbIsSpawn = * sgOptions . StartUp . shareware ;
}
void OptionAudioChanged ( )
{
effects_cleanup_sfx ( ) ;
music_stop ( ) ;
snd_deinit ( ) ;
snd_init ( ) ;
music_start ( TMUSIC_INTRO ) ;
if ( gbRunGame )
sound_init ( ) ;
else
ui_sound_init ( ) ;
}
} // namespace
void SetIniValue ( const char * sectionName , const char * keyName , const char * value , int len )
@ -294,11 +307,6 @@ void LoadOptions()
sgOptions . Audio . nSoundVolume = GetIniInt ( " Audio " , " Sound Volume " , VOLUME_MAX ) ;
sgOptions . Audio . nMusicVolume = GetIniInt ( " Audio " , " Music Volume " , VOLUME_MAX ) ;
sgOptions . Audio . nSampleRate = GetIniInt ( " Audio " , " Sample Rate " , DEFAULT_AUDIO_SAMPLE_RATE ) ;
sgOptions . Audio . nChannels = GetIniInt ( " Audio " , " Channels " , DEFAULT_AUDIO_CHANNELS ) ;
sgOptions . Audio . nBufferSize = GetIniInt ( " Audio " , " Buffer Size " , DEFAULT_AUDIO_BUFFER_SIZE ) ;
sgOptions . Audio . nResamplingQuality = GetIniInt ( " Audio " , " Resampling Quality " , DEFAULT_AUDIO_RESAMPLING_QUALITY ) ;
sgOptions . Graphics . nGammaCorrection = GetIniInt ( " Graphics " , " Gamma Correction " , 100 ) ;
# if SDL_VERSION_ATLEAST(2, 0, 0)
sgOptions . Graphics . bHardwareCursor = GetIniBool ( " Graphics " , " Hardware Cursor " , HardwareCursorDefault ( ) ) ;
@ -348,10 +356,6 @@ void SaveOptions()
SetIniValue ( " Audio " , " Sound Volume " , sgOptions . Audio . nSoundVolume ) ;
SetIniValue ( " Audio " , " Music Volume " , sgOptions . Audio . nMusicVolume ) ;
SetIniValue ( " Audio " , " Sample Rate " , sgOptions . Audio . nSampleRate ) ;
SetIniValue ( " Audio " , " Channels " , sgOptions . Audio . nChannels ) ;
SetIniValue ( " Audio " , " Buffer Size " , sgOptions . Audio . nBufferSize ) ;
SetIniValue ( " Audio " , " Resampling Quality " , sgOptions . Audio . nResamplingQuality ) ;
SetIniValue ( " Graphics " , " Gamma Correction " , sgOptions . Graphics . nGammaCorrection ) ;
# if SDL_VERSION_ATLEAST(2, 0, 0)
SetIniValue ( " Graphics " , " Hardware Cursor " , sgOptions . Graphics . bHardwareCursor ) ;
@ -605,7 +609,15 @@ AudioOptions::AudioOptions()
, walkingSound ( " Walking Sound " , OptionEntryFlags : : None , N_ ( " Walking Sound " ) , N_ ( " Player emits sound when walking. " ) , true )
, autoEquipSound ( " Auto Equip Sound " , OptionEntryFlags : : None , N_ ( " Auto Equip Sound " ) , N_ ( " Automatically equipping items on pickup emits the equipment sound. " ) , false )
, itemPickupSound ( " Item Pickup Sound " , OptionEntryFlags : : None , N_ ( " Item Pickup Sound " ) , N_ ( " Picking up items emits the items pickup sound. " ) , false )
, sampleRate ( " Sample Rate " , OptionEntryFlags : : CantChangeInGame , N_ ( " Sample Rate " ) , N_ ( " Output sample rate (Hz). " ) , DEFAULT_AUDIO_SAMPLE_RATE , { 22050 , 44100 , 48000 } )
, channels ( " Channels " , OptionEntryFlags : : CantChangeInGame , N_ ( " Channels " ) , N_ ( " Number of output channels. " ) , DEFAULT_AUDIO_CHANNELS , { 1 , 2 } )
, bufferSize ( " Buffer Size " , OptionEntryFlags : : CantChangeInGame , N_ ( " Buffer Size " ) , N_ ( " Buffer size (number of frames per channel). " ) , DEFAULT_AUDIO_BUFFER_SIZE , { 1024 , 2048 , 5120 } )
, resamplingQuality ( " Resampling Quality " , OptionEntryFlags : : CantChangeInGame , N_ ( " Resampling Quality " ) , N_ ( " Quality of the resampler, from 0 (lowest) to 10 (highest). " ) , DEFAULT_AUDIO_RESAMPLING_QUALITY , { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } )
{
sampleRate . SetValueChangedCallback ( OptionAudioChanged ) ;
channels . SetValueChangedCallback ( OptionAudioChanged ) ;
bufferSize . SetValueChangedCallback ( OptionAudioChanged ) ;
resamplingQuality . SetValueChangedCallback ( OptionAudioChanged ) ;
}
std : : vector < OptionEntryBase * > AudioOptions : : GetEntries ( )
{
@ -613,6 +625,10 @@ std::vector<OptionEntryBase *> AudioOptions::GetEntries()
& walkingSound ,
& autoEquipSound ,
& itemPickupSound ,
& sampleRate ,
& channels ,
& bufferSize ,
& resamplingQuality ,
} ;
}