aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alu.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-05-03 18:47:49 -0700
committerChris Robinson <[email protected]>2020-05-03 18:47:49 -0700
commitfe7a74b09ad601a07cd403be124e5e11a2eccd14 (patch)
tree8623881819cbb9051703919619d3f5895a80c07e /alc/alu.h
parentb52fde7c0e57b4965e3b87d9cc2d98611064b7e5 (diff)
Use a helper to set an identity ambisonic pan
Diffstat (limited to 'alc/alu.h')
-rw-r--r--alc/alu.h19
1 files changed, 15 insertions, 4 deletions
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 <array>
#include <cmath>
#include <cstddef>
+#include <type_traits>
#include "AL/al.h"
@@ -134,11 +135,21 @@ void ComputePanGains(const MixParams *mix, const float*RESTRICT coeffs, const fl
const al::span<float,MAX_OUTPUT_CHANNELS> gains);
-inline std::array<float,MAX_AMBI_CHANNELS> GetAmbiIdentityRow(size_t i) noexcept
+/** Helper to set an identity/pass-through panning for ambisonic mixing (3D input). */
+template<typename T, typename I, typename F>
+auto SetAmbiPanIdentity(T iter, I count, F func) -> std::enable_if_t<std::is_integral<I>::value>
{
- std::array<float,MAX_AMBI_CHANNELS> ret{};
- ret[i] = 1.0f;
- return ret;
+ if(count < 1) return;
+
+ std::array<float,MAX_AMBI_CHANNELS> 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);
+ }
}