From 6dec0cfff6af58bb41aa2b58ed6262a5ff65c18b Mon Sep 17 00:00:00 2001 From: David Marcec Date: Mon, 20 Apr 2020 21:57:38 +1000 Subject: [PATCH] audio_renderer: Implement 6 channel downmixing Adds 6 channel support by downmixing to 2 channels. Nintendo does this in their DSP firmware however the downmix coefficients are different depending on the internal state. This will be updated in a later PR. --- src/audio_core/audio_renderer.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/audio_core/audio_renderer.cpp b/src/audio_core/audio_renderer.cpp index 7a9dc61d49..fae20d5d2c 100644 --- a/src/audio_core/audio_renderer.cpp +++ b/src/audio_core/audio_renderer.cpp @@ -297,6 +297,21 @@ void AudioRenderer::VoiceState::RefreshBuffer(Core::Memory::Memory& memory) { samples = std::move(new_samples); break; } + case 6: { + samples.resize((new_samples.size() / 6) * 2); + const std::size_t sample_count = samples.size() / 2; + for (std::size_t index = 0; index < sample_count; ++index) { + const auto FL = static_cast(new_samples[index * 6]); + const auto FR = static_cast(new_samples[index * 6 + 1]); + const auto FC = static_cast(new_samples[index * 6 + 2]); + const auto BL = static_cast(new_samples[index * 6 + 4]); + const auto BR = static_cast(new_samples[index * 6 + 5]); + + samples[index * 2] = static_cast(0.3694 * FL + 0.2612 * FC + 0.3694 * BL); + samples[index * 2 + 1] = static_cast(0.3694 * FR + 0.2612 * FC + 0.3694 * BR); + } + break; + } default: UNIMPLEMENTED_MSG("Unimplemented channel_count={}", info.channel_count); break;