Skip to content

Commit

Permalink
Traktor: Changed container of surround sound listeners.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Mar 8, 2024
1 parent 441f7fb commit cdfd9fc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion code/Sound/Filters/SurroundEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 6 additions & 4 deletions code/Sound/Filters/SurroundEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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;
};

}
6 changes: 0 additions & 6 deletions code/Sound/Filters/SurroundFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions code/Sound/Player/SoundPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cdfd9fc

Please sign in to comment.