From 1442378a13aae759a51976d8caa02949c70b60dd Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Tue, 2 Aug 2016 10:31:05 -0500 Subject: [PATCH] Add option to mute sound on turbo --- gtk/src/gtk_config.cpp | 6 ++++++ gtk/src/gtk_config.h | 1 + gtk/src/gtk_preferences.cpp | 2 ++ gtk/src/gtk_s9x.cpp | 16 ++++++++++++++++ gtk/src/snes9x.ui | 20 ++++++++++++++++++-- 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/gtk/src/gtk_config.cpp b/gtk/src/gtk_config.cpp index 861ac646..2d2585c6 100644 --- a/gtk/src/gtk_config.cpp +++ b/gtk/src/gtk_config.cpp @@ -139,6 +139,7 @@ Snes9xConfig::load_defaults (void) pause_emulation_on_switch = 0; num_threads = 2; mute_sound = FALSE; + mute_sound_turbo = FALSE; fullscreen = FALSE; ui_visible = TRUE; statusbar_visible = FALSE; @@ -348,6 +349,7 @@ Snes9xConfig::save_config_file (void) xml_out_string (xml, "netplay_last_host", netplay_last_host); xml_out_int (xml, "mute_sound", mute_sound); + xml_out_int (xml, "mute_sound_turbo", mute_sound_turbo); xml_out_int (xml, "sound_buffer_size", sound_buffer_size); xml_out_int (xml, "sound_driver", sound_driver); xml_out_int (xml, "sound_input_rate", sound_input_rate); @@ -598,6 +600,10 @@ Snes9xConfig::set_option (const char *name, const char *value) { mute_sound = atoi (value); } + else if (!strcasecmp (name, "mute_sound_turbo")) + { + mute_sound_turbo = atoi (value); + } else if (!strcasecmp (name, "16bit_sound")) { Settings.SixteenBitSound = atoi (value); diff --git a/gtk/src/gtk_config.h b/gtk/src/gtk_config.h index 9e8ec7c0..90514847 100644 --- a/gtk/src/gtk_config.h +++ b/gtk/src/gtk_config.h @@ -119,6 +119,7 @@ class Snes9xConfig /* Operational */ int sound_driver; int mute_sound; + int mute_sound_turbo; int sound_buffer_size; int sound_playback_rate; int sound_input_rate; diff --git a/gtk/src/gtk_preferences.cpp b/gtk/src/gtk_preferences.cpp index ab8711cb..3816b9c9 100644 --- a/gtk/src/gtk_preferences.cpp +++ b/gtk/src/gtk_preferences.cpp @@ -660,6 +660,7 @@ Snes9xPreferences::move_settings_to_dialog (void) set_check ("pause_emulation_on_switch", config->pause_emulation_on_switch); set_spin ("num_threads", config->num_threads); set_check ("mute_sound_check", config->mute_sound); + set_check ("mute_sound_turbo_check", config->mute_sound_turbo); set_spin ("sound_buffer_size", config->sound_buffer_size); set_slider ("sound_input_rate", config->sound_input_rate); set_check ("sync_sound", Settings.SoundSync); @@ -815,6 +816,7 @@ Snes9xPreferences::get_settings_from_dialog (void) config->sound_input_rate = get_slider ("sound_input_rate"); Settings.SoundSync = get_check ("sync_sound"); config->mute_sound = get_check ("mute_sound_check"); + config->mute_sound_turbo = get_check ("mute_sound_turbo_check"); store_ntsc_settings (); config->ntsc_scanline_intensity = get_combo ("ntsc_scanline_intensity"); diff --git a/gtk/src/gtk_s9x.cpp b/gtk/src/gtk_s9x.cpp index 48195ffd..98fda970 100644 --- a/gtk/src/gtk_s9x.cpp +++ b/gtk/src/gtk_s9x.cpp @@ -358,6 +358,22 @@ S9xIdleFunc (gpointer data) { #endif S9xMainLoop (); + + static int muted_from_turbo = FALSE; + static int mute_saved_state = FALSE; + + if (Settings.TurboMode && !muted_from_turbo && gui_config->mute_sound_turbo) + { + muted_from_turbo = TRUE; + mute_saved_state = Settings.Mute; + } + + if (!Settings.TurboMode && muted_from_turbo) + { + muted_from_turbo = FALSE; + Settings.Mute = mute_saved_state; + } + S9xMixSound (); #ifdef NETPLAY_SUPPORT diff --git a/gtk/src/snes9x.ui b/gtk/src/snes9x.ui index 91635b3a..5fa84a99 100644 --- a/gtk/src/snes9x.ui +++ b/gtk/src/snes9x.ui @@ -3983,6 +3983,22 @@ 2 + + + Mute sound when using turbo + True + True + False + Disables output of sound when using turbo + True + True + + + False + False + 3 + + Stereo @@ -3996,7 +4012,7 @@ False False - 3 + 4 @@ -4172,7 +4188,7 @@ False True - 4 + 5