mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Merge pull request #10735 from CasualPokePlayer/audio_dump_volume_fix
Have audio dumps apply volume
This commit is contained in:
commit
f96e91119a
@ -256,17 +256,25 @@ void Mixer::MixerFifo::PushSamples(const short* samples, unsigned int num_sample
|
|||||||
void Mixer::PushSamples(const short* samples, unsigned int num_samples)
|
void Mixer::PushSamples(const short* samples, unsigned int num_samples)
|
||||||
{
|
{
|
||||||
m_dma_mixer.PushSamples(samples, num_samples);
|
m_dma_mixer.PushSamples(samples, num_samples);
|
||||||
int sample_rate = m_dma_mixer.GetInputSampleRate();
|
|
||||||
if (m_log_dsp_audio)
|
if (m_log_dsp_audio)
|
||||||
m_wave_writer_dsp.AddStereoSamplesBE(samples, num_samples, sample_rate);
|
{
|
||||||
|
int sample_rate = m_dma_mixer.GetInputSampleRate();
|
||||||
|
auto volume = m_dma_mixer.GetVolume();
|
||||||
|
m_wave_writer_dsp.AddStereoSamplesBE(samples, num_samples, sample_rate, volume.first,
|
||||||
|
volume.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::PushStreamingSamples(const short* samples, unsigned int num_samples)
|
void Mixer::PushStreamingSamples(const short* samples, unsigned int num_samples)
|
||||||
{
|
{
|
||||||
m_streaming_mixer.PushSamples(samples, num_samples);
|
m_streaming_mixer.PushSamples(samples, num_samples);
|
||||||
int sample_rate = m_streaming_mixer.GetInputSampleRate();
|
|
||||||
if (m_log_dtk_audio)
|
if (m_log_dtk_audio)
|
||||||
m_wave_writer_dtk.AddStereoSamplesBE(samples, num_samples, sample_rate);
|
{
|
||||||
|
int sample_rate = m_streaming_mixer.GetInputSampleRate();
|
||||||
|
auto volume = m_streaming_mixer.GetVolume();
|
||||||
|
m_wave_writer_dtk.AddStereoSamplesBE(samples, num_samples, sample_rate, volume.first,
|
||||||
|
volume.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::PushWiimoteSpeakerSamples(const short* samples, unsigned int num_samples,
|
void Mixer::PushWiimoteSpeakerSamples(const short* samples, unsigned int num_samples,
|
||||||
@ -427,6 +435,11 @@ void Mixer::MixerFifo::SetVolume(unsigned int lvolume, unsigned int rvolume)
|
|||||||
m_RVolume.store(rvolume + (rvolume >> 7));
|
m_RVolume.store(rvolume + (rvolume >> 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair<s32, s32> Mixer::MixerFifo::GetVolume() const
|
||||||
|
{
|
||||||
|
return std::make_pair(m_LVolume.load(), m_RVolume.load());
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int Mixer::MixerFifo::AvailableSamples() const
|
unsigned int Mixer::MixerFifo::AvailableSamples() const
|
||||||
{
|
{
|
||||||
unsigned int samples_in_fifo = ((m_indexW.load() - m_indexR.load()) & INDEX_MASK) / 2;
|
unsigned int samples_in_fifo = ((m_indexW.load() - m_indexR.load()) & INDEX_MASK) / 2;
|
||||||
|
@ -74,6 +74,7 @@ private:
|
|||||||
void SetInputSampleRate(unsigned int rate);
|
void SetInputSampleRate(unsigned int rate);
|
||||||
unsigned int GetInputSampleRate() const;
|
unsigned int GetInputSampleRate() const;
|
||||||
void SetVolume(unsigned int lvolume, unsigned int rvolume);
|
void SetVolume(unsigned int lvolume, unsigned int rvolume);
|
||||||
|
std::pair<s32, s32> GetVolume() const;
|
||||||
unsigned int AvailableSamples() const;
|
unsigned int AvailableSamples() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -114,7 +114,8 @@ void WaveFileWriter::Write4(const char* ptr)
|
|||||||
file.WriteBytes(ptr, 4);
|
file.WriteBytes(ptr, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count, int sample_rate)
|
void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count, int sample_rate,
|
||||||
|
int l_volume, int r_volume)
|
||||||
{
|
{
|
||||||
if (!file)
|
if (!file)
|
||||||
ERROR_LOG_FMT(AUDIO, "WaveFileWriter - file not open.");
|
ERROR_LOG_FMT(AUDIO, "WaveFileWriter - file not open.");
|
||||||
@ -141,6 +142,10 @@ void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count, int
|
|||||||
// Flip the audio channels from RL to LR
|
// Flip the audio channels from RL to LR
|
||||||
conv_buffer[2 * i] = Common::swap16((u16)sample_data[2 * i + 1]);
|
conv_buffer[2 * i] = Common::swap16((u16)sample_data[2 * i + 1]);
|
||||||
conv_buffer[2 * i + 1] = Common::swap16((u16)sample_data[2 * i]);
|
conv_buffer[2 * i + 1] = Common::swap16((u16)sample_data[2 * i]);
|
||||||
|
|
||||||
|
// Apply volume (volume ranges from 0 to 256)
|
||||||
|
conv_buffer[2 * i] = conv_buffer[2 * i] * l_volume / 256;
|
||||||
|
conv_buffer[2 * i + 1] = conv_buffer[2 * i + 1] * r_volume / 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample_rate != current_sample_rate)
|
if (sample_rate != current_sample_rate)
|
||||||
|
@ -34,7 +34,8 @@ public:
|
|||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
void SetSkipSilence(bool skip) { skip_silence = skip; }
|
void SetSkipSilence(bool skip) { skip_silence = skip; }
|
||||||
void AddStereoSamplesBE(const short* sample_data, u32 count, int sample_rate); // big endian
|
void AddStereoSamplesBE(const short* sample_data, u32 count, int sample_rate, int l_volume,
|
||||||
|
int r_volume); // big endian
|
||||||
u32 GetAudioSize() const { return audio_size; }
|
u32 GetAudioSize() const { return audio_size; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user