From cf846e0c56962f724c5f84c10b926de8884b8f95 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Fri, 9 Dec 2016 17:50:50 -0600 Subject: [PATCH] Use 32040hz with more consistency. --- apu/apu.cpp | 8 ++++---- msu1.cpp | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/apu/apu.cpp b/apu/apu.cpp index 3e83d7f9..34460b20 100644 --- a/apu/apu.cpp +++ b/apu/apu.cpp @@ -462,7 +462,7 @@ static void UpdatePlaybackRate (void) if (Settings.MSU1) { - time_ratio = (44100.0 / Settings.SoundPlaybackRate) * (Settings.SoundInputRate / 32040.5); + time_ratio = (44100.0 / Settings.SoundPlaybackRate) * (Settings.SoundInputRate / 32040); msu::resampler->time_ratio(time_ratio); } } @@ -472,8 +472,8 @@ bool8 S9xInitSound (int buffer_ms, int lag_ms) // buffer_ms : buffer size given in millisecond // lag_ms : allowable time-lag given in millisecond - int sample_count = buffer_ms * 32000 / 1000; - int lag_sample_count = lag_ms * 32000 / 1000; + int sample_count = buffer_ms * 32040 / 1000; + int lag_sample_count = lag_ms * 32040 / 1000; spc::lag_master = lag_sample_count; if (Settings.Stereo) @@ -488,7 +488,7 @@ bool8 S9xInitSound (int buffer_ms, int lag_ms) spc::buffer_size <<= 1; if (Settings.SixteenBitSound) spc::buffer_size <<= 1; - msu::buffer_size = ((buffer_ms * 44100 / 1000) * 441000 / 320405) << 2; // Always 16-bit, Stereo + msu::buffer_size = ((buffer_ms * 44100 / 1000) * 44100 / 32040) << 2; // Always 16-bit, Stereo printf("Sound buffer size: %d (%d samples)\n", spc::buffer_size, sample_count); diff --git a/msu1.cpp b/msu1.cpp index 382abbc5..4ad05419 100644 --- a/msu1.cpp +++ b/msu1.cpp @@ -197,8 +197,6 @@ #include #include -#define APU_DEFAULT_INPUT_RATE 32000 - std::ifstream dataFile, audioFile; uint32 audioLoopPos; uint32 partial_samples; @@ -294,9 +292,9 @@ bool S9xMSU1ROMExists(void) void S9xMSU1Generate(int sample_count) { - partial_samples += 441000 * sample_count; + partial_samples += 44100 * sample_count; - while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying) && partial_samples > 320405) + while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying) && partial_samples > 32040) { if (audioFile.is_open()) { @@ -307,7 +305,7 @@ void S9xMSU1Generate(int sample_count) *(bufPos++) = sample; MSU1.MSU1_AUDIO_POS += 2; - partial_samples -= 320405; + partial_samples -= 32040; } else if (audioFile.eof()) @@ -316,7 +314,7 @@ void S9xMSU1Generate(int sample_count) *(bufPos++) = sample; MSU1.MSU1_AUDIO_POS += 2; - partial_samples -= 320405; + partial_samples -= 32040; if (MSU1.MSU1_STATUS & AudioRepeating) {