diff --git a/apu/apu.cpp b/apu/apu.cpp index 1e4a6e86..63a35392 100644 --- a/apu/apu.cpp +++ b/apu/apu.cpp @@ -914,11 +914,3 @@ bool8 S9xSPCDump (const char *filename) return (TRUE); } - -extern int dsp_interpolation_method; - -void S9xSetDSPInterpolation (int mode) -{ - dsp_interpolation_method = mode; - return; -} diff --git a/apu/apu.h b/apu/apu.h index cb83fa84..fac90a28 100644 --- a/apu/apu.h +++ b/apu/apu.h @@ -237,6 +237,4 @@ void S9xUpdateDynamicRate (int, int); #define DSP_INTERPOLATION_CUBIC 3 #define DSP_INTERPOLATION_SINC 4 -void S9xSetDSPInterpolation (int); - #endif diff --git a/apu/bapu/dsp/SPC_DSP.cpp b/apu/bapu/dsp/SPC_DSP.cpp index 5dec1850..719c04b2 100644 --- a/apu/bapu/dsp/SPC_DSP.cpp +++ b/apu/bapu/dsp/SPC_DSP.cpp @@ -1,5 +1,7 @@ // snes_spc 0.9.0. http://www.slack.net/~ant/ +#include "snes9x.h" + #include "SPC_DSP.h" #include "blargg_endian.h" @@ -412,14 +414,12 @@ static short const sinc [2048] = -38, 41, -328, 718, 15642, 613, -302, 38, }; -int dsp_interpolation_method = 2; - inline int SPC_DSP::interpolate( voice_t const* v ) { int out; int const* in = &v->buf [(v->interp_pos >> 12) + v->buf_pos]; - switch (dsp_interpolation_method) + switch (Settings.InterpolationMethod) { case 0: // raw { diff --git a/gtk/src/gtk_config.cpp b/gtk/src/gtk_config.cpp index cd0b1539..e3ae8554 100644 --- a/gtk/src/gtk_config.cpp +++ b/gtk/src/gtk_config.cpp @@ -257,6 +257,7 @@ Snes9xConfig::load_defaults (void) Settings.SoundSync = 1; Settings.DynamicRateControl = FALSE; Settings.DynamicRateLimit = 5; + Settings.InterpolationMethod = DSP_INTERPOLATION_GAUSSIAN; Settings.HDMATimingHack = 100; Settings.SuperFXClockMultiplier = 100; Settings.InitialSnapshotFilename[0] = '\0'; @@ -409,6 +410,7 @@ Snes9xConfig::save_config_file (void) xml_out_int (xml, "dynamic_rate_control", Settings.DynamicRateControl); xml_out_int (xml, "dynamic_rate_limit", Settings.DynamicRateLimit); xml_out_int (xml, "auto_input_rate", auto_input_rate); + xml_out_int (xml, "interpolation_method", Settings.InterpolationMethod); /* Snes9X core-stored variables */ xml_out_int (xml, "transparency", Settings.Transparency); @@ -917,6 +919,10 @@ Snes9xConfig::set_option (const char *name, const char *value) { rewind_granularity = CLAMP (atoi (value), 0, 600); } + else if (!strcasecmp (name, "interpolation_method")) + { + Settings.InterpolationMethod = CLAMP (atoi (value), 0, 4); + } else { fprintf (stderr, _("bad option name: %s\n"), name); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index dc2e28ea..2648fa7e 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -169,6 +169,7 @@ void retro_set_environment(retro_environment_t cb) { "snes9x_up_down_allowed", "Allow Opposing Directions; disabled|enabled" }, { "snes9x_overclock_superfx", "SuperFX Overclocking; 100%|150%|200%|250%|300%|350%|400%|450%|500%|50%" }, { "snes9x_hires_blend", "Hires Blending; disabled|enabled" }, + { "snes9x_audio_interpolation", "Audio Interpolation; gaussian|cubic|sinc|none|linear" }, { "snes9x_layer_1", "Show layer 1; enabled|disabled" }, { "snes9x_layer_2", "Show layer 2; enabled|disabled" }, { "snes9x_layer_3", "Show layer 3; enabled|disabled" }, @@ -313,6 +314,24 @@ static void update_variables(void) var.value=NULL; Settings.SupportHiRes=!(environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && !strcmp("disabled", var.value)); + var.key="snes9x_audio_interpolation"; + var.value=NULL; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "gaussian") == 0) + Settings.InterpolationMethod = DSP_INTERPOLATION_GAUSSIAN; + else if (strcmp(var.value, "linear") == 0) + Settings.InterpolationMethod = DSP_INTERPOLATION_LINEAR; + else if (strcmp(var.value, "cubic") == 0) + Settings.InterpolationMethod = DSP_INTERPOLATION_CUBIC; + else if (strcmp(var.value, "sinc") == 0) + Settings.InterpolationMethod = DSP_INTERPOLATION_SINC; + else if (strcmp(var.value, "none") == 0) + Settings.InterpolationMethod = DSP_INTERPOLATION_NONE; + } + else + Settings.InterpolationMethod = DSP_INTERPOLATION_GAUSSIAN; + var.key = "snes9x_overscan"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) diff --git a/snes9x.cpp b/snes9x.cpp index 78947e44..dc70f89a 100644 --- a/snes9x.cpp +++ b/snes9x.cpp @@ -428,6 +428,7 @@ void S9xLoadConfigFiles (char **argv, int argc) Settings.Mute = conf.GetBool("Sound::Mute", false); Settings.DynamicRateControl = conf.GetBool("Sound::DynamicRateControl", false); Settings.DynamicRateLimit = conf.GetInt ("Sound::DynamicRateLimit", 5); + Settings.InterpolationMethod = conf.GetInt ("Sound::InterpolationMethod", 2); // Display diff --git a/snes9x.h b/snes9x.h index bf8304b4..f06564c4 100644 --- a/snes9x.h +++ b/snes9x.h @@ -419,6 +419,7 @@ struct SSettings bool8 Mute; bool8 DynamicRateControl; int32 DynamicRateLimit; /* Multiplied by 1000 */ + int32 InterpolationMethod; bool8 SupportHiRes; bool8 Transparency; diff --git a/win32/wconfig.cpp b/win32/wconfig.cpp index 0cf5df2f..9a07c28e 100644 --- a/win32/wconfig.cpp +++ b/win32/wconfig.cpp @@ -1005,6 +1005,7 @@ void WinRegisterConfigItems() AddBoolC("Mute", GUI.Mute, false, "true to mute sound output (does not disable the sound CPU)"); AddBool("DynamicRateControl", Settings.DynamicRateControl, false); AddBool("AutomaticInputRate", GUI.AutomaticInputRate, true); + AddIntC("InterpolationMethod", Settings.InterpolationMethod, 2, "0 = None, 1 = Linear, 2 = Gaussian (accurate), 3 = Cubic, 4 = Sinc"); #undef CATEGORY #define CATEGORY "Sound\\Win" AddUIntC("SoundDriver", GUI.SoundDriver, 4, "0=Snes9xDirectSound, 4=XAudio2 (recommended)");