summaryrefslogtreecommitdiffstats
path: root/src/audio_core/audio_renderer.cpp
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2021-07-08 18:09:21 +0200
committerGitHub <noreply@github.com>2021-07-08 18:09:21 +0200
commit91a4a924b13b50f5b86fac732575c22e40d21891 (patch)
tree6511301bcbebc5b9ed6c9a1c64b19b3a8b2179dd /src/audio_core/audio_renderer.cpp
parentMerge pull request #6567 from Kelebek1/Audio2 (diff)
parentaudio_core: Preserve front channel volume after 6 to 2 downmix (diff)
downloadyuzu-91a4a924b13b50f5b86fac732575c22e40d21891.tar
yuzu-91a4a924b13b50f5b86fac732575c22e40d21891.tar.gz
yuzu-91a4a924b13b50f5b86fac732575c22e40d21891.tar.bz2
yuzu-91a4a924b13b50f5b86fac732575c22e40d21891.tar.lz
yuzu-91a4a924b13b50f5b86fac732575c22e40d21891.tar.xz
yuzu-91a4a924b13b50f5b86fac732575c22e40d21891.tar.zst
yuzu-91a4a924b13b50f5b86fac732575c22e40d21891.zip
Diffstat (limited to 'src/audio_core/audio_renderer.cpp')
-rw-r--r--src/audio_core/audio_renderer.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/audio_core/audio_renderer.cpp b/src/audio_core/audio_renderer.cpp
index ccd5ca6cc..7dba739b4 100644
--- a/src/audio_core/audio_renderer.cpp
+++ b/src/audio_core/audio_renderer.cpp
@@ -29,10 +29,9 @@ namespace {
(static_cast<float>(r_channel) * r_mix_amount)));
}
-[[nodiscard]] static constexpr std::tuple<s16, s16> Mix6To2(s16 fl_channel, s16 fr_channel,
- s16 fc_channel,
- [[maybe_unused]] s16 lf_channel,
- s16 bl_channel, s16 br_channel) {
+[[maybe_unused, nodiscard]] static constexpr std::tuple<s16, s16> Mix6To2(
+ s16 fl_channel, s16 fr_channel, s16 fc_channel, [[maybe_unused]] s16 lf_channel, s16 bl_channel,
+ s16 br_channel) {
// Front channels are mixed 36.94%, Center channels are mixed to be 26.12% & the back channels
// are mixed to be 36.94%
@@ -57,11 +56,11 @@ namespace {
const std::array<float_le, 4>& coeff) {
const auto left =
static_cast<float>(fl_channel) * coeff[0] + static_cast<float>(fc_channel) * coeff[1] +
- static_cast<float>(lf_channel) * coeff[2] + static_cast<float>(bl_channel) * coeff[0];
+ static_cast<float>(lf_channel) * coeff[2] + static_cast<float>(bl_channel) * coeff[3];
const auto right =
static_cast<float>(fr_channel) * coeff[0] + static_cast<float>(fc_channel) * coeff[1] +
- static_cast<float>(lf_channel) * coeff[2] + static_cast<float>(br_channel) * coeff[0];
+ static_cast<float>(lf_channel) * coeff[2] + static_cast<float>(br_channel) * coeff[3];
return {ClampToS16(static_cast<s32>(left)), ClampToS16(static_cast<s32>(right))};
}
@@ -241,7 +240,7 @@ void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) {
const auto channel_count = buffer_offsets.size();
const auto& final_mix = mix_context.GetFinalMixInfo();
const auto& in_params = final_mix.GetInParams();
- std::vector<s32*> mix_buffers(channel_count);
+ std::vector<std::span<s32>> mix_buffers(channel_count);
for (std::size_t i = 0; i < channel_count; i++) {
mix_buffers[i] =
command_generator.GetMixBuffer(in_params.buffer_offset + buffer_offsets[i]);
@@ -294,18 +293,11 @@ void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) {
buffer[i * stream_channel_count + 0] = Mix2To1(fl_sample, fr_sample);
} else if (stream_channel_count == 2) {
// Mix all channels into 2 channels
- if (sink_context.HasDownMixingCoefficients()) {
- const auto [left, right] = Mix6To2WithCoefficients(
- fl_sample, fr_sample, fc_sample, lf_sample, bl_sample, br_sample,
- sink_context.GetDownmixCoefficients());
- buffer[i * stream_channel_count + 0] = left;
- buffer[i * stream_channel_count + 1] = right;
- } else {
- const auto [left, right] = Mix6To2(fl_sample, fr_sample, fc_sample,
- lf_sample, bl_sample, br_sample);
- buffer[i * stream_channel_count + 0] = left;
- buffer[i * stream_channel_count + 1] = right;
- }
+ const auto [left, right] = Mix6To2WithCoefficients(
+ fl_sample, fr_sample, fc_sample, lf_sample, bl_sample, br_sample,
+ sink_context.GetDownmixCoefficients());
+ buffer[i * stream_channel_count + 0] = left;
+ buffer[i * stream_channel_count + 1] = right;
} else if (stream_channel_count == 6) {
// Pass through
buffer[i * stream_channel_count + 0] = fl_sample;