Skip to content

Commit 96aa6b5

Browse files
committed
Merge branch 'release/M20181003'
2 parents 5be0e5d + b7f6194 commit 96aa6b5

28 files changed

+120
-107
lines changed

3dti_Toolkit/BinauralSpatializer/BRIR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ namespace Binaural {
165165
}
166166
else
167167
{
168-
SET_RESULT(RESULT_ERROR_NOTSET, "GetBRIR_Partitioned: BRIR not found. Returning an empty BRIR");
168+
SET_RESULT(RESULT_ERROR_NOTSET, "GetBRIR_Partitioned: BRIR "+ std::to_string(vsPos) +" not found. Returning an empty BRIR");
169169
return emptyBRIR_partitioned;
170170
}
171171
}

3dti_Toolkit/BinauralSpatializer/Environment.cpp

Lines changed: 69 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -483,27 +483,6 @@ namespace Binaural {
483483
{
484484
environmentABIR.Setup(ownerCore->GetAudioState().bufferSize, environmentBRIR->GetBRIRLength());
485485

486-
487-
//1. Get BRIR values for each channel
488-
TImpulseResponse_Partitioned northLeft = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::NORTH, Common::T_ear::LEFT);
489-
TImpulseResponse_Partitioned southLeft = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::SOUTH, Common::T_ear::LEFT);
490-
TImpulseResponse_Partitioned eastLeft = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::EAST, Common::T_ear::LEFT);
491-
TImpulseResponse_Partitioned westLeft = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::WEST, Common::T_ear::LEFT);
492-
TImpulseResponse_Partitioned zenitLeft = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::ZENIT, Common::T_ear::LEFT);
493-
TImpulseResponse_Partitioned nadirLeft = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::NADIR, Common::T_ear::LEFT);
494-
495-
TImpulseResponse_Partitioned northRight = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::NORTH, Common::T_ear::RIGHT);
496-
TImpulseResponse_Partitioned southRight = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::SOUTH, Common::T_ear::RIGHT);
497-
TImpulseResponse_Partitioned eastRight = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::EAST, Common::T_ear::RIGHT);
498-
TImpulseResponse_Partitioned westRight = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::WEST, Common::T_ear::RIGHT);
499-
TImpulseResponse_Partitioned zenitRight = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::ZENIT, Common::T_ear::RIGHT);
500-
TImpulseResponse_Partitioned nadirRight = environmentBRIR->GetBRIR_Partitioned(VirtualSpeakerPosition::NADIR, Common::T_ear::RIGHT);
501-
502-
long s = northLeft.size();
503-
504-
TImpulseResponse_Partitioned newAIR_W_left, newAIR_X_left, newAIR_Y_left, newAIR_Z_left;
505-
TImpulseResponse_Partitioned newAIR_W_right, newAIR_X_right, newAIR_Y_right, newAIR_Z_right;
506-
507486
switch (reverberationOrder) {
508487
case TReverberationOrder::BIDIMENSIONAL:
509488
return CalculateABIRPartitionedBidimensional();
@@ -626,19 +605,19 @@ namespace Binaural {
626605
continue;
627606
}
628607

608+
//Check if the source is in the same position as the listener head. If yes, do not apply spatialization to this source
609+
if (eachSource->distanceToListener < ownerCore->GetListener()->GetHeadRadius())
610+
{
611+
continue;
612+
}
613+
629614
// Get azimuth, elevation and distance from listener to each source
630615
// We precompute everything, to minimize per-sample computations.
631616
Common::CTransform sourceTransform = eachSource->GetSourceTransform();
632617
Common::CVector3 vectorToSource = ownerCore->GetListener()->GetListenerTransform().GetVectorTo(sourceTransform);
633-
float sourceAzimuth = vectorToSource.GetAzimuthRadians();
634-
float sourceElevation = vectorToSource.GetElevationRadians();
618+
635619
float sourceDistance = vectorToSource.GetDistance();
636-
float cosAzimuth = std::cos(sourceAzimuth);
637-
float sinAzimuth = std::sin(sourceAzimuth);
638-
float sinElevation = std::sin(sourceElevation);
639-
float cosElevation = std::cos(sourceElevation);
640-
float cosAcosE = cosAzimuth * cosElevation;
641-
float sinAcosE = sinAzimuth * cosElevation;
620+
642621
CMonoBuffer<float> sourceBuffer = eachSource->GetBuffer();
643622
//ASSERT(sourceBuffer.size() > 0, RESULT_ERROR_NOTSET, "Attempt to process virtual ambisonics reverb without previously feeding audio source buffers", "");
644623

@@ -746,7 +725,7 @@ namespace Binaural {
746725
CMonoBuffer<float> temp_OutputBlockLeft(ouputBuffer_temp.begin() + halfsize, ouputBuffer_temp.end());
747726
mixerOutput_left = std::move(temp_OutputBlockLeft); //To use in C++11
748727

749-
//Right channel
728+
//Right channel
750729
ouputBuffer_temp.clear();
751730
Common::CFprocessor::CalculateIFFT(mixerOutput_right_FFT, ouputBuffer_temp);
752731
//We are left only with the final half of the result
@@ -755,16 +734,11 @@ namespace Binaural {
755734
mixerOutput_right = std::move(temp_OutputBlockRight); //To use in C++11
756735
#endif
757736

758-
//////////////////////////////////////////////
759-
// Mix of chabbels decoded after convolution
760-
//////////////////////////////////////////////
761-
762-
//Interlace TODO Use the method in bufferClass??
763-
for (int i = 0; i < mixerOutput_left.size(); i++) {
764-
outBufferLeft.push_back(mixerOutput_left[i]);
765-
outBufferRight.push_back(mixerOutput_right[i]);
766-
}
767-
737+
//////////////////////////////////////////////
738+
// Move channels to output buffers
739+
//////////////////////////////////////////////
740+
outBufferLeft = std::move(mixerOutput_left); //To use in C++11
741+
outBufferRight = std::move(mixerOutput_right); //To use in C++11
768742

769743
#ifdef USE_PROFILER_Environment
770744
PROFILER3DTI.RelativeSampleEnd(dsEnvInvFFT);
@@ -787,6 +761,7 @@ namespace Binaural {
787761
WATCH(WV_ENVIRONMENT_OUTPUT_LEFT, outBufferLeft, CMonoBuffer<float>);
788762
WATCH(WV_ENVIRONMENT_OUTPUT_RIGHT, outBufferRight, CMonoBuffer<float>);
789763
}
764+
790765
void CEnvironment::ProcessVirtualAmbisonicReverbBidimensional(CMonoBuffer<float> & outBufferLeft, CMonoBuffer<float> & outBufferRight)
791766
{
792767
CMonoBuffer<float> w, x, y; // B-Format data
@@ -844,15 +819,23 @@ namespace Binaural {
844819
// We precompute everything, to minimize per-sample computations.
845820
Common::CTransform sourceTransform = eachSource->GetSourceTransform();
846821
Common::CVector3 vectorToSource = ownerCore->GetListener()->GetListenerTransform().GetVectorTo(sourceTransform);
847-
float sourceAzimuth = vectorToSource.GetAzimuthRadians();
848822
float sourceElevation = vectorToSource.GetElevationRadians();
849-
float sourceDistance = vectorToSource.GetDistance();
850-
float cosAzimuth = std::cos(sourceAzimuth);
851-
float sinAzimuth = std::sin(sourceAzimuth);
852823
float sinElevationAbs = std::fabs(std::sin(sourceElevation)); // TEST: adding power to W channel to compensate for the lack of Z channel
853824
float cosElevation = std::cos(sourceElevation);
854-
float cosAcosE = cosAzimuth * cosElevation;
855-
float sinAcosE = sinAzimuth * cosElevation;
825+
826+
float cosAcosE = 0.0f;
827+
float sinAcosE = 0.0f;
828+
if (!Common::CMagnitudes::AreSame(0.0f, cosElevation, EPSILON))
829+
{
830+
float sourceAzimuth = vectorToSource.GetAzimuthRadians();
831+
float cosAzimuth = std::cos(sourceAzimuth);
832+
float sinAzimuth = std::sin(sourceAzimuth);
833+
cosAcosE = cosAzimuth * cosElevation;
834+
sinAcosE = sinAzimuth * cosElevation;
835+
}
836+
837+
float sourceDistance = vectorToSource.GetDistance();
838+
856839
CMonoBuffer<float> sourceBuffer = eachSource->GetBuffer();
857840
//ASSERT(sourceBuffer.size() > 0, RESULT_ERROR_NOTSET, "Attempt to process virtual ambisonics reverb without previously feeding audio source buffers", "");
858841

@@ -975,16 +958,11 @@ namespace Binaural {
975958
mixerOutput_right = std::move(temp_OutputBlockRight); //To use in C++11
976959
#endif
977960

978-
//////////////////////////////////////////////
979-
// Mix of channels decoded after convolution
980-
//////////////////////////////////////////////
981-
982-
//Interlace TODO Use the method in bufferClass??
983-
for (int i = 0; i < mixerOutput_left.size(); i++) {
984-
outBufferLeft.push_back(mixerOutput_left[i]);
985-
outBufferRight.push_back(mixerOutput_right[i]);
986-
}
987-
961+
//////////////////////////////////////////////
962+
// Move channels to output buffers
963+
//////////////////////////////////////////////
964+
outBufferLeft = std::move(mixerOutput_left); //To use in C++11
965+
outBufferRight = std::move(mixerOutput_right); //To use in C++11
988966

989967
#ifdef USE_PROFILER_Environment
990968
PROFILER3DTI.RelativeSampleEnd(dsEnvInvFFT);
@@ -1007,6 +985,7 @@ namespace Binaural {
1007985
WATCH(WV_ENVIRONMENT_OUTPUT_LEFT, outBufferLeft, CMonoBuffer<float>);
1008986
WATCH(WV_ENVIRONMENT_OUTPUT_RIGHT, outBufferRight, CMonoBuffer<float>);
1009987
}
988+
1010989
void CEnvironment::ProcessVirtualAmbisonicReverbThreedimensional(CMonoBuffer<float> & outBufferLeft, CMonoBuffer<float> & outBufferRight)
1011990
{
1012991
CMonoBuffer<float> w, x, y, z; // B-Format data
@@ -1054,21 +1033,36 @@ namespace Binaural {
10541033
{
10551034
SET_RESULT(RESULT_WARNING, "Attempt to do reverb process without updating source buffer; please call to SetBuffer before ProcessVirtualAmbisonicReverb.");
10561035
continue;
1057-
}
1036+
}
1037+
1038+
//Check if the source is in the same position as the listener head. If yes, do not apply spatialization to this source
1039+
if (eachSource->distanceToListener < ownerCore->GetListener()->GetHeadRadius())
1040+
{
1041+
continue;
1042+
}
10581043

10591044
// Get azimuth, elevation and distance from listener to each source
10601045
// We precompute everything, to minimize per-sample computations.
10611046
Common::CTransform sourceTransform = eachSource->GetSourceTransform();
10621047
Common::CVector3 vectorToSource = ownerCore->GetListener()->GetListenerTransform().GetVectorTo(sourceTransform);
1063-
float sourceAzimuth = vectorToSource.GetAzimuthRadians();
1048+
10641049
float sourceElevation = vectorToSource.GetElevationRadians();
1065-
float sourceDistance = vectorToSource.GetDistance();
1066-
float cosAzimuth = std::cos(sourceAzimuth);
1067-
float sinAzimuth = std::sin(sourceAzimuth);
10681050
float sinElevation = std::sin(sourceElevation);
10691051
float cosElevation = std::cos(sourceElevation);
1070-
float cosAcosE = cosAzimuth * cosElevation;
1071-
float sinAcosE = sinAzimuth * cosElevation;
1052+
1053+
float cosAcosE = 0.0f;
1054+
float sinAcosE = 0.0f;
1055+
if (!Common::CMagnitudes::AreSame(0.0f, cosElevation, EPSILON))
1056+
{
1057+
float sourceAzimuth = vectorToSource.GetAzimuthRadians();
1058+
float cosAzimuth = std::cos(sourceAzimuth);
1059+
float sinAzimuth = std::sin(sourceAzimuth);
1060+
cosAcosE = cosAzimuth * cosElevation;
1061+
sinAcosE = sinAzimuth * cosElevation;
1062+
}
1063+
1064+
float sourceDistance = vectorToSource.GetDistance();
1065+
10721066
CMonoBuffer<float> sourceBuffer = eachSource->GetBuffer();
10731067
//ASSERT(sourceBuffer.size() > 0, RESULT_ERROR_NOTSET, "Attempt to process virtual ambisonics reverb without previously feeding audio source buffers", "");
10741068

@@ -1194,16 +1188,11 @@ namespace Binaural {
11941188
mixerOutput_right = std::move(temp_OutputBlockRight); //To use in C++11
11951189
#endif
11961190

1197-
//////////////////////////////////////////////
1198-
// Mix of chabbels decoded after convolution
1199-
//////////////////////////////////////////////
1200-
1201-
//Interlace TODO Use the method in bufferClass??
1202-
for (int i = 0; i < mixerOutput_left.size(); i++) {
1203-
outBufferLeft.push_back(mixerOutput_left[i]);
1204-
outBufferRight.push_back(mixerOutput_right[i]);
1205-
}
1206-
1191+
//////////////////////////////////////////////
1192+
// Move channels to output buffers
1193+
//////////////////////////////////////////////
1194+
outBufferLeft = std::move(mixerOutput_left); //To use in C++11
1195+
outBufferRight = std::move(mixerOutput_right); //To use in C++11
12071196

12081197
#ifdef USE_PROFILER_Environment
12091198
PROFILER3DTI.RelativeSampleEnd(dsEnvInvFFT);
@@ -1235,6 +1224,13 @@ namespace Binaural {
12351224
SET_RESULT(RESULT_ERROR_NOTINITIALIZED, "Data is not ready to be processed");
12361225
return;
12371226
}
1227+
1228+
// Check outbuffers size
1229+
if (outBufferLeft.size() != 0 || outBufferRight.size() != 0) {
1230+
outBufferLeft.clear();
1231+
outBufferRight.clear();
1232+
SET_RESULT(RESULT_ERROR_BADSIZE, "outBufferLeft and outBufferRight were expected to be empty, they will be cleared. CEnvironment::ProcessVirtualAmbisonicReverb");
1233+
}
12381234

12391235
// This would crash if there are no sources created. Rather than reporting error, do nothing
12401236
if (ownerCore->audioSources.size() == 0)

3dti_Toolkit/BinauralSpatializer/SingleSourceDSP.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,6 @@ namespace Binaural {
254254
PROFILER3DTI.RelativeSampleStart(dsSSDSPTransform);
255255
#endif
256256

257-
float angleToForwardAxisRadians = vectorToListener.GetAngleToForwardAxisRadians(); //angle that this vector keeps with the forward axis
258-
259257
// WATCHER
260258
WATCH(TWatcherVariable::WV_ANECHOIC_AZIMUTH_LEFT, leftAzimuth, float);
261259
WATCH(TWatcherVariable::WV_ANECHOIC_AZIMUTH_RIGHT, rightAzimuth, float);
@@ -302,6 +300,7 @@ namespace Binaural {
302300
}
303301

304302
// Apply the directionality to simulate the hearing aid device
303+
float angleToForwardAxisRadians = vectorToListener.GetAngleToForwardAxisRadians(); //angle that this vector keeps with the forward axis
305304
ProcessDirectionality(outLeftBuffer, outRightBuffer, angleToForwardAxisRadians);
306305

307306
readyForAnechoic = false; // Mark the buffer as already used for anechoic process
@@ -730,27 +729,31 @@ namespace Binaural {
730729
const Common::CVector3 CSingleSourceDSP::GetSphereProjectionPosition(Common::CVector3 vectorToEar, Common::CVector3 earLocalPosition, float distance) const
731730
{
732731
//get axis according to the defined convention
733-
float leftAxis = vectorToEar.GetAxis(LEFT_AXIS);
732+
float rightAxis = vectorToEar.GetAxis(RIGHT_AXIS);
734733
float forwardAxis = vectorToEar.GetAxis(FORWARD_AXIS);
735734
float upAxis = vectorToEar.GetAxis(UP_AXIS);
736735
// Error handler:
737-
if ((leftAxis == 0.0f) && (forwardAxis == 0.0f) && (upAxis == 0.0f)) {
736+
if ((rightAxis == 0.0f) && (forwardAxis == 0.0f) && (upAxis == 0.0f)) {
738737
ASSERT(false, RESULT_ERROR_DIVBYZERO, "Axes are not correctly set. Please, check axis conventions", "Azimuth computed from vector succesfully");
739738
}
739+
//get ear position in right axis
740+
float earRightAxis = earLocalPosition.GetAxis(RIGHT_AXIS);
741+
740742
//Resolve a quadratic equation to get lambda, which is the parameter that define the line between the ear and the sphere, passing by the source
741743
// (x_sphere, y_sphere, z_sphere) = earLocalPosition + lambda * vectorToEar
742744
// x_sphere^2 + y_sphere^2 + z_sphere^2 = distance^2
743745

744-
float a = forwardAxis * forwardAxis + leftAxis * leftAxis + upAxis * upAxis;
745-
float b = 2.0f * earLocalPosition.y * leftAxis;
746-
float c = earLocalPosition.y * earLocalPosition.y - distance * distance;
746+
747+
float a = forwardAxis * forwardAxis + rightAxis * rightAxis + upAxis * upAxis;
748+
float b = 2.0f * earRightAxis * rightAxis;
749+
float c = earRightAxis * earRightAxis - distance * distance;
747750
float lambda = (-b + sqrt(b*b - 4.0f* a*c))* 0.5f * (1 / a);
748751

749752
Common::CVector3 cartesianposition;
750753

751-
cartesianposition.x = lambda * forwardAxis;
752-
cartesianposition.y = earLocalPosition.y + lambda * leftAxis;
753-
cartesianposition.z = lambda * upAxis;
754+
cartesianposition.SetAxis(FORWARD_AXIS, lambda * forwardAxis);
755+
cartesianposition.SetAxis(RIGHT_AXIS, (earRightAxis + lambda * rightAxis));
756+
cartesianposition.SetAxis(UP_AXIS, lambda * upAxis);
754757

755758
return cartesianposition;
756759
}

3dti_Toolkit/Common/Buffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ namespace Common {
457457

458458
// Start with a clean buffer
459459
this->clear();
460+
this->reserve(2 * left.size());
460461

461462
// Interlace channels
462463
for (int sample = 0; sample < left.size(); sample++)

3dti_Toolkit/Common/Conventions.h

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@
2727
/*! \file */
2828

2929
// Axis convention pre-sets
30-
// Your app should define one of the axis convention presets, as a preprocessor directive:
31-
// _3DTI_AXIS_CONVENTION_DEFAULT, // Same as _3DTI_AXIS_CONVENTION_OPENFRAMEWORK
30+
// Your project could define, as global preprocessor difinitions, one of the axis convention presets, as a preprocessor directive:
3231
// _3DTI_AXIS_CONVENTION_OPENFRAMEWORK, // Openframeworks test apps
3332
// _3DTI_AXIS_CONVENTION_UNITY, // Unity 5.x
34-
// _3DTI_AXIS_CONVENTION_AMBISONIC // Ambisonics
33+
//
34+
// If no convention is defined, the Ambisonic convention is used:
35+
// UP_AXIS is Z
36+
// RIGHT_AXIS is -Y
37+
// FORWARD_AXIS is X
3538

3639

3740
// Spherical angle convention pre-sets
@@ -59,40 +62,34 @@ typedef int TCircularMotion; ///< Type definition for defining spherical motion
5962

6063
/////////////////////////////////////////////////////////////////////
6164
// PRESET IMPLEMENTATION
62-
/*
63-
#if defined(_3DTI_AXIS_CONVENTION_DEFAULT)
64-
#define _3DTI_AXIS_CONVENTION_OPENFRAMEWORK
65-
#endif
66-
*/
6765

68-
#if defined (_3DTI_AXIS_CONVENTION_BINAURAL_TEST_APP )
6966

70-
#define UP_AXIS AXIS_Z ///< In the test app Z is the UP direction
71-
#define RIGHT_AXIS AXIS_MINUS_Y ///< In the test app -Y is the RIGHT direction
72-
#define FORWARD_AXIS AXIS_X ///< In the test app X is the FORWARD direction
73-
#define LEFT_AXIS AXIS_Y ///< In the test app Y is the LEFT direction
67+
#if defined(_3DTI_AXIS_CONVENTION_BINAURAL_TEST_APP)
68+
69+
#define UP_AXIS AXIS_Z ///< In the test app Z is the UP direction
70+
#define RIGHT_AXIS AXIS_MINUS_Y ///< In the test app -Y is the RIGHT direction
71+
#define FORWARD_AXIS AXIS_X ///< In the test app X is the FORWARD direction
7472

7573
#elif defined(_3DTI_AXIS_CONVENTION_UNITY)
7674
#define UP_AXIS AXIS_Y ///< In Unity 5.x, Y is the UP direction
7775
#define RIGHT_AXIS AXIS_X ///< In Unity 5.x, X is the RIGHT direction
7876
#define FORWARD_AXIS AXIS_Z ///< In Unity 5.x, Z is the FORWARD direction
79-
#define LEFT_AXIS AXIS_MINUS_X ///< In Unity 5.x, X is the RIGHT direction
80-
8177

8278
#elif defined ( _3DTI_AXIS_CONVENTION_OPENFRAMEWORK )
8379
#define UP_AXIS AXIS_MINUS_Z ///< In Open Framework test apps, -Z is the UP direction
8480
#define RIGHT_AXIS AXIS_X ///< In Open Framework test apps, X is the RIGHT direction
8581
#define FORWARD_AXIS AXIS_MINUS_Y ///< In Open Framework test apps, -Y is the FORWARD direction
8682

87-
#elif defined( _3DTI_AXIS_CONVENTION_AMBISONIC )
83+
#elif defined(_3DTI_AXIS_CONVENTION_WEBAUDIOAPI)
84+
#define UP_AXIS AXIS_Y ///< In the Web Audio API, Y is the UP direction
85+
#define RIGHT_AXIS AXIS_X ///< In the Web Audio API, X is the RIGHT direction
86+
#define FORWARD_AXIS AXIS_MINUS_Z ///< In the Web Audio API, -Z is the FORWARD direction
87+
88+
#else
8889
#define UP_AXIS AXIS_Z ///< In Ambisonics, Z is the UP direction
8990
#define RIGHT_AXIS AXIS_MINUS_Y ///< In Ambisonics, -Y is the RIGHT direction
9091
#define FORWARD_AXIS AXIS_X ///< In Ambisonics, X is the FORWARD direction
9192

92-
#elif defined(_3DTI_AXIS_CONVENTION_WEBAUDIOAPI)
93-
#define UP_AXIS AXIS_Y ///< In the Web Audio API, Y is the UP direction
94-
#define RIGHT_AXIS AXIS_X ///< In the Web Audio API, X is the RIGHT direction
95-
#define FORWARD_AXIS AXIS_MINUS_Z ///< In the Web Audio API, -Z is the FORWARD direction
9693
#endif
9794

9895
/////////////////////////////////////////////////////////////////////

3dti_Toolkit/Common/Vector3.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ namespace Common {
215215
float rightAxis = GetAxis(RIGHT_AXIS);
216216
float forwardAxis = GetAxis(FORWARD_AXIS);
217217
if ((rightAxis == 0.0f) && (forwardAxis == 0.0f))
218-
ASSERT(false, RESULT_ERROR_DIVBYZERO, "Axes are not correctly set. Please, check axis conventions", "Azimuth computed from vector succesfully");
218+
{
219+
SET_RESULT(RESULT_ERROR_INVALID_PARAM, "Azimuth cannot be computed for a (0,0,z) vector. 0.0 is returned");
220+
return 0.0f;
221+
}
219222

220223
// front=0; left=-90; right=90
221224
//return atan2(*rightAxis, *forwardAxis);
@@ -314,8 +317,6 @@ namespace Common {
314317
SET_RESULT(RESULT_ERROR_DIVBYZERO, "Distance from source to listener is zero");
315318
return 0.0f;
316319
}
317-
//else
318-
// SET_RESULT(RESULT_OK, "Interaural azimuth computed from vector succesfully"); // No more possible errors.
319320

320321
float f = GetAxis(FORWARD_AXIS);
321322
float angle = SafeAcos(f / distance);

0 commit comments

Comments
 (0)