Use display refresh rates rather than input rate directly.

This commit is contained in:
Themaister 2011-11-18 15:14:56 +01:00
parent da97b29d0b
commit 81b0e6d0a3
5 changed files with 39 additions and 12 deletions

View file

@ -159,6 +159,16 @@ static const bool post_filter_record = false;
// OSD-messages
static const bool font_enable = true;
// The accurate refresh rate of your monitor (Hz).
// This is used to calculate audio input rate with the formula:
// audio_input_rate = game_input_rate * display_refresh_rate / game_refresh_rate.
// If the implementation does not report any values,
// SNES NTSC defaults will be assumed for compatibility.
// This value should stay close to 60Hz to avoid large pitch changes.
// If your monitor does not run at 60Hz, or something close to it, disable VSync,
// and leave this at its default.
static const float refresh_rate = 59.95;
////////////////
// Audio
////////////////
@ -169,10 +179,6 @@ static const bool audio_enable = true;
// Output samplerate
static const unsigned out_rate = 48000;
// Input samplerate from libSNES.
// Lower this (slightly) if you are experiencing frequent audio dropouts while vsync is enabled.
static const float in_rate = 31980.0;
// When changing input rate on-the-fly
static const float audio_rate_step = 0.25;

View file

@ -222,6 +222,27 @@ static void deinit_dsp_plugin(void)
}
}
static void adjust_audio_input_rate(void)
{
static bool first = true;
if (!first)
return;
if (g_extern.system.timing_set)
{
g_settings.audio.in_rate = g_extern.system.timing.sample_rate *
(g_settings.video.refresh_rate / g_extern.system.timing.fps);
}
else
{
g_settings.audio.in_rate = 32040.5 *
(g_settings.video.refresh_rate / (21477272.0 / 357366.0)); // SNES metrics.
}
SSNES_LOG("Adjusted audio input rate to: %.2f Hz.\n", g_settings.audio.in_rate);
first = false;
}
#define AUDIO_CHUNK_SIZE_BLOCKING 64
#define AUDIO_CHUNK_SIZE_NONBLOCKING 2048 // So we don't get complete line-noise when fast-forwarding audio.
#define AUDIO_MAX_RATIO 16
@ -233,6 +254,7 @@ void init_audio(void)
return;
}
adjust_audio_input_rate();
find_audio_driver();
g_extern.audio_data.block_chunk_size = AUDIO_CHUNK_SIZE_BLOCKING;

View file

@ -86,6 +86,7 @@ struct settings
char bsnes_shader_path[MAXPATHLEN];
char filter_path[MAXPATHLEN];
enum ssnes_shader_type shader_type;
float refresh_rate;
bool render_to_texture;
double fbo_scale_x;

View file

@ -150,12 +150,12 @@ static void set_defaults(void)
g_settings.video.second_pass_smooth = second_pass_smooth;
#endif
g_settings.video.refresh_rate = refresh_rate;
g_settings.video.hires_record = hires_record;
g_settings.video.post_filter_record = post_filter_record;
g_settings.audio.enable = audio_enable;
g_settings.audio.out_rate = out_rate;
g_settings.audio.in_rate = in_rate;
g_settings.audio.rate_step = audio_rate_step;
if (audio_device)
strlcpy(g_settings.audio.device, audio_device, sizeof(g_settings.audio.device));
@ -317,6 +317,7 @@ static void parse_config_file(void)
CONFIG_GET_BOOL(video.force_aspect, "video_force_aspect");
CONFIG_GET_BOOL(video.crop_overscan, "video_crop_overscan");
CONFIG_GET_DOUBLE(video.aspect_ratio, "video_aspect_ratio");
CONFIG_GET_DOUBLE(video.refresh_rate, "video_refresh_rate");
CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader");
CONFIG_GET_STRING(video.bsnes_shader_path, "video_bsnes_shader");
@ -380,7 +381,6 @@ static void parse_config_file(void)
// Audio settings.
CONFIG_GET_BOOL(audio.enable, "audio_enable");
CONFIG_GET_INT(audio.out_rate, "audio_out_rate");
CONFIG_GET_DOUBLE(audio.in_rate, "audio_in_rate");
CONFIG_GET_DOUBLE(audio.rate_step, "audio_rate_step");
CONFIG_GET_STRING(audio.device, "audio_device");
CONFIG_GET_INT(audio.latency, "audio_latency");

View file

@ -101,6 +101,10 @@
# It is a regular RGB hex number, i.e. red is "ff0000".
# video_message_color = ffffff
# Video refresh rate of your monitor.
# Used to calculate a suitable audio input rate.
# video_refresh_rate = 59.95
#### Audio
# Enable audio.
@ -109,12 +113,6 @@
# Audio output samplerate.
# audio_out_rate = 48000
# Audio input samplerate from libsnes.
# Lower this (slightly) if you are experiencing frequent audio dropouts while vsync is enabled.
# Conversely, increase this slightly if you are experiencing good audio,
# but lots of dropped frames. Reasonable values for this is 32000 +/- 100 Hz.
# audio_in_rate = 31980
# When altering audio_in_rate on-the-fly, define by how much each time.
# audio_rate_step = 0.25