Skip to content

Commit

Permalink
Merge branch 'release/M20180705'
Browse files Browse the repository at this point in the history
  • Loading branch information
mariacuevas committed Jul 5, 2018
2 parents e8dc336 + 65dea68 commit 673b563
Show file tree
Hide file tree
Showing 18 changed files with 1,244 additions and 297 deletions.
33 changes: 20 additions & 13 deletions 3dti_ResourceManager/BRIR/BRIRFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ namespace BRIR
{
if (LoadBRIRTableFromSOFA(sofafile, environment))
{
environment->GetBRIR()->EndSetup();
return true;
return environment->GetBRIR()->EndSetup();
}
else
{
Expand Down Expand Up @@ -275,31 +274,39 @@ namespace BRIR

double azimuth = pos[array2DIndex(i, 0, nMeasurements, dims[1])];
double elevation = pos[array2DIndex(i, 1, nMeasurements, dims[1])];
while (elevation < 0) elevation += 360; // TODO: check who should do this

while (elevation < 0) elevation += 360;
// SET VIRTUAL SPEAKER

if ((AnglesAreCloseInDegrees(azimuth, NORTH_AZIMUTH)) && (AnglesAreCloseInDegrees(elevation, 0.0f)))
{
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NORTH, Common::T_ear::LEFT, std::move(leftBRIRChannel));
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NORTH, Common::T_ear::RIGHT, std::move(rightBRIRChannel));
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NORTH, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NORTH, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
}
if ((AnglesAreCloseInDegrees(azimuth, SOUTH_AZIMUTH)) && (AnglesAreCloseInDegrees(elevation, 0.0f)))
{
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::SOUTH, Common::T_ear::LEFT, std::move(leftBRIRChannel));
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::SOUTH, Common::T_ear::RIGHT, std::move(rightBRIRChannel));
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::SOUTH, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::SOUTH, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
}
if ((AnglesAreCloseInDegrees(azimuth, WEST_AZIMUTH)) && (AnglesAreCloseInDegrees(elevation, 0.0f)))
{
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::WEST, Common::T_ear::LEFT, std::move(leftBRIRChannel));
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::WEST, Common::T_ear::RIGHT, std::move(rightBRIRChannel));
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::WEST, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::WEST, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
}
if ((AnglesAreCloseInDegrees(azimuth, EAST_AZIMUTH)) && (AnglesAreCloseInDegrees(elevation, 0.0f)))
{
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::EAST, Common::T_ear::LEFT, std::move(leftBRIRChannel));
environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::EAST, Common::T_ear::RIGHT, std::move(rightBRIRChannel));
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::EAST, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::EAST, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
}
if (AnglesAreCloseInDegrees(elevation, 90.0f))
{
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::ZENIT, Common::T_ear::LEFT, std::move(leftBRIRChannel))){return false;}
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::ZENIT, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
}
if (AnglesAreCloseInDegrees(elevation, 270.0f))
{
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NADIR, Common::T_ear::LEFT, std::move(leftBRIRChannel))) {return false;}
if(!environment->GetBRIR()->AddBRIR(VirtualSpeakerPosition::NADIR, Common::T_ear::RIGHT, std::move(rightBRIRChannel))){return false;}
}
// TO DO: consider elevations. Read zenith and nadir speakers
}
return true;
}
Expand Down
23 changes: 18 additions & 5 deletions 3dti_Toolkit/BinauralSpatializer/BRIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,26 @@ namespace Binaural {
return t_BRIR_DataBase;
}

void CBRIR::AddBRIR(VirtualSpeakerPosition vsPosition, Common::T_ear vsChannel, TImpulseResponse && newBRIR)
bool CBRIR::AddBRIR(VirtualSpeakerPosition vsPosition, Common::T_ear vsChannel, TImpulseResponse && newBRIR)
{
if (setupInProgress)
{
auto returnValue = t_BRIR_DataBase.emplace(TVirtualSpeaker(vsPosition, vsChannel), std::forward<TImpulseResponse>(newBRIR));
//Error handler
if (returnValue.second) { /*SET_RESULT(RESULT_OK, "BRIR emplaced into t_BRIR_DataBase succesfully"); */ }
else { SET_RESULT(RESULT_WARNING, "Error emplacing BRIR in t_BRIR_DataBase map"); }
if (returnValue.second) { /*SET_RESULT(RESULT_OK, "BRIR emplaced into t_BRIR_DataBase succesfully"); */
return true;
}
else { SET_RESULT(RESULT_WARNING, "Error emplacing BRIR in t_BRIR_DataBase map");
return false;
}
}
else {
SET_RESULT(RESULT_ERROR_NOTSET, "AddBRIR: It is not possible to Add a BRIR. Try to call BeginSetUp before addind a BRIR");
return false;
}
}

void CBRIR::EndSetup()
bool CBRIR::EndSetup()
{
if (!t_BRIR_DataBase.empty())
{
Expand All @@ -93,17 +98,21 @@ namespace Binaural {
#endif

//Calculate ARIR table and set the convolution buffers
ownerEnvironment->SetABIR();
if (!ownerEnvironment->SetABIR()) {
return false;
}

//Free up memory
//t_BRIR_DataBase.clear();

SET_RESULT(RESULT_OK, "BRIR Matrix completed succesfully");
return true;
}
else
{
// TO DO: Should be ASSERT?
SET_RESULT(RESULT_ERROR_NOTSET, "The t_BRIR_DataBase map has not been set");
return false;
}
}

Expand Down Expand Up @@ -141,6 +150,10 @@ namespace Binaural {
BRIRLength_frequency = 0;
bufferSize = 0;
}
bool CBRIR::IsIREmpty(const TImpulseResponse_Partitioned& in) {

return in == emptyBRIR_partitioned;
}

const TImpulseResponse_Partitioned & CBRIR::GetBRIR_Partitioned(VirtualSpeakerPosition vsPos, Common::T_ear vsChannel) const
{
Expand Down
8 changes: 6 additions & 2 deletions 3dti_Toolkit/BinauralSpatializer/BRIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ namespace Binaural
* \param [in] vsPosition Virtual Speaker position (N,S,E,W)
* \param [in] vsChannel Virtual Speaker Channel (left, right)
* \param [in] newBRIR BRIR vector value to add to the BRIR matrix
* \retval boolean to indicate if BRIR has been added correctly
* \eh On error, an error code is reported to the error handler.
Warnings may be reported to the error handler
*/
void AddBRIR(VirtualSpeakerPosition vsPosition, Common::T_ear vsChannel, TImpulseResponse && newBRIR);
bool AddBRIR(VirtualSpeakerPosition vsPosition, Common::T_ear vsChannel, TImpulseResponse && newBRIR);

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

/** \brief Stop the BRIR configuration and set the ABIR configuration
* \retval boolean to indicate if setup was successful
* \eh On success, RESULT_OK is reported to the error handler.
* On error, an error code is reported to the error handler.
*/
void EndSetup();
bool EndSetup();

/** \brief Get BRIR filter length in time domain
* \retval length int BRIR filter length in time domain
Expand Down Expand Up @@ -192,6 +194,8 @@ namespace Binaural
* \retval table raw BRIR table partitioned
*/
//const TBRIRTablePartitioned & GetRawBRIRTablePartitioned() const;

bool IsIREmpty(const TImpulseResponse_Partitioned& in);

private:

Expand Down
Loading

0 comments on commit 673b563

Please sign in to comment.