diff options
author | Chris Robinson <[email protected]> | 2023-10-12 05:14:00 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-10-12 05:14:00 -0700 |
commit | 8dad679dd05a8bbd9efd6b4bd2f35fb902133d28 (patch) | |
tree | 0e4be81cd8b2b8958b0354435143d5751f6ef932 /alc | |
parent | a0819843be860bff54b378eebc2277069041b373 (diff) |
Add convolution effect properties to rotate ambisonic responses
Diffstat (limited to 'alc')
-rw-r--r-- | alc/effects/convolution.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
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 |