From 4234b25682ddfab6018c3c7bf410e568f527b1cd Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Sun, 3 Jul 2022 15:07:06 -0700 Subject: Do not directly store input sample rate, rather just store a divisor for that sample rate, with it using a fixed dividend of 54000000 * 2. This should reduce (but not completely eliminate) gradual audio desyncs in dumps. This also allows for accurate sample rates for the GameCube. Completely eliminating gradual audio desyncs will require resampling to an integer sample rate, as nothing seems to support a non-integer sample rate. --- Source/Core/AudioCommon/WaveFile.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'Source/Core/AudioCommon/WaveFile.h') diff --git a/Source/Core/AudioCommon/WaveFile.h b/Source/Core/AudioCommon/WaveFile.h index e95ed8eb73..350e1da9af 100644 --- a/Source/Core/AudioCommon/WaveFile.h +++ b/Source/Core/AudioCommon/WaveFile.h @@ -30,24 +30,28 @@ public: WaveFileWriter(WaveFileWriter&&) = delete; WaveFileWriter& operator=(WaveFileWriter&&) = delete; - bool Start(const std::string& filename, unsigned int HLESampleRate); + bool Start(const std::string& filename, u32 sample_rate_divisor); void Stop(); void SetSkipSilence(bool skip) { skip_silence = skip; } - void AddStereoSamplesBE(const short* sample_data, u32 count, int sample_rate, int l_volume, - int r_volume); // big endian + // big endian + void AddStereoSamplesBE(const short* sample_data, u32 count, u32 sample_rate_divisor, + int l_volume, int r_volume); u32 GetAudioSize() const { return audio_size; } private: static constexpr size_t BUFFER_SIZE = 32 * 1024; - File::IOFile file; - bool skip_silence = false; - u32 audio_size = 0; - std::array conv_buffer{}; void Write(u32 value); void Write4(const char* ptr); + + File::IOFile file; std::string basename; - int current_sample_rate; - int file_index = 0; + u32 file_index = 0; + u32 audio_size = 0; + + u32 current_sample_rate_divisor; + std::array conv_buffer{}; + + bool skip_silence = false; }; -- cgit v1.2.3