From fe7a74b09ad601a07cd403be124e5e11a2eccd14 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 3 May 2020 18:47:49 -0700 Subject: Use a helper to set an identity ambisonic pan --- alc/alu.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'alc/alu.h') diff --git a/alc/alu.h b/alc/alu.h index f565d1f5..6099559d 100644 --- a/alc/alu.h +++ b/alc/alu.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "AL/al.h" @@ -134,11 +135,21 @@ void ComputePanGains(const MixParams *mix, const float*RESTRICT coeffs, const fl const al::span gains); -inline std::array GetAmbiIdentityRow(size_t i) noexcept +/** Helper to set an identity/pass-through panning for ambisonic mixing (3D input). */ +template +auto SetAmbiPanIdentity(T iter, I count, F func) -> std::enable_if_t::value> { - std::array ret{}; - ret[i] = 1.0f; - return ret; + if(count < 1) return; + + std::array coeffs{{1.0f}}; + func(*iter, coeffs); + ++iter; + for(I i{1};i < count;++i,++iter) + { + coeffs[i-1] = 0.0f; + coeffs[i ] = 1.0f; + func(*iter, coeffs); + } } -- cgit v1.2.3