From cdfd9fcdb0b1892b7ec4483b74423d3bf2348cde Mon Sep 17 00:00:00 2001 From: apistol78 Date: Fri, 8 Mar 2024 15:00:52 +0100 Subject: [PATCH] Traktor: Changed container of surround sound listeners. --- code/Sound/Filters/SurroundEnvironment.cpp | 2 +- code/Sound/Filters/SurroundEnvironment.h | 10 ++++++---- code/Sound/Filters/SurroundFilter.cpp | 6 ------ code/Sound/Player/SoundPlayer.cpp | 4 ++-- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/code/Sound/Filters/SurroundEnvironment.cpp b/code/Sound/Filters/SurroundEnvironment.cpp index fb9c6adf4f..f9e04f4d63 100644 --- a/code/Sound/Filters/SurroundEnvironment.cpp +++ b/code/Sound/Filters/SurroundEnvironment.cpp @@ -46,7 +46,7 @@ void SurroundEnvironment::setFullSurround(bool fullSurround) m_fullSurround = fullSurround; } -void SurroundEnvironment::setListenerTransforms(const AlignedVector< Transform >& listenerTransforms) +void SurroundEnvironment::setListenerTransforms(const listenerTransformVector_t& listenerTransforms) { m_listenerTransforms = listenerTransforms; } diff --git a/code/Sound/Filters/SurroundEnvironment.h b/code/Sound/Filters/SurroundEnvironment.h index 37f076c0d5..61b2aa7294 100644 --- a/code/Sound/Filters/SurroundEnvironment.h +++ b/code/Sound/Filters/SurroundEnvironment.h @@ -9,7 +9,7 @@ #pragma once #include "Core/Object.h" -#include "Core/Containers/AlignedVector.h" +#include "Core/Containers/StaticVector.h" #include "Core/Math/Transform.h" // import/export mechanism. @@ -28,6 +28,8 @@ class T_DLLCLASS SurroundEnvironment : public Object T_RTTI_CLASS; public: + typedef StaticVector< Transform, 4 > listenerTransformVector_t; + explicit SurroundEnvironment( float maxDistance, float innerRadius, @@ -51,16 +53,16 @@ class T_DLLCLASS SurroundEnvironment : public Object bool getFullSurround() const { return m_fullSurround; } - void setListenerTransforms(const AlignedVector< Transform >& listenerTransforms); + void setListenerTransforms(const listenerTransformVector_t& listenerTransforms); - const AlignedVector< Transform >& getListenerTransforms() const { return m_listenerTransforms; } + const listenerTransformVector_t& getListenerTransforms() const { return m_listenerTransforms; } private: Scalar m_maxDistance; Scalar m_innerRadius; Scalar m_fallOffExponent; bool m_fullSurround; - AlignedVector< Transform > m_listenerTransforms; + listenerTransformVector_t m_listenerTransforms; }; } diff --git a/code/Sound/Filters/SurroundFilter.cpp b/code/Sound/Filters/SurroundFilter.cpp index ea2fa9fdac..6b9a272a89 100644 --- a/code/Sound/Filters/SurroundFilter.cpp +++ b/code/Sound/Filters/SurroundFilter.cpp @@ -196,8 +196,6 @@ void SurroundFilter::applyStereo(IAudioFilterInstance* instance, AudioBlock& out const Scalar speakerAngle = angleRange(Scalar(atan2f(-speakerPosition.z(), -speakerPosition.x()) + PI)); const Scalar& innerRadius = m_environment->getInnerRadius(); - - //const Scalar innerAtten = power(clamp(1.0_simd - speakerDistance / innerRadius, 0.0_simd, 1.0_simd), 1.0_simd); const Scalar distanceAtten = power(clamp(1.0_simd - (speakerDistance - innerRadius) / m_maxDistance, 0.0_simd, 1.0_simd), 1.0_simd); for (uint32_t i = 0; i < sizeof_array(c_speakersStereo); ++i) @@ -213,12 +211,8 @@ void SurroundFilter::applyStereo(IAudioFilterInstance* instance, AudioBlock& out { const Vector4 sd4 = Vector4::loadAligned(&directionalSamples[j]); const Vector4 s4 = sd4 * directionalAtten; - //s4.storeAligned(&outputSamples[j]); - (Vector4::loadAligned(&outputSamples[j]) + s4).storeAligned(&outputSamples[j]); } - - //outBlock.samples[c_speakersStereo[i].channel] = outputSamples; } } } diff --git a/code/Sound/Player/SoundPlayer.cpp b/code/Sound/Player/SoundPlayer.cpp index b75ce861a6..3c2354ff54 100644 --- a/code/Sound/Player/SoundPlayer.cpp +++ b/code/Sound/Player/SoundPlayer.cpp @@ -331,8 +331,8 @@ void SoundPlayer::update(float dT) if (m_surroundEnvironment) { - // Update listener transforms \fixme Memory allocations... - AlignedVector< Transform > listenerTransforms; + // Update listener transforms. + SurroundEnvironment::listenerTransformVector_t listenerTransforms; for (auto listener : m_listeners) listenerTransforms.push_back(listener->getTransform()); m_surroundEnvironment->setListenerTransforms(listenerTransforms);