From faec0c78eba89e8fa3417e775e438926c837a83e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 7 May 2020 02:13:11 -0700 Subject: [PATCH] Allow declaring internal dual-band decoders --- alc/panning.cpp | 57 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/alc/panning.cpp b/alc/panning.cpp index e82d4b91..9ed2ff65 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -332,39 +332,73 @@ auto GetAmbiLayout(AmbiLayout layouttype) noexcept -> const std::array; +enum DecoderMode : bool { + SingleBand = false, + DualBand = true +}; + +template +struct DecoderConfig; template -struct DecoderConfig { +struct DecoderConfig { ALuint mOrder; std::array mChannels; std::array mOrderGain; std::array mCoeffs; }; +template +struct DecoderConfig { + ALuint mOrder; + std::array mChannels; + std::array mOrderGain; + std::array mCoeffs; + std::array mOrderGainLF; + std::array mCoeffsLF; +}; + template<> -struct DecoderConfig<0> { +struct DecoderConfig { ALuint mOrder; al::span mChannels; al::span mOrderGain; al::span mCoeffs; + al::span mOrderGainLF; + al::span mCoeffsLF; template - DecoderConfig& operator=(const DecoderConfig &rhs) noexcept + DecoderConfig& operator=(const DecoderConfig &rhs) noexcept { mOrder = rhs.mOrder; mChannels = rhs.mChannels; mOrderGain = rhs.mOrderGain; mCoeffs = rhs.mCoeffs; + mOrderGainLF = {}; + mCoeffsLF = {}; + return *this; + } + + template + DecoderConfig& operator=(const DecoderConfig &rhs) noexcept + { + mOrder = rhs.mOrder; + mChannels = rhs.mChannels; + mOrderGain = rhs.mOrderGain; + mCoeffs = rhs.mCoeffs; + mOrderGainLF = rhs.mOrderGainLF; + mCoeffsLF = rhs.mCoeffsLF; return *this; } }; +using DecoderView = DecoderConfig; -constexpr DecoderConfig<1> MonoConfig{ +constexpr DecoderConfig MonoConfig{ 0, {{FrontCenter}}, {{1.0f}}, {{ {{1.0f}} }} }; -constexpr DecoderConfig<2> StereoConfig{ +constexpr DecoderConfig StereoConfig{ 1, {{FrontLeft, FrontRight}}, {{1.0f, 1.0f}}, {{ @@ -372,7 +406,7 @@ constexpr DecoderConfig<2> StereoConfig{ {{5.00000000e-1f, -2.88675135e-1f, 5.52305643e-2f}}, }} }; -constexpr DecoderConfig<4> QuadConfig{ +constexpr DecoderConfig QuadConfig{ 2, {{BackLeft, FrontLeft, FrontRight, BackRight}}, {{1.15470054e+0f, 1.00000000e+0f, 5.77350269e-1f}}, {{ @@ -382,7 +416,7 @@ constexpr DecoderConfig<4> QuadConfig{ {{2.50000000e-1f, -2.04124145e-1f, -2.04124145e-1f, 1.29099445e-1f, 0.00000000e+0f}}, }} }; -constexpr DecoderConfig<4> X51Config{ +constexpr DecoderConfig X51Config{ 2, {{SideLeft, FrontLeft, FrontRight, SideRight}}, {{1.0f, 1.0f, 1.0f}}, {{ @@ -392,7 +426,7 @@ constexpr DecoderConfig<4> X51Config{ {{3.33000782e-1f, -1.89084803e-1f, -2.00042375e-1f, 2.12307769e-2f, -1.14579885e-2f}}, }} }; -constexpr DecoderConfig<4> X51RearConfig{ +constexpr DecoderConfig X51RearConfig{ 2, {{BackLeft, FrontLeft, FrontRight, BackRight}}, {{1.0f, 1.0f, 1.0f}}, {{ @@ -402,7 +436,7 @@ constexpr DecoderConfig<4> X51RearConfig{ {{3.33000782e-1f, -1.89084803e-1f, -2.00042375e-1f, 2.12307769e-2f, -1.14579885e-2f}}, }} }; -constexpr DecoderConfig<5> X61Config{ +constexpr DecoderConfig X61Config{ 2, {{SideLeft, FrontLeft, FrontRight, SideRight, BackCenter}}, {{1.0f, 1.0f, 1.0f}}, {{ @@ -413,7 +447,7 @@ constexpr DecoderConfig<5> X61Config{ {{2.50001688e-1f, 0.00000000e+0f, -2.50000094e-1f, 0.00000000e+0f, 6.05133395e-2f}}, }} }; -constexpr DecoderConfig<6> X71Config{ +constexpr DecoderConfig X71Config{ 3, {{BackLeft, SideLeft, FrontLeft, FrontRight, SideRight, BackRight}}, {{1.22474487e+0f, 1.13151672e+0f, 8.66025404e-1f, 4.68689571e-1f}}, {{ @@ -428,8 +462,7 @@ constexpr DecoderConfig<6> X71Config{ void InitPanning(ALCdevice *device) { - DecoderConfig<0> decoder{}; - + DecoderView decoder{}; switch(device->FmtChans) { case DevFmtMono: