diff options
author | Chris Robinson <[email protected]> | 2021-04-24 13:46:52 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-04-24 13:46:52 -0700 |
commit | 440ce71dcedb39e827660d0925b6cc2046c6d0f0 (patch) | |
tree | d8d5f11c71bf8d2852e176a9ec55e0cd1dc140b3 | |
parent | f10cc1e1acb11bbabd5a16b62e0d435d6b1e9337 (diff) |
Move GetHFOrderScales to a more appropriate place
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | alc/bformatdec.cpp | 33 | ||||
-rw-r--r-- | alc/bformatdec.h | 4 | ||||
-rw-r--r-- | alc/effects/convolution.cpp | 3 | ||||
-rw-r--r-- | alc/effects/reverb.cpp | 4 | ||||
-rw-r--r-- | alc/voice.cpp | 3 | ||||
-rw-r--r-- | core/ambidefs.cpp | 44 | ||||
-rw-r--r-- | core/ambidefs.h | 4 |
8 files changed, 53 insertions, 43 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b323fa12..b3bafbb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -644,6 +644,7 @@ set(COMMON_OBJS set(CORE_OBJS core/ambdec.cpp core/ambdec.h + core/ambidefs.cpp core/ambidefs.h core/bs2b.cpp core/bs2b.h diff --git a/alc/bformatdec.cpp b/alc/bformatdec.cpp index 9b2d9049..36b8d50e 100644 --- a/alc/bformatdec.cpp +++ b/alc/bformatdec.cpp @@ -21,23 +21,6 @@ namespace { -constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale{{ - 1.00000000e+00f, 1.00000000e+00f -}}; -constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale2O{{ - 7.45355990e-01f, 1.00000000e+00f, 1.00000000e+00f -}}; -constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale3O{{ - 5.89792205e-01f, 8.79693856e-01f, 1.00000000e+00f, 1.00000000e+00f -}}; - -inline auto& GetDecoderHFScales(uint order) noexcept -{ - if(order >= 3) return Ambi3DDecoderHFScale3O; - if(order == 2) return Ambi3DDecoderHFScale2O; - return Ambi3DDecoderHFScale; -} - inline auto& GetAmbiScales(AmbDecScale scaletype) noexcept { if(scaletype == AmbDecScale::FuMa) return AmbiScale::FromFuMa(); @@ -266,22 +249,6 @@ void BFormatDec::processStablize(const al::span<FloatBufferLine> OutBuffer, } -auto BFormatDec::GetHFOrderScales(const uint in_order, const uint out_order) noexcept - -> std::array<float,MaxAmbiOrder+1> -{ - std::array<float,MaxAmbiOrder+1> ret{}; - - assert(out_order >= in_order); - - const auto &target = GetDecoderHFScales(out_order); - const auto &input = GetDecoderHFScales(in_order); - - for(size_t i{0};i < in_order+1;++i) - ret[i] = input[i] / target[i]; - - return ret; -} - std::unique_ptr<BFormatDec> BFormatDec::Create(const AmbDecConf *conf, const bool allow_2band, const size_t inchans, const uint srate, const uint (&chanmap)[MAX_OUTPUT_CHANNELS], std::unique_ptr<FrontStablizer> stablizer) diff --git a/alc/bformatdec.h b/alc/bformatdec.h index 7715d364..bb39f709 100644 --- a/alc/bformatdec.h +++ b/alc/bformatdec.h @@ -58,10 +58,6 @@ public: const FloatBufferLine *InSamples, const size_t lidx, const size_t ridx, const size_t cidx, const size_t SamplesToDo); - /* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */ - static std::array<float,MaxAmbiOrder+1> GetHFOrderScales(const uint in_order, - const uint out_order) noexcept; - static std::unique_ptr<BFormatDec> Create(const AmbDecConf *conf, const bool allow_2band, const size_t inchans, const uint srate, const uint (&chanmap)[MAX_OUTPUT_CHANNELS], std::unique_ptr<FrontStablizer> stablizer); diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 0a1bd214..072bc034 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -14,7 +14,6 @@ #include "alcontext.h" #include "almalloc.h" #include "alspan.h" -#include "bformatdec.h" #include "buffer_storage.h" #include "core/ambidefs.h" #include "core/filters/splitter.h" @@ -398,7 +397,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot if(device->mAmbiOrder > mAmbiOrder) { mMix = &ConvolutionState::UpsampleMix; - const auto scales = BFormatDec::GetHFOrderScales(mAmbiOrder, device->mAmbiOrder); + const auto scales = AmbiScale::GetHFOrderScales(mAmbiOrder, device->mAmbiOrder); (*mChans)[0].mHfScale = scales[0]; for(size_t i{1};i < mChans->size();++i) (*mChans)[i].mHfScale = scales[1]; diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 1260748c..2af7472d 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -32,7 +32,7 @@ #include "alcmain.h" #include "alcontext.h" #include "alnumeric.h" -#include "bformatdec.h" +#include "core/ambidefs.h" #include "core/filters/biquad.h" #include "effectslot.h" #include "vector.h" @@ -665,7 +665,7 @@ void ReverbState::deviceUpdate(const DeviceBase *device, const Buffer&) if(device->mAmbiOrder > 1) { mMixOut = &ReverbState::MixOutAmbiUp; - mOrderScales = BFormatDec::GetHFOrderScales(1, device->mAmbiOrder); + mOrderScales = AmbiScale::GetHFOrderScales(1, device->mAmbiOrder); } else { diff --git a/alc/voice.cpp b/alc/voice.cpp index 206444d9..79c47588 100644 --- a/alc/voice.cpp +++ b/alc/voice.cpp @@ -44,7 +44,6 @@ #include "alstring.h" #include "alu.h" #include "async_event.h" -#include "bformatdec.h" #include "buffer_storage.h" #include "core/ambidefs.h" #include "core/cpu_caps.h" @@ -840,7 +839,7 @@ void Voice::prepare(DeviceBase *device) { const uint8_t *OrderFromChan{(mFmtChannels == FmtBFormat2D) ? AmbiIndex::OrderFrom2DChannel().data() : AmbiIndex::OrderFromChannel().data()}; - const auto scales = BFormatDec::GetHFOrderScales(mAmbiOrder, device->mAmbiOrder); + const auto scales = AmbiScale::GetHFOrderScales(mAmbiOrder, device->mAmbiOrder); const BandSplitter splitter{device->mXOverFreq / static_cast<float>(device->Frequency)}; for(auto &chandata : mChans) diff --git a/core/ambidefs.cpp b/core/ambidefs.cpp new file mode 100644 index 00000000..2725748e --- /dev/null +++ b/core/ambidefs.cpp @@ -0,0 +1,44 @@ + +#include "config.h" + +#include "ambidefs.h" + +#include <cassert> + + +namespace { + +constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale{{ + 1.00000000e+00f, 1.00000000e+00f +}}; +constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale2O{{ + 7.45355990e-01f, 1.00000000e+00f, 1.00000000e+00f +}}; +constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale3O{{ + 5.89792205e-01f, 8.79693856e-01f, 1.00000000e+00f, 1.00000000e+00f +}}; + +inline auto& GetDecoderHFScales(uint order) noexcept +{ + if(order >= 3) return Ambi3DDecoderHFScale3O; + if(order == 2) return Ambi3DDecoderHFScale2O; + return Ambi3DDecoderHFScale; +} + +} // namespace + +auto AmbiScale::GetHFOrderScales(const uint in_order, const uint out_order) noexcept + -> std::array<float,MaxAmbiOrder+1> +{ + std::array<float,MaxAmbiOrder+1> ret{}; + + assert(out_order >= in_order); + + const auto &target = GetDecoderHFScales(out_order); + const auto &input = GetDecoderHFScales(in_order); + + for(size_t i{0};i < in_order+1;++i) + ret[i] = input[i] / target[i]; + + return ret; +} diff --git a/core/ambidefs.h b/core/ambidefs.h index a72f7b78..22739359 100644 --- a/core/ambidefs.h +++ b/core/ambidefs.h @@ -97,6 +97,10 @@ struct AmbiScale { }}; return ret; } + + /* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */ + static std::array<float,MaxAmbiOrder+1> GetHFOrderScales(const uint in_order, + const uint out_order) noexcept; }; struct AmbiIndex { |