mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 06:51:17 +01:00
DSPHLE/Zelda: use MixingBuffer type (NFC)
This commit is contained in:
parent
69aca2fbfc
commit
4f5e3674e1
@ -1233,24 +1233,24 @@ void ZeldaAudioRenderer::AddVoice(u16 voice_id)
|
||||
|
||||
struct
|
||||
{
|
||||
MixingBuffer* buffer;
|
||||
MixingBuffer& buffer;
|
||||
s16 volume;
|
||||
s16 volume_delta;
|
||||
} buffers[8] = {
|
||||
{&m_buf_front_left, quadrant_volumes[0], volume_deltas[0]},
|
||||
{&m_buf_back_left, quadrant_volumes[1], volume_deltas[1]},
|
||||
{&m_buf_front_right, quadrant_volumes[2], volume_deltas[2]},
|
||||
{&m_buf_back_right, quadrant_volumes[3], volume_deltas[3]},
|
||||
{m_buf_front_left, quadrant_volumes[0], volume_deltas[0]},
|
||||
{m_buf_back_left, quadrant_volumes[1], volume_deltas[1]},
|
||||
{m_buf_front_right, quadrant_volumes[2], volume_deltas[2]},
|
||||
{m_buf_back_right, quadrant_volumes[3], volume_deltas[3]},
|
||||
|
||||
{&m_buf_front_left_reverb, reverb_volumes[0], reverb_volume_deltas[0]},
|
||||
{&m_buf_back_left_reverb, reverb_volumes[1], reverb_volume_deltas[1]},
|
||||
{&m_buf_front_right_reverb, reverb_volumes[2], reverb_volume_deltas[2]},
|
||||
{&m_buf_back_right_reverb, reverb_volumes[3], reverb_volume_deltas[3]},
|
||||
{m_buf_front_left_reverb, reverb_volumes[0], reverb_volume_deltas[0]},
|
||||
{m_buf_back_left_reverb, reverb_volumes[1], reverb_volume_deltas[1]},
|
||||
{m_buf_front_right_reverb, reverb_volumes[2], reverb_volume_deltas[2]},
|
||||
{m_buf_back_right_reverb, reverb_volumes[3], reverb_volume_deltas[3]},
|
||||
};
|
||||
for (const auto& buffer : buffers)
|
||||
{
|
||||
AddBuffersWithVolumeRamp(buffer.buffer, input_samples, buffer.volume << 16,
|
||||
(buffer.volume_delta << 16) / (s32)buffer.buffer->size());
|
||||
(buffer.volume_delta << 16) / (s32)buffer.buffer.size());
|
||||
}
|
||||
|
||||
vpb.dolby_volume_current = vpb.dolby_volume_target;
|
||||
@ -1303,7 +1303,7 @@ void ZeldaAudioRenderer::AddVoice(u16 voice_id)
|
||||
continue;
|
||||
}
|
||||
|
||||
s32 new_volume = AddBuffersWithVolumeRamp(dst_buffer, input_samples,
|
||||
s32 new_volume = AddBuffersWithVolumeRamp(*dst_buffer, input_samples,
|
||||
vpb.channels[i].current_volume << 16, volume_step);
|
||||
vpb.channels[i].current_volume = new_volume >> 16;
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ private:
|
||||
// See Zelda.cpp for the list of possible flags.
|
||||
u32 m_flags;
|
||||
|
||||
typedef std::array<s16, 0x50> MixingBuffer;
|
||||
|
||||
// Utility functions for audio operations.
|
||||
|
||||
// Apply volume to a buffer. The volume is a fixed point integer, usually
|
||||
@ -82,16 +84,15 @@ private:
|
||||
//
|
||||
// Note: On a real GC, the stepping happens in 32 steps instead. But hey,
|
||||
// we can do better here with very low risk. Why not? :)
|
||||
template <size_t N>
|
||||
s32 AddBuffersWithVolumeRamp(std::array<s16, N>* dst, const std::array<s16, N>& src, s32 vol,
|
||||
s32 AddBuffersWithVolumeRamp(MixingBuffer& dst, const MixingBuffer& src, s32 vol,
|
||||
s32 step)
|
||||
{
|
||||
if (!vol && !step)
|
||||
return vol;
|
||||
|
||||
for (size_t i = 0; i < N; ++i)
|
||||
for (size_t i = 0; i < 0x50; ++i)
|
||||
{
|
||||
(*dst)[i] += ((vol >> 16) * src[i]) >> 16;
|
||||
dst[i] += ((vol >> 16) * src[i]) >> 16;
|
||||
vol += step;
|
||||
}
|
||||
|
||||
@ -120,7 +121,6 @@ private:
|
||||
u16 m_output_volume = 0;
|
||||
|
||||
// Mixing buffers.
|
||||
typedef std::array<s16, 0x50> MixingBuffer;
|
||||
MixingBuffer m_buf_front_left{};
|
||||
MixingBuffer m_buf_front_right{};
|
||||
MixingBuffer m_buf_back_left{};
|
||||
|
Loading…
x
Reference in New Issue
Block a user