Skip to content

Commit e8dc336

Browse files
committed
Merge branch 'release/M20180319'
2 parents 574e622 + 2c55ea8 commit e8dc336

50 files changed

Lines changed: 4127 additions & 432 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3dti_ResourceManager/BRIR/BRIRCereal.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
// Serialization function for virtual speakers
3434
template <class Archive>
35-
void serialize(Archive & ar, VirtualSpeaker & vs)
35+
void serialize(Archive & ar, TVirtualSpeaker & vs)
3636
{
3737
ar(vs.vsPosition, vs.vsChannel);
3838
}
@@ -42,8 +42,8 @@ struct BRIRDetail_struct
4242
{
4343
uint32_t samplingRate;
4444
uint32_t irLength;
45-
//BRIRTable_Partitioned_type table;
46-
BRIRTable_type table;
45+
//TBRIRTablePartitioned table;
46+
TBRIRTable table;
4747
};
4848

4949
// Serialization function for BRIR archive
@@ -71,12 +71,6 @@ namespace BRIR {
7171
*/
7272
bool CreateFrom3dti(const std::string & input3dti, shared_ptr<Binaural::CEnvironment> environment);
7373

74-
/** \brief Loads the data in input3dtiStream as BRIR in environment.
75-
* \param [in] stream that contains the data to be loaded
76-
* \param [in] environment in which the data will be loaded.
77-
* \eh On error, an error code is reported to the error handler.
78-
* \retval Returns true on success. False otherwise
79-
*/
8074
bool CreateFrom3dtiStream(std::istream& input3dtiStream, shared_ptr<Binaural::CEnvironment> environment);
8175
}
8276

3dti_ResourceManager/BRIR/BRIRFactory.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,25 @@
2828

2929
namespace BRIR
3030
{
31+
/** \brief Returns the sample rate in Hz in the sofa file
32+
* \param [in] path of the sofa file
33+
* \eh On error, an error code is reported to the error handler.
34+
*/
3135
int GetSampleRateFromSofa(const std::string & sofafile);
3236

33-
bool CreateFromSofa(const std::string & sofafile, shared_ptr<Binaural::CEnvironment> environment);
34-
bool Create3DTIFromSofa(const std::string & sofafile, shared_ptr<Binaural::CEnvironment> environment);
37+
/** \brief Loads an BRIR from a sofa file
38+
* \param [in] path of the sofa file
39+
* \param [out] listener affected by the hrtf
40+
* \eh On error, an error code is reported to the error handler.
41+
*/
42+
bool CreateFromSofa(const std::string & sofafile, shared_ptr<Binaural::CEnvironment> environment);
43+
44+
/** \brief Loads a BRIR from SOFA file so a 3DTI file can be created later
45+
* \param [in] path of the sofa file
46+
* \param [out] listener affected by the hrtf
47+
* \eh On error, an error code is reported to the error handler. */
48+
bool Create3DTIFromSofa(const std::string & sofafile, shared_ptr<Binaural::CEnvironment> environment);
49+
3550
bool LoadBRIRTableFromSOFA(const std::string & sofafile, shared_ptr<Binaural::CEnvironment> environment);
3651
};
3752

3dti_ResourceManager/HRTF/HRTFCereal.cpp

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ namespace HRTF
4343
{
4444
cereal::PortableBinaryInputArchive archive(input3dtiStream);
4545
HRTFDetail_struct hrtf;
46-
archive(hrtf);
47-
listener->GetHRTF()->BeginSetup(hrtf.hrirLength);
46+
archive(hrtf);
47+
listener->GetHRTF()->BeginSetup(hrtf.hrirLength, hrtf.distanceOfMeasurement);
4848
listener->GetHRTF()->AddHRTFTable(std::move(hrtf.table));
4949
listener->GetHRTF()->EndSetup();
5050
SET_RESULT(RESULT_OK, "HRTF created from 3DTI stream");
@@ -75,45 +75,7 @@ namespace HRTF
7575
//////////////////////////////////////////////////////
7676

7777
#if defined (PLATFORM_ANDROID)
78-
//Binaural::CHRTF CreateFrom3dtiWithAndroidActivity(const std::string input3dti, ANativeActivity* activity, int bufferSize, int sampleRate)
79-
//{
80-
// // TO DO: Use error handler to set result
81-
82-
// // Get access to environment and asset manager
83-
// JNIEnv* env = activity->env;
84-
// AAssetManager* assetManager = activity->assetManager;
85-
//
86-
// // Open asset
87-
// AAsset* asset = AAssetManager_open(assetManager, input3dti.c_str(), AASSET_MODE_STREAMING);
88-
// if (asset == NULL)
89-
// {
90-
// DEBUG_ANDROID("Asset %s not found!", input3dti.c_str());
91-
// return CHRTF();
92-
// }
93-
//
94-
// // Write asset to file, so that we can reuse existing code
95-
// std::string dataPath(activity->internalDataPath);
96-
// std::string fileWithPath = dataPath + input3dti; // Without adding this path, we would receive a read-only error when trying to open the out file
97-
// char buf[BUFSIZ];
98-
// int nb_read = 0;
99-
// FILE* out = fopen(fileWithPath.c_str(), "wb");
100-
// if (out == NULL)
101-
// {
102-
// DEBUG_ANDROID("Error opening file to write asset: %s", strerror(errno));
103-
// return CHRTF();
104-
// }
105-
// while ((nb_read = AAsset_read(asset, buf, BUFSIZ)) > 0)
106-
// {
107-
// fwrite(buf, sizeof(char), nb_read, out);
108-
// }
109-
// fclose(out);
110-
// AAsset_close(asset);
111-
//
112-
// // Now, read HRTF from that file
113-
// return CreateFrom3dti(fileWithPath, bufferSize, sampleRate);
114-
//}
115-
116-
void CreateFrom3dtiWithAndroidActivity(const std::string input3dti, ANativeActivity* activity, shared_ptr<Binaural::CListener> listener)
78+
void CreateFrom3dtiWithAndroidActivity(const std::string input3dti, ANativeActivity* activity, shared_ptr<Binaural::CListener> listener)
11779
{
11880
// TO DO: Use error handler to set result
11981

3dti_ResourceManager/HRTF/HRTFCereal.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void serialize(Archive & ar, orientation & ori)
5656

5757
// Serialization function for pairs of HRIRs
5858
template <class Archive>
59-
void serialize(Archive & ar, HRIR_struct & hrir)
59+
void serialize(Archive & ar, THRIRStruct & hrir)
6060
{
6161
ar(hrir.leftDelay, hrir.rightDelay, hrir.leftHRIR, hrir.rightHRIR); // FIXME: should use stdint types!!
6262
}
@@ -68,23 +68,33 @@ struct HRTFDetail_struct
6868
//uint32_t elevationStep;
6969
uint32_t samplingRate;
7070
uint32_t hrirLength;
71+
float distanceOfMeasurement;
7172
T_HRTFTable table;
7273
};
7374

7475
// Serialization function for HRIR archive
7576
template <class Archive>
7677
void serialize(Archive & ar, HRTFDetail_struct & h)
77-
{
78-
//ar(h.azimuthStep, h.elevationStep, h.hrirLength, h.table);
79-
ar(h.samplingRate, h.hrirLength, h.table);
78+
{
79+
ar(h.samplingRate, h.hrirLength, h.distanceOfMeasurement, h.table);
8080
}
8181

8282
namespace HRTF {
8383

84-
int GetSampleRateFrom3dti(const std::string & input3dti); ///< Get sample rate from HRTF 3dti file
84+
/** \brief Returns the sample rate in the 3dti file whose path is input3dti
85+
* \param [in] path of the 3dti file whose sampling rate will be returned
86+
* \eh On error, an error code is reported to the error handler.
87+
* \retval the sample rate of the file whose path is input3dti */
88+
int GetSampleRateFrom3dti(const std::string & input3dti);
8589

86-
bool CreateFrom3dti(const std::string & input3dti, shared_ptr<Binaural::CListener> listener); ///< Load HRTF head from 3dti file.
87-
bool CreateFrom3dtiStream(std::istream& input3dtiStream, shared_ptr<Binaural::CListener> listener); ///< Load HRTF head from a stream opened from a 3dti file
90+
/** \brief Load HRTF head from 3dti file.
91+
* \param [in] path of the 3dti file
92+
* \param [out] listener affected by the hrtf
93+
* \eh On error, an error code is reported to the error handler. */
94+
bool CreateFrom3dti(const std::string & input3dti, shared_ptr<Binaural::CListener> listener);
95+
96+
// Load HRTF head from a stream opened from a 3dti file
97+
bool CreateFrom3dtiStream(std::istream& input3dtiStream, shared_ptr<Binaural::CListener> listener);
8898

8999
#if defined(PLATFORM_ANDROID)
90100
//Binaural::CHRTF CreateFrom3dtiWithAndroidActivity(const std::string input3dti, ANativeActivity* activity, int bufferSize, int sampleRate); ///< Create head from 3dti file in Android platform

3dti_ResourceManager/HRTF/HRTFFactory.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace HRTF
102102

103103
//////////////////////////////////////////////////////////////////////
104104

105-
bool CreateFromSofa(const std::string & sofafile, shared_ptr<Binaural::CListener> listener)
105+
bool CreateFromSofa(const std::string & sofafile, shared_ptr<Binaural::CListener> listener)
106106
{
107107
if (LoadHRTFTableFromSOFA(sofafile, listener))
108108
{
@@ -178,12 +178,13 @@ namespace HRTF
178178

179179
// Prepare HRTF
180180
const unsigned int nSamples = (unsigned int)hrir.GetNumDataSamples(); // For example: 512 samples.
181-
listener->GetHRTF()->BeginSetup(nSamples);
181+
double distance = pos[array2DIndex(0, 2, nMeasurements, dims[1])]; //We consider that every HRIR are meased at the same distance, so we get the firts one
182+
listener->GetHRTF()->BeginSetup(nSamples, distance);
182183

183184
// This outtermost loop iterates over HRIRs
184185
for (std::size_t i = 0; i < nMeasurements; i++) // or for( std::size_t i = 0; i < dims[0]; i++ ), should be the same.
185186
{
186-
HRIR_struct hrir_value;
187+
THRIRStruct hrir_value;
187188
hrir_value.leftHRIR.resize(nSamples);
188189
hrir_value.rightHRIR.resize(nSamples);
189190
double azimuth = pos[array2DIndex(i, 0, nMeasurements, dims[1])];

3dti_ResourceManager/HRTF/HRTFFactory.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,26 @@
2828
//#include <vector>
2929

3030
namespace HRTF
31-
{
31+
{
32+
/** \brief Returns the sample rate in Hz in the sofa file
33+
* \param [in] path of the sofa file
34+
* \eh On error, an error code is reported to the error handler.
35+
*/
3236
int GetSampleRateFromSofa(const std::string & sofafile);
3337

38+
/** \brief Loads an HRTF from a sofa file
39+
* \param [in] path of the sofa file
40+
* \param [out] listener affected by the hrtf
41+
* \eh On error, an error code is reported to the error handler.
42+
*/
3443
bool CreateFromSofa(const std::string & sofafile, shared_ptr<Binaural::CListener> listener);
44+
45+
/** \brief Loads an HRTF from SOFA file so a 3DTI file can be created later
46+
* \param [in] path of the sofa file
47+
* \param [out] listener affected by the hrtf
48+
* \eh On error, an error code is reported to the error handler. */
3549
bool Create3DTIFromSofa(const std::string & sofafile, shared_ptr<Binaural::CListener> listener);
50+
3651
bool LoadHRTFTableFromSOFA(const std::string & sofafile, shared_ptr<Binaural::CListener> listener);
3752

3853
//static CHRTF CreateFromListen(const std::vector<std::string> & listenFiles);

3dti_ResourceManager/ILD/ILDCereal.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ namespace ILD {
8787
{
8888
try
8989
{
90-
cereal::PortableBinaryInputArchive archive(input3dtiStream);
90+
cereal::PortableBinaryInputArchive archive( input3dtiStream );
9191
//T_ILD_HashTable ild_data;
9292
ILDDetail_struct ild_data;
93-
archive(ild_data);
93+
archive( ild_data );
9494

9595
if (tableDestiny == T_ILDTable::ILDNearFieldEffectTable) {
9696
//listener->GetILD()->AddILDNearFieldEffectTable(std::move(ild_data));
@@ -99,9 +99,8 @@ namespace ILD {
9999
else if (tableDestiny == T_ILDTable::ILDSpatializationTable)
100100
{
101101
//listener->GetILD()->AddILDSpatialziationTable(std::move(ild_data));
102-
listener->GetILD()->AddILDSpatialziationTable(std::move(ild_data.table));
103-
}
104-
102+
listener->GetILD()->AddILDSpatializationTable(std::move(ild_data.table));
103+
}
105104

106105
SET_RESULT(RESULT_OK, "ILD created from 3DTI stream");
107106
return true;

3dti_ResourceManager/ILD/ILDCereal.h

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,40 @@
3939
#endif
4040

4141
#include <BinauralSpatializer/ILD.h>
42-
#include <BinauralSpatializer/listener.h>
42+
#include <BinauralSpatializer/Listener.h>
4343
#include <cereal/archives/portable_binary.hpp>
4444
#include <cereal/types/unordered_map.hpp>
4545

46-
// Serialization function for ILD key
46+
/** \brief Serialization function for ILD key
47+
* \param [out] archive for serialization
48+
* \param [in] k key
49+
* \eh Nothing is reported to the error handler.
50+
*/
4751
template <class Archive>
4852
void serialize(Archive & ar, CILD_Key & k)
4953
{
5054
ar(k.distance, k.azimuth);
5155
}
5256

53-
// Serialization functio fo the coefficients of the biquad fiter
57+
/** \brief Serialization function for the coefficients of the biquad fiter
58+
* \param [out] archive for serialization
59+
* \param [in] coeficients of the two biquad filters used in the serialization
60+
* \eh Nothing is reported to the error handler.
61+
*/
5462
template<class Archive>
5563
void serialize(Archive & ar, T_ILD_TwoBiquadFilterCoefs & c)
5664
{
5765
ar(c.coefs);
5866
}
5967

60-
// Auxiliary struct required to archive ILD with sampling rate
68+
/** \details Auxiliary struct required to archive ILD with sampling rate */
6169
struct ILDDetail_struct
6270
{
6371
uint32_t samplingRate;
6472
T_ILD_HashTable table;
6573
};
6674

67-
// Serialization function for ILD archive
75+
/** \details Serialization function for ILD archive */
6876
template <class Archive>
6977
void serialize(Archive & ar, ILDDetail_struct & h)
7078
{
@@ -73,17 +81,39 @@ void serialize(Archive & ar, ILDDetail_struct & h)
7381

7482
namespace ILD
7583
{
84+
/** \details Serialization function for ILD archive */
7685
enum T_ILDTable { ILDNearFieldEffectTable = 0 , ILDSpatializationTable };
7786

7887
/*T_ILD_HashTable CreateFrom3dti(const std::string & input3dti); ///< Create ILD from 3dti file.
7988
T_ILD_HashTable CreateFrom3dtiStream(std::istream& input3dtiStream); ///< Create ILD from a stream opened from a 3dti file*/
8089

90+
/** \brief Returns the sample rate in the input3dti file
91+
* \param [in] 3dti file path
92+
* \eh On error, an error code is reported to the error handler.
93+
*/
8194
int GetSampleRateFrom3dti(const std::string & input3dti); ///< Get sample rate from ILD 3dti file
8295

83-
bool CreateFrom3dti_ILDNearFieldEffectTable(const std::string & input3dti, shared_ptr<Binaural::CListener> listener); ///< Create ILD from 3dti file.
84-
bool CreateFrom3dti_ILDSpatializationTable (const std::string & input3dti, shared_ptr<Binaural::CListener> listener); ///< Create ILD from 3dti file.
96+
/** \brief Create ILD from 3dti file.
97+
* \details Creates a table to process the ILD effect from the 3dti file.
98+
* \param [in] 3dti file path with the data to create the ILD table
99+
* \param [out] Listener that is affected by the ILD
100+
* \eh On error, an error code is reported to the error handler.
101+
*/
102+
bool CreateFrom3dti_ILDNearFieldEffectTable(const std::string & input3dti, shared_ptr<Binaural::CListener> listener);
103+
/** \brief Creates the spacialization table for ILD from the 3dti input file.
104+
* \param [in] 3dti file path with the data to create the spacialization table
105+
* \param [out] Listener that is affected by spacialization table
106+
* \eh On error, an error code is reported to the error handler.
107+
*/
108+
bool CreateFrom3dti_ILDSpatializationTable (const std::string & input3dti, shared_ptr<Binaural::CListener> listener );
85109

86-
bool CreateFrom3dtiStream(std::istream& input3dtiStream, shared_ptr<Binaural::CListener> listener, T_ILDTable tableDestiny); ///< Create ILD from a stream opened from a 3dti file
110+
/** \brief Create ILD from a stream opened from a 3dti file
111+
* \param [in] 3dti file path with the data to create the spacialization table
112+
* \param [out] Listener that is affected by spacialization table
113+
* \param [out] table containing the ouput data
114+
* \eh On error, an error code is reported to the error handler.
115+
*/
116+
bool CreateFrom3dtiStream(std::istream& input3dtiStream, shared_ptr<Binaural::CListener> listener, T_ILDTable tableDestiny);
87117
}
88118

89119
#endif

0 commit comments

Comments
 (0)