From 18032785386abac02886d010c14eccea8d161796 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 6 Apr 2023 17:45:02 -0700 Subject: Scale B-Format panning coefficients only when needed --- alc/alu.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'alc') diff --git a/alc/alu.cpp b/alc/alu.cpp index a5230580..e9ad68b1 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -862,16 +862,10 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con }; auto&& scales = GetAmbiScales(voice->mAmbiScaling); auto coeffs = calc_coeffs(Device->mRenderMode); - /* Scale the panned W signal based on the coverage (full coverage means - * no panned signal). Scale the panned W signal according to channel - * scaling. - */ - std::transform(coeffs.begin(), coeffs.end(), coeffs.begin(), - [scale=(1.0f-coverage)*scales[0]](const float c){ return c * scale; }); if(!(coverage > 0.0f)) { - ComputePanGains(&Device->Dry, coeffs.data(), DryGain.Base, + ComputePanGains(&Device->Dry, coeffs.data(), DryGain.Base*scales[0], voice->mChans[0].mDryParams.Gains.Target); for(uint i{0};i < NumSends;i++) { @@ -962,6 +956,12 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con GetAmbi2DLayout(voice->mAmbiLayout).data() : GetAmbiLayout(voice->mAmbiLayout).data()}; + /* Scale the panned W signal inversely to coverage (full coverage + * means no panned signal), and according to the channel scaling. + */ + std::for_each(coeffs.begin(), coeffs.end(), + [scale=(1.0f-coverage)*scales[0]](float &coeff) noexcept { coeff *= scale; }); + for(size_t c{0};c < num_channels;c++) { const size_t acn{index_map[c]}; -- cgit v1.2.3