Optimize rate control formula and remove placeholder copy-paste.

This commit is contained in:
Brandon Wright 2017-11-24 08:19:05 -06:00
parent 2eaac353ba
commit 618519457b
3 changed files with 5 additions and 7 deletions

View File

@ -475,10 +475,8 @@ void S9xSetSamplesAvailableCallback (apu_callback callback, void *data)
void S9xUpdateDynamicRate (int avail, int buffer_size) void S9xUpdateDynamicRate (int avail, int buffer_size)
{ {
int half_size = buffer_size / 2; spc::dynamic_rate_multiplier = 1.0 + ((int) Settings.DynamicRateLimit * (buffer_size - 2 * avail)) /
int delta_mid = avail - half_size; (double)(1000 * buffer_size);
double direction = (double) delta_mid / half_size;
spc::dynamic_rate_multiplier = 1.0 - (Settings.DynamicRateLimit / 100000.0) * direction;
UpdatePlaybackRate(); UpdatePlaybackRate();
} }

View File

@ -662,7 +662,7 @@ Snes9xPreferences::move_settings_to_dialog (void)
set_slider ("sound_input_rate", config->sound_input_rate); set_slider ("sound_input_rate", config->sound_input_rate);
set_check ("sync_sound", Settings.SoundSync); set_check ("sync_sound", Settings.SoundSync);
set_check ("dynamic_rate_control", Settings.DynamicRateControl); set_check ("dynamic_rate_control", Settings.DynamicRateControl);
set_spin ("dynamic_rate_limit", Settings.DynamicRateLimit / 100000.0); set_spin ("dynamic_rate_limit", Settings.DynamicRateLimit / 1000.0);
set_spin ("rewind_buffer_size", config->rewind_buffer_size); set_spin ("rewind_buffer_size", config->rewind_buffer_size);
set_spin ("rewind_granularity", config->rewind_granularity); set_spin ("rewind_granularity", config->rewind_granularity);
@ -819,7 +819,7 @@ Snes9xPreferences::get_settings_from_dialog (void)
config->mute_sound = get_check ("mute_sound_check"); config->mute_sound = get_check ("mute_sound_check");
config->mute_sound_turbo = get_check ("mute_sound_turbo_check"); config->mute_sound_turbo = get_check ("mute_sound_turbo_check");
Settings.DynamicRateControl = get_check ("dynamic_rate_control"); Settings.DynamicRateControl = get_check ("dynamic_rate_control");
Settings.DynamicRateLimit = (uint32) (get_spin ("dynamic_rate_limit") * 100000); Settings.DynamicRateLimit = (uint32) (get_spin ("dynamic_rate_limit") * 1000);
store_ntsc_settings (); store_ntsc_settings ();
config->ntsc_scanline_intensity = get_combo ("ntsc_scanline_intensity"); config->ntsc_scanline_intensity = get_combo ("ntsc_scanline_intensity");

View File

@ -408,7 +408,7 @@ struct SSettings
bool8 ReverseStereo; bool8 ReverseStereo;
bool8 Mute; bool8 Mute;
bool8 DynamicRateControl; bool8 DynamicRateControl;
uint32 DynamicRateLimit; /* Multiplied by 100000 */ uint32 DynamicRateLimit; /* Multiplied by 1000 */
bool8 SupportHiRes; bool8 SupportHiRes;
bool8 Transparency; bool8 Transparency;