mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Split Audio Dumps on Sample Rate Changes
This commit is contained in:
@ -41,6 +41,11 @@ bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRa
|
||||
|
||||
audio_size = 0;
|
||||
|
||||
if (basename.empty())
|
||||
SplitPath(filename, nullptr, &basename, nullptr);
|
||||
|
||||
current_sample_rate = HLESampleRate;
|
||||
|
||||
// -----------------
|
||||
// Write file header
|
||||
// -----------------
|
||||
@ -89,7 +94,7 @@ void WaveFileWriter::Write4(const char* ptr)
|
||||
file.WriteBytes(ptr, 4);
|
||||
}
|
||||
|
||||
void WaveFileWriter::AddStereoSamples(const short* sample_data, u32 count)
|
||||
void WaveFileWriter::AddStereoSamples(const short* sample_data, u32 count, int sample_rate)
|
||||
{
|
||||
if (!file)
|
||||
PanicAlertT("WaveFileWriter - file not open.");
|
||||
@ -108,11 +113,13 @@ void WaveFileWriter::AddStereoSamples(const short* sample_data, u32 count)
|
||||
return;
|
||||
}
|
||||
|
||||
CheckSampleRate(sample_rate);
|
||||
|
||||
file.WriteBytes(sample_data, count * 4);
|
||||
audio_size += count * 4;
|
||||
}
|
||||
|
||||
void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count)
|
||||
void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count, int sample_rate)
|
||||
{
|
||||
if (!file)
|
||||
PanicAlertT("WaveFileWriter - file not open.");
|
||||
@ -141,6 +148,21 @@ void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count)
|
||||
conv_buffer[2 * i + 1] = Common::swap16((u16)sample_data[2 * i]);
|
||||
}
|
||||
|
||||
CheckSampleRate(sample_rate);
|
||||
|
||||
file.WriteBytes(conv_buffer.data(), count * 4);
|
||||
audio_size += count * 4;
|
||||
}
|
||||
|
||||
void WaveFileWriter::CheckSampleRate(int sample_rate)
|
||||
{
|
||||
if (sample_rate != current_sample_rate)
|
||||
{
|
||||
Stop();
|
||||
file_index++;
|
||||
std::stringstream filename;
|
||||
filename << File::GetUserPath(D_DUMPAUDIO_IDX) << basename << file_index << ".wav";
|
||||
Start(filename.str(), sample_rate);
|
||||
current_sample_rate = sample_rate;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user