Use nominal frequency ratio for APU.

This commit is contained in:
Brandon Wright 2019-02-19 17:50:25 -06:00
parent df9e37d718
commit aa867abcd3
7 changed files with 17 additions and 17 deletions

View File

@ -17,10 +17,10 @@
static const int APU_DEFAULT_INPUT_RATE = 31950; // ~59.94Hz static const int APU_DEFAULT_INPUT_RATE = 31950; // ~59.94Hz
static const int APU_SAMPLE_BLOCK = 48; static const int APU_SAMPLE_BLOCK = 48;
static const int APU_NUMERATOR_NTSC = 15664; static const int APU_NUMERATOR_NTSC = 5632;
static const int APU_DENOMINATOR_NTSC = 328125; static const int APU_DENOMINATOR_NTSC = 118125;
static const int APU_NUMERATOR_PAL = 34176; static const int APU_NUMERATOR_PAL = 35527;
static const int APU_DENOMINATOR_PAL = 709379; static const int APU_DENOMINATOR_PAL = 738343;
// Max number of samples we'll ever generate before call to port API and // Max number of samples we'll ever generate before call to port API and
// moving the samples to the resampler. // moving the samples to the resampler.
@ -176,7 +176,7 @@ static void UpdatePlaybackRate(void)
if (Settings.MSU1) if (Settings.MSU1)
{ {
time_ratio = (44100.0 / Settings.SoundPlaybackRate) * (Settings.SoundInputRate / 32040.0); time_ratio = (44100.0 / Settings.SoundPlaybackRate) * (Settings.SoundInputRate / 32000.0);
msu::resampler->time_ratio(time_ratio); msu::resampler->time_ratio(time_ratio);
} }
} }

View File

@ -418,7 +418,7 @@ event_input_rate_changed (GtkRange *range, gpointer data)
{ {
char text[256]; char text[256];
GtkLabel *label = GTK_LABEL (data); GtkLabel *label = GTK_LABEL (data);
double value = gtk_range_get_value (range) / 32040.0 * 60.09881389744051; double value = gtk_range_get_value (range) / 32000.0 * 60.09881389744051;
snprintf (text, 256, "%.4f hz", value); snprintf (text, 256, "%.4f hz", value);

View File

@ -1595,9 +1595,9 @@ Snes9xWindow::get_auto_input_rate ()
if (refresh_rate > 239.0 && refresh_rate < 241.0) if (refresh_rate > 239.0 && refresh_rate < 241.0)
refresh_rate /= 4.0; refresh_rate /= 4.0;
double new_input_rate = refresh_rate * 32040.0 / 60.09881389744051 + 0.5; double new_input_rate = refresh_rate * 32000.0 / 60.09881389744051 + 0.5;
if (new_input_rate > 32040.0 * 1.05 || new_input_rate < 32040.0 * 0.95) if (new_input_rate > 32000.0 * 1.05 || new_input_rate < 32000.0 * 0.95)
new_input_rate = 0.0; new_input_rate = 0.0;
return new_input_rate; return new_input_rate;

View File

@ -690,7 +690,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
info->geometry.max_width = MAX_SNES_WIDTH; info->geometry.max_width = MAX_SNES_WIDTH;
info->geometry.max_height = MAX_SNES_HEIGHT; info->geometry.max_height = MAX_SNES_HEIGHT;
info->geometry.aspect_ratio = get_aspect_ratio(width, height); info->geometry.aspect_ratio = get_aspect_ratio(width, height);
info->timing.sample_rate = 32040; info->timing.sample_rate = 32000;
info->timing.fps = retro_get_region() == RETRO_REGION_NTSC ? 21477272.0 / 357366.0 : 21281370.0 / 425568.0; info->timing.fps = retro_get_region() == RETRO_REGION_NTSC ? 21477272.0 / 357366.0 : 21281370.0 / 425568.0;
g_screen_gun_width = width; g_screen_gun_width = width;
@ -1202,8 +1202,8 @@ void retro_init(void)
Settings.FrameTimeNTSC = 16667; Settings.FrameTimeNTSC = 16667;
Settings.SixteenBitSound = TRUE; Settings.SixteenBitSound = TRUE;
Settings.Stereo = TRUE; Settings.Stereo = TRUE;
Settings.SoundPlaybackRate = 32040; Settings.SoundPlaybackRate = 32000;
Settings.SoundInputRate = 32040; Settings.SoundInputRate = 32000;
Settings.SupportHiRes = TRUE; Settings.SupportHiRes = TRUE;
Settings.Transparency = TRUE; Settings.Transparency = TRUE;
Settings.AutoDisplayMessages = TRUE; Settings.AutoDisplayMessages = TRUE;

View File

@ -230,7 +230,7 @@ void S9xMSU1Generate(size_t sample_count)
{ {
partial_frames += 4410 * (sample_count / 2); partial_frames += 4410 * (sample_count / 2);
while (partial_frames >= 3204) while (partial_frames >= 3200)
{ {
if (MSU1.MSU1_STATUS & AudioPlaying && audioStream) if (MSU1.MSU1_STATUS & AudioPlaying && audioStream)
{ {
@ -246,7 +246,7 @@ void S9xMSU1Generate(size_t sample_count)
msu_resampler->push_sample(*left, *right); msu_resampler->push_sample(*left, *right);
MSU1.MSU1_AUDIO_POS += 4; MSU1.MSU1_AUDIO_POS += 4;
partial_frames -= 3204; partial_frames -= 3200;
} }
else else
if (bytes_read >= 0) if (bytes_read >= 0)
@ -270,7 +270,7 @@ void S9xMSU1Generate(size_t sample_count)
else else
{ {
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating); MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
partial_frames -= 3204; partial_frames -= 3200;
msu_resampler->push_sample(0, 0); msu_resampler->push_sample(0, 0);
} }
} }

View File

@ -61,7 +61,7 @@
#define IMAGE_WIDTH (Settings.SupportHiRes ? MAX_SNES_WIDTH : SNES_WIDTH) #define IMAGE_WIDTH (Settings.SupportHiRes ? MAX_SNES_WIDTH : SNES_WIDTH)
#define IMAGE_HEIGHT (Settings.SupportHiRes ? MAX_SNES_HEIGHT : SNES_HEIGHT_EXTENDED) #define IMAGE_HEIGHT (Settings.SupportHiRes ? MAX_SNES_HEIGHT : SNES_HEIGHT_EXTENDED)
#define NTSC_MASTER_CLOCK 21477272.0 #define NTSC_MASTER_CLOCK 21477272.727272 // 21477272 + 8/11 exact
#define PAL_MASTER_CLOCK 21281370.0 #define PAL_MASTER_CLOCK 21281370.0
#define SNES_MAX_NTSC_VCOUNTER 262 #define SNES_MAX_NTSC_VCOUNTER 262

View File

@ -622,9 +622,9 @@ int WinGetAutomaticInputRate(void)
if (refreshRate > 239.0 && refreshRate < 241.0) if (refreshRate > 239.0 && refreshRate < 241.0)
refreshRate /= 4.0; refreshRate /= 4.0;
double newInputRate = refreshRate * 32040.0 / 60.09881389744051 + 0.5; double newInputRate = refreshRate * 32000.0 / 60.09881389744051 + 0.5;
if (newInputRate > 32040.0 * 1.05 || newInputRate < 32040.0 * 0.95) if (newInputRate > 32000.0 * 1.05 || newInputRate < 32000.0 * 0.95)
newInputRate = 0.0; newInputRate = 0.0;
return (int)newInputRate; return (int)newInputRate;