diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2022-07-05 11:37:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-05 11:37:30 +0200 |
| commit | de3d1344d5ed939faedae9c19e2e340a83038aba (patch) | |
| tree | 40d2efd3dbe7c8ad2d7303539a7a48264be00005 /Source/Core/AudioCommon/WaveFile.cpp | |
| parent | d625c612c4a40a8c8db3d90b313f5643aec9c890 (diff) | |
| parent | 4234b25682ddfab6018c3c7bf410e568f527b1cd (diff) | |
Merge pull request #10762 from CasualPokePlayer/fix_slow_audio_desyncs
Reduce gradual audio desyncing in dumps and apply the correct sample rate for GameCube audio
Diffstat (limited to 'Source/Core/AudioCommon/WaveFile.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/WaveFile.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Source/Core/AudioCommon/WaveFile.cpp b/Source/Core/AudioCommon/WaveFile.cpp index befcf6bfbd..dc689e74dd 100644 --- a/Source/Core/AudioCommon/WaveFile.cpp +++ b/Source/Core/AudioCommon/WaveFile.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "AudioCommon/WaveFile.h" +#include "AudioCommon/Mixer.h" #include <string> @@ -26,7 +27,7 @@ WaveFileWriter::~WaveFileWriter() Stop(); } -bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRate) +bool WaveFileWriter::Start(const std::string& filename, u32 sample_rate_divisor) { // Ask to delete file if (File::Exists(filename)) @@ -65,7 +66,7 @@ bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRa if (basename.empty()) SplitPath(filename, nullptr, &basename, nullptr); - current_sample_rate = HLESampleRate; + current_sample_rate_divisor = sample_rate_divisor; // ----------------- // Write file header @@ -78,7 +79,7 @@ bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRa Write(16); // size of fmt block Write(0x00020001); // two channels, uncompressed - const u32 sample_rate = HLESampleRate; + const u32 sample_rate = Mixer::FIXED_SAMPLE_RATE_DIVIDEND / sample_rate_divisor; Write(sample_rate); Write(sample_rate * 2 * 2); // two channels, 16bit @@ -114,8 +115,8 @@ void WaveFileWriter::Write4(const char* ptr) file.WriteBytes(ptr, 4); } -void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count, int sample_rate, - int l_volume, int r_volume) +void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count, + u32 sample_rate_divisor, int l_volume, int r_volume) { if (!file) ERROR_LOG_FMT(AUDIO, "WaveFileWriter - file not open."); @@ -148,14 +149,14 @@ void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count, int conv_buffer[2 * i + 1] = conv_buffer[2 * i + 1] * r_volume / 256; } - if (sample_rate != current_sample_rate) + if (sample_rate_divisor != current_sample_rate_divisor) { Stop(); file_index++; std::ostringstream filename; filename << File::GetUserPath(D_DUMPAUDIO_IDX) << basename << file_index << ".wav"; - Start(filename.str(), sample_rate); - current_sample_rate = sample_rate; + Start(filename.str(), sample_rate_divisor); + current_sample_rate_divisor = sample_rate_divisor; } file.WriteBytes(conv_buffer.data(), count * 4); |
