From 7cbf3ba2e2bab5c3aecb001e1d387c89309dbec4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 4 May 2023 11:39:13 -0700 Subject: Use std::byte instead of a custom al::byte --- core/effects/base.h | 1 - 1 file changed, 1 deletion(-) (limited to 'core/effects/base.h') diff --git a/core/effects/base.h b/core/effects/base.h index 4ee19f37..b02d33b7 100644 --- a/core/effects/base.h +++ b/core/effects/base.h @@ -3,7 +3,6 @@ #include -#include "albyte.h" #include "almalloc.h" #include "alspan.h" #include "atomic.h" -- cgit v1.2.3 From 8dad679dd05a8bbd9efd6b4bd2f35fb902133d28 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 12 Oct 2023 05:14:00 -0700 Subject: Add convolution effect properties to rotate ambisonic responses --- al/effects/convolution.cpp | 2 ++ alc/effects/convolution.cpp | 26 +++++++++++++++++++++++--- core/effects/base.h | 6 ++++++ 3 files changed, 31 insertions(+), 3 deletions(-) (limited to 'core/effects/base.h') diff --git a/al/effects/convolution.cpp b/al/effects/convolution.cpp index 8e850fd3..a9426ce4 100644 --- a/al/effects/convolution.cpp +++ b/al/effects/convolution.cpp @@ -83,6 +83,8 @@ void Convolution_getParamfv(const EffectProps *props, ALenum param, float *vals) EffectProps genDefaultProps() noexcept { EffectProps props{}; + props.Convolution.OrientAt = {0.0f, 0.0f, -1.0f}; + props.Convolution.OrientUp = {0.0f, 1.0f, 0.0f}; return props; } diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index f3a7dbe3..fe681745 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -431,7 +431,7 @@ void ConvolutionState::deviceUpdate(const DeviceBase *device, const BufferStorag void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot, - const EffectProps* /*props*/, const EffectTarget target) + const EffectProps *props, const EffectTarget target) { /* NOTE: Stereo and Rear are slightly different from normal mixing (as * defined in alu.cpp). These are 45 degrees from center, rather than the @@ -516,6 +516,23 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot } mOutTarget = target.Main->Buffer; + alu::Vector N{props->Convolution.OrientAt[0], props->Convolution.OrientAt[1], + props->Convolution.OrientAt[2], 0.0f}; + N.normalize(); + alu::Vector V{props->Convolution.OrientUp[0], props->Convolution.OrientUp[1], + props->Convolution.OrientUp[2], 0.0f}; + V.normalize(); + /* Build and normalize right-vector */ + alu::Vector U{N.cross_product(V)}; + U.normalize(); + + const float mixmatrix[4][4]{ + {1.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, U[0], -U[1], U[2]}, + {0.0f, -V[0], V[1], -V[2]}, + {0.0f, -N[0], N[1], -N[2]}, + }; + const auto scales = GetAmbiScales(mAmbiScaling); const uint8_t *index_map{Is2DAmbisonic(mChannels) ? GetAmbi2DLayout(mAmbiLayout).data() : @@ -525,9 +542,12 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot for(size_t c{0u};c < mChans->size();++c) { const size_t acn{index_map[c]}; - coeffs[acn] = scales[acn]; + const float scale{scales[acn]}; + + for(size_t x{0};x < 4;++x) + coeffs[x] = mixmatrix[acn][x] * scale; + ComputePanGains(target.Main, coeffs.data(), gain, (*mChans)[c].Target); - coeffs[acn] = 0.0f; } } else diff --git a/core/effects/base.h b/core/effects/base.h index b02d33b7..83df7cf0 100644 --- a/core/effects/base.h +++ b/core/effects/base.h @@ -1,6 +1,7 @@ #ifndef CORE_EFFECTS_BASE_H #define CORE_EFFECTS_BASE_H +#include #include #include "almalloc.h" @@ -165,6 +166,11 @@ union EffectProps { struct { float Gain; } Dedicated; + + struct { + std::array OrientAt; + std::array OrientUp; + } Convolution; }; -- cgit v1.2.3