aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alu.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-04-06 17:45:02 -0700
committerChris Robinson <[email protected]>2023-04-06 17:45:02 -0700
commit18032785386abac02886d010c14eccea8d161796 (patch)
tree3c6964b96956c6b9f868afaf416dd547061dfdec /alc/alu.cpp
parent9062721fa84322d794e9676974ad1a3e82913b91 (diff)
Scale B-Format panning coefficients only when needed
Diffstat (limited to 'alc/alu.cpp')
-rw-r--r--alc/alu.cpp14
1 files changed, 7 insertions, 7 deletions
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]};