Skip to content

Commit 673b563

Browse files
committed
Merge branch 'release/M20180705'
2 parents e8dc336 + 65dea68 commit 673b563

18 files changed

Lines changed: 1244 additions & 297 deletions

File tree

3dti_ResourceManager/BRIR/BRIRFactory.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ namespace BRIR
161161
{
162162
if (LoadBRIRTableFromSOFA(sofafile, environment))
163163
{
164-
environment->GetBRIR()->EndSetup();
165-
return true;
164+
return environment->GetBRIR()->EndSetup();
166165
}
167166
else
168167
{
@@ -275,31 +274,39 @@ namespace BRIR
275274

276275
double azimuth = pos[array2DIndex(i, 0, nMeasurements, dims[1])];
277276
double elevation = pos[array2DIndex(i, 1, nMeasurements, dims[1])];
278-
while (elevation < 0) elevation += 360; // TODO: check who should do this
279-
277+
while (elevation < 0) elevation += 360;
280278
// SET VIRTUAL SPEAKER
281279

282280
if ((AnglesAreCloseInDegrees(azimuth, NORTH_AZIMUTH)) && (AnglesAreCloseInDegrees(elevation, 0.0f)))
283281
{
284-
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NORTH, Common::T_ear::LEFT, std::move(leftBRIRChannel));
285-
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NORTH, Common::T_ear::RIGHT, std::move(rightBRIRChannel));
282+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NORTH, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
283+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NORTH, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
286284
}
287285
if ((AnglesAreCloseInDegrees(azimuth, SOUTH_AZIMUTH)) && (AnglesAreCloseInDegrees(elevation, 0.0f)))
288286
{
289-
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::SOUTH, Common::T_ear::LEFT, std::move(leftBRIRChannel));
290-
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::SOUTH, Common::T_ear::RIGHT, std::move(rightBRIRChannel));
287+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::SOUTH, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
288+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::SOUTH, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
291289
}
292290
if ((AnglesAreCloseInDegrees(azimuth, WEST_AZIMUTH)) && (AnglesAreCloseInDegrees(elevation, 0.0f)))
293291
{
294-
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::WEST, Common::T_ear::LEFT, std::move(leftBRIRChannel));
295-
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::WEST, Common::T_ear::RIGHT, std::move(rightBRIRChannel));
292+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::WEST, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
293+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::WEST, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
296294
}
297295
if ((AnglesAreCloseInDegrees(azimuth, EAST_AZIMUTH)) && (AnglesAreCloseInDegrees(elevation, 0.0f)))
298296
{
299-
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::EAST, Common::T_ear::LEFT, std::move(leftBRIRChannel));
300-
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::EAST, Common::T_ear::RIGHT, std::move(rightBRIRChannel));
297+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::EAST, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
298+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::EAST, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
299+
}
300+
if (AnglesAreCloseInDegrees(elevation, 90.0f))
301+
{
302+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::ZENIT, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
303+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::ZENIT, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
304+
}
305+
if (AnglesAreCloseInDegrees(elevation, 270.0f))
306+
{
307+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NADIR, Common::T_ear::LEFT, std::move(leftBRIRChannel))) {return false;}
308+
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NADIR, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
301309
}
302-
// TO DO: consider elevations. Read zenith and nadir speakers
303310
}
304311
return true;
305312
}

3dti_Toolkit/BinauralSpatializer/BRIR.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,26 @@ namespace Binaural {
6464
return t_BRIR_DataBase;
6565
}
6666

67-
void CBRIR::AddBRIR(VirtualSpeakerPosition vsPosition, Common::T_ear vsChannel, TImpulseResponse && newBRIR)
67+
bool CBRIR::AddBRIR(VirtualSpeakerPosition vsPosition, Common::T_ear vsChannel, TImpulseResponse && newBRIR)
6868
{
6969
if (setupInProgress)
7070
{
7171
auto returnValue = t_BRIR_DataBase.emplace(TVirtualSpeaker(vsPosition, vsChannel), std::forward<TImpulseResponse>(newBRIR));
7272
//Error handler
73-
if (returnValue.second) { /*SET_RESULT(RESULT_OK, "BRIR emplaced into t_BRIR_DataBase succesfully"); */ }
74-
else { SET_RESULT(RESULT_WARNING, "Error emplacing BRIR in t_BRIR_DataBase map"); }
73+
if (returnValue.second) { /*SET_RESULT(RESULT_OK, "BRIR emplaced into t_BRIR_DataBase succesfully"); */
74+
return true;
75+
}
76+
else { SET_RESULT(RESULT_WARNING, "Error emplacing BRIR in t_BRIR_DataBase map");
77+
return false;
78+
}
7579
}
7680
else {
7781
SET_RESULT(RESULT_ERROR_NOTSET, "AddBRIR: It is not possible to Add a BRIR. Try to call BeginSetUp before addind a BRIR");
82+
return false;
7883
}
7984
}
8085

81-
void CBRIR::EndSetup()
86+
bool CBRIR::EndSetup()
8287
{
8388
if (!t_BRIR_DataBase.empty())
8489
{
@@ -93,17 +98,21 @@ namespace Binaural {
9398
#endif
9499

95100
//Calculate ARIR table and set the convolution buffers
96-
ownerEnvironment->SetABIR();
101+
if (!ownerEnvironment->SetABIR()) {
102+
return false;
103+
}
97104

98105
//Free up memory
99106
//t_BRIR_DataBase.clear();
100107

101108
SET_RESULT(RESULT_OK, "BRIR Matrix completed succesfully");
109+
return true;
102110
}
103111
else
104112
{
105113
// TO DO: Should be ASSERT?
106114
SET_RESULT(RESULT_ERROR_NOTSET, "The t_BRIR_DataBase map has not been set");
115+
return false;
107116
}
108117
}
109118

@@ -141,6 +150,10 @@ namespace Binaural {
141150
BRIRLength_frequency = 0;
142151
bufferSize = 0;
143152
}
153+
bool CBRIR::IsIREmpty(const TImpulseResponse_Partitioned& in) {
154+
155+
return in == emptyBRIR_partitioned;
156+
}
144157

145158
const TImpulseResponse_Partitioned & CBRIR::GetBRIR_Partitioned(VirtualSpeakerPosition vsPos, Common::T_ear vsChannel) const
146159
{

3dti_Toolkit/BinauralSpatializer/BRIR.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ namespace Binaural
115115
* \param [in] vsPosition Virtual Speaker position (N,S,E,W)
116116
* \param [in] vsChannel Virtual Speaker Channel (left, right)
117117
* \param [in] newBRIR BRIR vector value to add to the BRIR matrix
118+
* \retval boolean to indicate if BRIR has been added correctly
118119
* \eh On error, an error code is reported to the error handler.
119120
Warnings may be reported to the error handler
120121
*/
121-
void AddBRIR(VirtualSpeakerPosition vsPosition, Common::T_ear vsChannel, TImpulseResponse && newBRIR);
122+
bool AddBRIR(VirtualSpeakerPosition vsPosition, Common::T_ear vsChannel, TImpulseResponse && newBRIR);
122123

123124
/** \brief Set the full BRIR matrix.
124125
* \param [in] newTable full table with all BRIR data
@@ -127,10 +128,11 @@ namespace Binaural
127128
void AddBRIRTable(TBRIRTable && newTable);
128129

129130
/** \brief Stop the BRIR configuration and set the ABIR configuration
131+
* \retval boolean to indicate if setup was successful
130132
* \eh On success, RESULT_OK is reported to the error handler.
131133
* On error, an error code is reported to the error handler.
132134
*/
133-
void EndSetup();
135+
bool EndSetup();
134136

135137
/** \brief Get BRIR filter length in time domain
136138
* \retval length int BRIR filter length in time domain
@@ -192,6 +194,8 @@ namespace Binaural
192194
* \retval table raw BRIR table partitioned
193195
*/
194196
//const TBRIRTablePartitioned & GetRawBRIRTablePartitioned() const;
197+
198+
bool IsIREmpty(const TImpulseResponse_Partitioned& in);
195199

196200
private:
197201

0 commit comments

Comments
 (0)