diff --git a/source/audio.cpp b/source/audio.cpp index 248bc93..3d434cc 100644 --- a/source/audio.cpp +++ b/source/audio.cpp @@ -85,6 +85,7 @@ GCMixSamples () static void FinalizeSamplesCallback (void *data) { LWP_MutexLock(audiomutex); + UpdatePlaybackRateWithDynamicRate(); S9xFinalizeSamples(); LWP_MutexUnlock(audiomutex); } diff --git a/source/menu.cpp b/source/menu.cpp index f4b280a..211db0e 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -3100,7 +3100,6 @@ static int MenuSettingsVideo() int ret; int i = 0; bool firstRun = true; - bool reset_sfx = false; OptionList options; sprintf(options.name[i++], "Rendering"); @@ -3205,17 +3204,18 @@ static int MenuSettingsVideo() break; case 8: GCSettings.sfxOverclock++; - if (GCSettings.sfxOverclock > 2) + if (GCSettings.sfxOverclock > 2) { GCSettings.sfxOverclock = 0; + } switch(GCSettings.sfxOverclock) { - case 0: Settings.SuperFXSpeedPerLine = 0.417 * 10.5e6; reset_sfx = true; break; - case 1: Settings.SuperFXSpeedPerLine = 0.417 * 40.5e6; reset_sfx = true; break; - case 2: Settings.SuperFXSpeedPerLine = 0.417 * 60.5e6; reset_sfx = true; break; + case 0: Settings.SuperFXSpeedPerLine = 0.417 * 10.5e6; break; + case 1: Settings.SuperFXSpeedPerLine = 0.417 * 40.5e6; break; + case 2: Settings.SuperFXSpeedPerLine = 0.417 * 60.5e6; break; } - if (reset_sfx) S9xResetSuperFX(); + S9xResetSuperFX(); S9xReset(); - break; + break; } if(ret >= 0 || firstRun) diff --git a/source/preferences.cpp b/source/preferences.cpp index d4dbc22..1d33aac 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -483,7 +483,7 @@ DefaultSettings () Settings.Stereo = true; Settings.ReverseStereo = true; Settings.SoundPlaybackRate = 48000; - Settings.SoundInputRate = 32000; + Settings.SoundInputRate = 31970; Settings.DynamicRateControl = true; // Graphics diff --git a/source/snes9x/apu/apu.cpp b/source/snes9x/apu/apu.cpp index 233fadc..727d0a6 100644 --- a/source/snes9x/apu/apu.cpp +++ b/source/snes9x/apu/apu.cpp @@ -390,20 +390,23 @@ int S9xGetSampleCount (void) } #ifdef GEKKO -void S9xIncreaseDynamicRateMultiplier () -{ - if(spc::dynamic_rate_multiplier != 1.005) { - spc::dynamic_rate_multiplier = 1.005; +static double new_dynamic_rate_multiplier = 1.0; + +void UpdatePlaybackRateWithDynamicRate() { + if(spc::dynamic_rate_multiplier != new_dynamic_rate_multiplier) { + spc::dynamic_rate_multiplier = new_dynamic_rate_multiplier; UpdatePlaybackRate(); } } -void S9xResetDynamicRateMultiplier () +static inline void IncreaseDynamicRateMultiplier () { - if(spc::dynamic_rate_multiplier != 1.0) { - spc::dynamic_rate_multiplier = 1.0; - UpdatePlaybackRate(); - } + new_dynamic_rate_multiplier = 1.01; +} + +static inline void ResetDynamicRateMultiplier () +{ + new_dynamic_rate_multiplier = 1.0; } #endif @@ -413,17 +416,14 @@ void S9xFinalizeSamples (void) if (!Settings.Mute) { - if(!spc::sound_in_sync) { - S9xIncreaseDynamicRateMultiplier(); - } - drop_current_msu1_samples = FALSE; if (!spc::resampler->push((short *) spc::landing_buffer, spc_core->sample_count())) { /* We weren't able to process the entire buffer. Potential overrun. */ spc::sound_in_sync = FALSE; - + S9xClearSamples(); + if (Settings.SoundSync && !Settings.TurboMode) return; @@ -455,7 +455,10 @@ void S9xFinalizeSamples (void) spc::sound_in_sync = FALSE; if(spc::sound_in_sync) { - S9xResetDynamicRateMultiplier (); + ResetDynamicRateMultiplier (); + } + else { + IncreaseDynamicRateMultiplier (); } spc_core->set_output((SNES_SPC::sample_t *) spc::landing_buffer, spc::buffer_size >> 1); diff --git a/source/snes9x/apu/apu.h b/source/snes9x/apu/apu.h index 16fdde8..78557f8 100644 --- a/source/snes9x/apu/apu.h +++ b/source/snes9x/apu/apu.h @@ -211,6 +211,7 @@ void S9xSetSoundControl (uint8); void S9xSetSoundMute (bool8); void S9xLandSamples (void); void S9xFinalizeSamples (void); +void UpdatePlaybackRateWithDynamicRate(); void S9xClearSamples (void); bool8 S9xMixSamples (uint8 *, int); void S9xSetSamplesAvailableCallback (apu_callback, void *); diff --git a/source/snes9xgx.cpp b/source/snes9xgx.cpp index fb45f1b..1b5ae91 100644 --- a/source/snes9xgx.cpp +++ b/source/snes9xgx.cpp @@ -378,7 +378,7 @@ void InitializeSnes9x() { if (!S9xInitAPU ()) ExitApp(); - S9xInitSound (32, 0); // Initialise Sound System + S9xInitSound (64, 0); // Initialise Sound System // Initialise Graphics setGFX (); diff --git a/source/video.cpp b/source/video.cpp index 43f39fb..c148efa 100644 --- a/source/video.cpp +++ b/source/video.cpp @@ -638,7 +638,7 @@ ResetVideo_Emu () else ResetFbWidth(512, rmode); - Settings.SoundInputRate = 32000; + Settings.SoundInputRate = 31970; UpdatePlaybackRate(); }