Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
I
ITAPropagationModels
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
ITAPropagationModels
Commits
6b616db9
Commit
6b616db9
authored
Jan 24, 2019
by
Armin Erraji
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'remotes/origin/develop' into ma_2018/erraji
parents
9e9fe320
6fcefdfc
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
630 additions
and
335 deletions
+630
-335
CMakeLists.txt
CMakeLists.txt
+3
-0
benchmarks/DiffractionModelsBenchmark.cpp
benchmarks/DiffractionModelsBenchmark.cpp
+1
-1
include/ITAPropagationModels/Base.h
include/ITAPropagationModels/Base.h
+6
-1
include/ITAPropagationModels/FilterEngine.h
include/ITAPropagationModels/FilterEngine.h
+80
-62
include/ITAPropagationModels/Maekawa.h
include/ITAPropagationModels/Maekawa.h
+3
-3
include/ITAPropagationModels/Svensson.h
include/ITAPropagationModels/Svensson.h
+1
-1
include/ITAPropagationModels/UTD.h
include/ITAPropagationModels/UTD.h
+4
-3
include/ITAPropagationModels/Utils.h
include/ITAPropagationModels/Utils.h
+39
-0
src/ITAPropagationModels/FilterEngine.cpp
src/ITAPropagationModels/FilterEngine.cpp
+225
-256
src/ITAPropagationModels/Utils.cpp
src/ITAPropagationModels/Utils.cpp
+48
-0
tests/CMakeLists.txt
tests/CMakeLists.txt
+2
-0
tests/FilterEngine/FilterEngineTest.cpp
tests/FilterEngine/FilterEngineTest.cpp
+5
-6
tests/ReceiverDirectivityTest/CMakeLists.txt
tests/ReceiverDirectivityTest/CMakeLists.txt
+27
-0
tests/ReceiverDirectivityTest/ITA_Artificial_Head_5x5_44kHz_128.v17.ir.daff
...ctivityTest/ITA_Artificial_Head_5x5_44kHz_128.v17.ir.daff
+0
-0
tests/ReceiverDirectivityTest/ReceiverDirectivityTest.cpp
tests/ReceiverDirectivityTest/ReceiverDirectivityTest.cpp
+78
-0
tests/ReceiverDirectivityTest/ReceiverDirectivityTest.m
tests/ReceiverDirectivityTest/ReceiverDirectivityTest.m
+6
-0
tests/SourceDirectivityTest/CMakeLists.txt
tests/SourceDirectivityTest/CMakeLists.txt
+26
-0
tests/SourceDirectivityTest/SourceDirectivityTest.cpp
tests/SourceDirectivityTest/SourceDirectivityTest.cpp
+65
-0
tests/SourceDirectivityTest/SourceDirectivityTest.m
tests/SourceDirectivityTest/SourceDirectivityTest.m
+9
-0
tests/SourceDirectivityTest/Trumpet1.v17.ms.daff
tests/SourceDirectivityTest/Trumpet1.v17.ms.daff
+0
-0
tests/Svensson/SvenssonTest.cpp
tests/Svensson/SvenssonTest.cpp
+1
-1
tests/UTD/UTDTest.cpp
tests/UTD/UTDTest.cpp
+1
-1
No files found.
CMakeLists.txt
View file @
6b616db9
...
...
@@ -7,6 +7,7 @@ include( VistaCommon )
# dependencies
vista_use_package
(
ITABase REQUIRED FIND_DEPENDENCIES
)
vista_use_package
(
ITAFFT REQUIRED FIND_DEPENDENCIES
)
vista_use_package
(
ITAGeo REQUIRED FIND_DEPENDENCIES
)
...
...
@@ -22,12 +23,14 @@ set( ITAPropagationModelsHeader
"include/ITAPropagationModels/Maekawa.h"
"include/ITAPropagationModels/Svensson.h"
"include/ITAPropagationModels/UTD.h"
"include/ITAPropagationModels/Utils.h"
)
set
(
ITAPropagationModelsSources
"src/ITAPropagationModels/FilterEngine.cpp"
"src/ITAPropagationModels/Maekawa.cpp"
"src/ITAPropagationModels/Svensson.cpp"
"src/ITAPropagationModels/UTD.cpp"
"src/ITAPropagationModels/Utils.cpp"
)
...
...
benchmarks/DiffractionModelsBenchmark.cpp
View file @
6b616db9
...
...
@@ -47,7 +47,7 @@
using
namespace
std
;
using
namespace
ITAPropagationModels
;
float
g_fSpeedOfSound
=
ITAConstants
::
SPEED_OF_SOUND_F
;
float
g_fSpeedOfSound
=
ITAConstants
::
DEFAULT_
SPEED_OF_SOUND_F
;
float
g_fSampleRate
=
44.1e3
;
int
g_iFilterLength
=
64
;
...
...
include/ITAPropagationModels/Base.h
View file @
6b616db9
...
...
@@ -21,7 +21,12 @@
namespace
ITAPropagationModels
{
enum
DiffractionModels
{
MAEKAWA_DETOUR_LAW
=
1
,
UNIFORM_THEORY_OF_DIFFRACTION
,
BIOT_TOLSTOY_MEDWIN_SVENSSON
,
};
}
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_BASE
include/ITAPropagationModels/FilterEngine.h
View file @
6b616db9
...
...
@@ -19,13 +19,14 @@
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER_ENGINE
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER_ENGINE
// ITAPropagationModel includes
// ITAPropagationModel includes
#include "Base.h"
#include "Definitions.h"
// ITA includes
#include <ITAGeo/Base.h>
#include <ITAGeo/Material//Manager.h>
#include <ITAGeo/Material/Manager.h>
#include <ITAGeo/Directivity/Manager.h>
#include <ITAHDFTSpectra.h>
#include <ITAHDFTSpectrum.h>
...
...
@@ -36,7 +37,7 @@
namespace
ITAPropagationModels
{
using
namespace
std
;
//! Transfer function filter generator for propagation paths
/**
* Generates transfer functions in the frequency-domain that
...
...
@@ -47,7 +48,50 @@ namespace ITAPropagationModels
class
ITA_PROPAGATION_MODELS_API
CFilterEngine
{
public:
CFilterEngine
();
//!< Material resolutions structure (used if not determined by material)
struct
TMaterialResolution
{
ITAGeo
::
Material
::
IMaterial
::
Type
iReflection
=
ITAGeo
::
Material
::
IMaterial
::
SCALAR
;
//!< Default reflection component resolution
ITAGeo
::
Material
::
IMaterial
::
Type
iDiffraction
=
ITAGeo
::
Material
::
IMaterial
::
THIRD_OCTAVE
;
//!< Default diffraction component resolution
ITAGeo
::
Material
::
IMaterial
::
Type
iTransmission
=
ITAGeo
::
Material
::
IMaterial
::
THIRD_OCTAVE
;
//!< Default transmission component resolution
}
oMaterialResolution
;
//! Static environment state description
struct
TStaticEnvironmentState
{
double
dHumidity
=
ITAConstants
::
DEFAULT_HUMIDITY_D
;
double
dTemperature
=
ITAConstants
::
DEFAULT_TEMPERATURE_D
;
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_SPEED_OF_SOUND_F
;
}
oEnvironmentState
;
//!< Environment state
enum
EAtmoshpericAbsorption
{
NONE
=
-
1
,
ISO9613
,
};
enum
EGeometricalSpreading
{
PLANE_WAVE
=
1
,
CYLINDRIC_WAVE
,
SPHERICAL_WAVE
,
};
//! Propagation model configuration description
struct
TPropagationModelConfiguration
{
int
iAtmosphericAbsorption
=
EAtmoshpericAbsorption
::
ISO9613
;
int
iDiffractionModel
=
DiffractionModels
::
MAEKAWA_DETOUR_LAW
;
int
iGeometricalSpreading
=
SPHERICAL_WAVE
;
}
oPropagationModelConfiguration
;
//!< Propagation model configuration
//! Standard constructor for a filter engine
CFilterEngine
(
const
ITAGeo
::
ECoordinateSystemConvention
iConvention
=
ITAGeo
::
ECoordinateSystemConvention
::
ISO
);
//! Default destructor of a filter engine
~
CFilterEngine
();
//! Returns number of sensor channels
...
...
@@ -56,96 +100,70 @@ namespace ITAPropagationModels
*
* @note Throws ITAException if sensors have different number of channels
*/
static
int
GetNumSensorChannels
(
const
ITAGeo
::
CPropagationPathList
&
oPathList
);
static
int
GetNumSensorChannels
(
const
ITAGeo
::
CPropagationPathList
&
oPathList
);
//! Checks if the sensor is the same anchor for all propagation paths
/**
* @param[in] oPathList Propagation path list
* @return True, if path list shares the same sensor
*
* @note Throws ITAException if sensors have different number of channels
*/
static
bool
HasSameSensorAnchor
(
const
ITAGeo
::
CPropagationPathList
&
oPathList
);
//! Applies all acoustic models like reflection diffraction models
void
ApplyAcousticModels
(
ITAGeo
::
CPropagationPathList
&
oPathList
);
//!Applies diffraction models
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
*/
void
ApplyDiffractionModel
(
ITAGeo
::
CPropagationPathList
&
oPathList
,
int
iModel
=
-
1
);
//!Applies reflection models
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
*/
void
ApplyReflectionModel
(
ITAGeo
::
CPropagationPathList
&
oPathList
,
int
iModel
=
-
1
);
static
bool
ValidateSameSensor
(
const
ITAGeo
::
CPropagationPathList
&
oPathList
);
//!Applies emitter models
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
*/
void
ApplyEmitterModel
(
ITAGeo
::
CPropagationPathList
&
oPathList
,
int
iModel
=
-
1
);
//!Applies sensor models
//! Checks if the sensor is the same anchor for all propagation paths
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
* @param[in] oPathList Propagation path list
* @return True, if path list shares the same emitter
*
* @note Throws ITAException if sensors have different number of channels
*/
void
ApplySensorModel
(
ITAGeo
::
CPropagationPathList
&
oPathList
,
int
iModel
=
-
1
);
void
ApplyTransmissionModel
(
ITAGeo
::
CPropagationPathList
&
oPathList
,
int
iModel
=
-
1
);
// @todo
static
bool
ValidateSameEmitter
(
const
ITAGeo
::
CPropagationPathList
&
oPathList
);
//! Generate multi-channel propagation path (for multi-channel receiver directivity)
/**
* @todo AER
*/
void
Generate
(
const
ITAGeo
::
CPropagationPathList
&
oPathList
,
ITABase
::
CHDFTSpectra
&
oFilter
,
bool
*
pbDFTDegreeTooSmall
=
NULL
);
void
Generate
(
const
ITAGeo
::
CPropagationPathList
&
oPathList
,
ITABase
::
CHDFTSpectra
&
oFilter
,
bool
*
pbDFTDegreeTooSmall
=
NULL
);
//! Generate single propagation path (for multi-channel receiver directivity)
inline
void
Generate
(
const
ITAGeo
::
CPropagationPath
&
oPath
,
ITABase
::
CHDFTSpectra
&
oFilter
,
bool
*
pbDFTDegreeTooSmall
=
NULL
)
{
ITAGeo
::
CPropagationPathList
oPathList
;
oPathList
.
push_back
(
oPath
);
Generate
(
oPathList
,
oFilter
,
pbDFTDegreeTooSmall
);
};
//! Generate single-channel propagation path (for single-channel receiver directivity)
inline
void
Generate
(
const
ITAGeo
::
CPropagationPathList
&
oPathList
,
ITABase
::
CHDFTSpectrum
&
oFilter
,
bool
*
pbDFTDegreeTooSmall
=
NULL
)
inline
void
Generate
(
const
ITAGeo
::
CPropagationPathList
&
oPathList
,
ITABase
::
CHDFTSpectrum
&
oFilter
,
bool
*
pbDFTDegreeTooSmall
=
NULL
)
{
const
vector
<
ITABase
::
CHDFTSpectrum
*
>
vpSpectra
=
{
&
oFilter
};
ITABase
::
CHDFTSpectra
oTF
(
vpSpectra
);
Generate
(
oPathList
,
oTF
,
pbDFTDegreeTooSmall
);
ITABase
::
CHDFTSpectra
oTF
(
vpSpectra
);
Generate
(
oPathList
,
oTF
,
pbDFTDegreeTooSmall
);
};
//! Sets a connection to the material manager
void
SetMaterialManager
(
const
ITAGeo
::
CMaterialManager
*
pMaterialManager
);
void
SetMaterialManager
(
std
::
shared_ptr
<
const
ITAGeo
::
Material
::
IManager
>
pMaterialManager
);
// Returns pointer to material manager or null
const
ITAGeo
::
CMaterialManager
*
GetMaterialManager
()
const
;
std
::
shared_ptr
<
const
ITAGeo
::
Material
::
IManager
>
GetMaterialManager
()
const
;
//! Sets a connection to the diffraction manager
void
SetDirectivityManager
(
std
::
shared_ptr
<
const
ITAGeo
::
Directivity
::
IManager
>
pDirectivityManager
);
// Returns pointer to directivity manager or null
std
::
shared_ptr
<
const
ITAGeo
::
Directivity
::
IManager
>
GetDirectivityManager
()
const
;
private:
unique_ptr
<
ITABase
::
CHDFTSpectra
>
m_pAccumulatedSpectra
;
//!< Gathered propagation paths from list
unique_ptr
<
ITABase
::
CHDFTSpectra
>
m_pTempPropPathSpectra
;
//!< Single prop-path spectra
static
struct
m_DefaultValues
//!< Default values
{
static
const
int
iReflectionModel
=
ITAGeo
::
IAcousticMaterial
::
SCALAR
;
static
const
int
iDiffractionModel
=
ITAGeo
::
IAcousticMaterial
::
THIRD_OCTAVE
;
static
const
int
iEmitterModel
=
ITAGeo
::
IAcousticMaterial
::
SCALAR
;
static
const
int
iSensorModel
=
ITAGeo
::
IAcousticMaterial
::
SCALAR
;
};
std
::
shared_ptr
<
const
ITAGeo
::
Material
::
IManager
>
m_pMaterialManager
;
std
::
shared_ptr
<
const
ITAGeo
::
Directivity
::
IManager
>
m_pDirectivityManager
;
const
ITAGeo
::
CMaterialManager
*
m_pMaterialManager
;
const
double
m_dHumidity
=
80.0
;
const
double
m_dTemperature
=
20.0
;
const
float
m_fSpeedOfSound
=
ITAConstants
::
SPEED_OF_SOUND_F
;
static
struct
m_DefaultDiffractionModel
//!< Default values for diffractions
{
int
iModel
=
1
;
};
ITAGeo
::
ECoordinateSystemConvention
m_iCoordinateSystemConvention
;
};
}
...
...
include/ITAPropagationModels/Maekawa.h
View file @
6b616db9
...
...
@@ -117,7 +117,7 @@ namespace ITAPropagationModels
* @param[in] fSpeedOfSound Speed of sound [m/s]
*
*/
double
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFilterCoefficient
(
const
double
dPropagationLengthFreeField
,
const
double
dPropagationLengthOverApex
,
const
float
fFrequency
,
const
float
fSpeedOfSound
=
ITAConstants
::
SPEED_OF_SOUND_F
);
double
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFilterCoefficient
(
const
double
dPropagationLengthFreeField
,
const
double
dPropagationLengthOverApex
,
const
float
fFrequency
,
const
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_
SPEED_OF_SOUND_F
);
//! Calculate diffraction factor based on the Maekawa detour method
/**
...
...
@@ -131,7 +131,7 @@ namespace ITAPropagationModels
* @param[in] fSpeedOfSound Speed of sound [m/s]
*
*/
double
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFactor
(
const
double
dPropagationLengthFreeField
,
const
double
dPropagationLengthOverApex
,
const
float
fFrequency
,
const
float
fSpeedOfSound
=
ITAConstants
::
SPEED_OF_SOUND_F
);
double
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFactor
(
const
double
dPropagationLengthFreeField
,
const
double
dPropagationLengthOverApex
,
const
float
fFrequency
,
const
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_
SPEED_OF_SOUND_F
);
//! Calculate diffraction filter (frequency domain) based on the Maekawa detour method
...
...
@@ -145,7 +145,7 @@ namespace ITAPropagationModels
* @param[in] fSpeedOfSound Speed of sound [m/s]
*
*/
void
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFilter
(
const
double
dPropagationLengthFreeField
,
const
double
dPropagationLengthOverApex
,
ITABase
::
CHDFTSpectrum
&
oTransferFunction
,
const
float
fSpeedOfSound
=
ITAConstants
::
SPEED_OF_SOUND_F
);
void
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFilter
(
const
double
dPropagationLengthFreeField
,
const
double
dPropagationLengthOverApex
,
ITABase
::
CHDFTSpectrum
&
oTransferFunction
,
const
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_
SPEED_OF_SOUND_F
);
}
}
...
...
include/ITAPropagationModels/Svensson.h
View file @
6b616db9
...
...
@@ -49,7 +49,7 @@ namespace ITAPropagationModels
*
* @sa GetMinimumWavefrontDelayTime, GetMaximumWavefrontDelayTime
*/
ITA_PROPAGATION_MODELS_API
bool
CalculateDiffractionIR
(
const
VistaVector3D
&
v3SourcePos
,
const
VistaVector3D
&
v3TargetPos
,
std
::
shared_ptr
<
const
ITAGeo
::
CITADiffractionWedgeApertureBase
>
pApex
,
ITABase
::
CFiniteImpulseResponse
&
oEffectiveDiffractionIR
,
const
float
fSpeedOfSound
=
ITAConstants
::
SPEED_OF_SOUND_F
);
ITA_PROPAGATION_MODELS_API
bool
CalculateDiffractionIR
(
const
VistaVector3D
&
v3SourcePos
,
const
VistaVector3D
&
v3TargetPos
,
std
::
shared_ptr
<
const
ITAGeo
::
CITADiffractionWedgeApertureBase
>
pApex
,
ITABase
::
CFiniteImpulseResponse
&
oEffectiveDiffractionIR
,
const
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_SPEED_OF_SOUND_F
);
}
}
...
...
include/ITAPropagationModels/UTD.h
View file @
6b616db9
...
...
@@ -23,6 +23,7 @@
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_UTD
#include "Definitions.h"
#include "Base.h"
// Vista includes
#include <VistaBase/VistaVector3D.h>
...
...
@@ -66,7 +67,7 @@ namespace ITAPropagationModels
* @param[out] cfFactor Complex-valued diffraction coefficient ( D( n, k,\rho, r, \phi_i, \alpha_i, \alpha_d ) )
* @param[in] iMethod Approximation algorithm
*/
bool
ITA_PROPAGATION_MODELS_API
CalculateDiffractionCoefficient
(
const
VistaVector3D
&
v3SourcePos
,
const
VistaVector3D
&
v3TargetPos
,
std
::
shared_ptr
<
const
ITAGeo
::
CITADiffractionWedgeApertureBase
>
pApex
,
const
float
fFrequency
,
complex
<
float
>&
cfCoeff
,
const
int
iMethod
=
UTD_APPROX_KAWAI_KOUYOUMJIAN
,
const
float
fSpeedOfSound
=
ITAConstants
::
SPEED_OF_SOUND_F
);
bool
ITA_PROPAGATION_MODELS_API
CalculateDiffractionCoefficient
(
const
VistaVector3D
&
v3SourcePos
,
const
VistaVector3D
&
v3TargetPos
,
std
::
shared_ptr
<
const
ITAGeo
::
CITADiffractionWedgeApertureBase
>
pApex
,
const
float
fFrequency
,
complex
<
float
>&
cfCoeff
,
const
int
iMethod
=
UTD_APPROX_KAWAI_KOUYOUMJIAN
,
const
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_SPEED_OF_SOUND_F
);
//! Calculate diffraction factor based on the Maekawa detour method
/**
...
...
@@ -80,7 +81,7 @@ namespace ITAPropagationModels
* @param[in] fSpeedOfSound Speed of sound [m/s]
*
*/
bool
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFactor
(
const
VistaVector3D
&
v3SourcePos
,
const
VistaVector3D
&
v3TargetPos
,
shared_ptr
<
const
ITAGeo
::
CITADiffractionWedgeApertureBase
>
pApex
,
const
float
fFrequency
,
complex
<
float
>&
cfFactor
,
const
int
iMethod
=
UTD_APPROX_KAWAI_KOUYOUMJIAN
,
const
float
fSpeedOfSound
=
ITAConstants
::
SPEED_OF_SOUND_F
);
bool
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFactor
(
const
VistaVector3D
&
v3SourcePos
,
const
VistaVector3D
&
v3TargetPos
,
shared_ptr
<
const
ITAGeo
::
CITADiffractionWedgeApertureBase
>
pApex
,
const
float
fFrequency
,
complex
<
float
>&
cfFactor
,
const
int
iMethod
=
UTD_APPROX_KAWAI_KOUYOUMJIAN
,
const
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_SPEED_OF_SOUND_F
);
//! Calculates the UTD diffraction filter in frequency domain for a given constellation
/**
...
...
@@ -95,7 +96,7 @@ namespace ITAPropagationModels
* @param[in] iMethod Approximation algorithm
* @param[in] fSpeedOfSound Sound speed
*/
void
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFilter
(
const
VistaVector3D
&
v3SourcePos
,
const
VistaVector3D
&
v3TargetPos
,
std
::
shared_ptr
<
const
ITAGeo
::
CITADiffractionWedgeApertureBase
>
pApex
,
ITABase
::
CHDFTSpectrum
&
oTF
,
const
int
iMethod
=
UTD_APPROX_KAWAI_KOUYOUMJIAN
,
const
float
fSpeedOfSound
=
ITAConstants
::
SPEED_OF_SOUND_F
);
void
ITA_PROPAGATION_MODELS_API
CalculateDiffractionFilter
(
const
VistaVector3D
&
v3SourcePos
,
const
VistaVector3D
&
v3TargetPos
,
std
::
shared_ptr
<
const
ITAGeo
::
CITADiffractionWedgeApertureBase
>
pApex
,
ITABase
::
CHDFTSpectrum
&
oTF
,
const
int
iMethod
=
UTD_APPROX_KAWAI_KOUYOUMJIAN
,
const
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_SPEED_OF_SOUND_F
);
}
}
...
...
include/ITAPropagationModels/Utils.h
0 → 100644
View file @
6b616db9
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_UTILS
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_UTILS
#include "Definitions.h"
#include <ITAConstants.h>
#include <ITAGeo/Base.h>
namespace
ITAPropagationModels
{
namespace
Utils
{
//! Estimates the required filter length on a best guess approach and by using path length and directivities / meterials into account
/**
* @note Set the minimum at least to the block length of your audio stream
*/
ITA_PROPAGATION_MODELS_API
float
EstimateFilterLengthSamples
(
const
ITAGeo
::
CPropagationPath
&
oPath
,
const
float
fSampleRate
,
const
float
fMinimumSamples
=
64
,
const
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_SPEED_OF_SOUND_F
);
}
}
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_UTILS
src/ITAPropagationModels/FilterEngine.cpp
View file @
6b616db9
This diff is collapsed.
Click to expand it.
src/ITAPropagationModels/Utils.cpp
0 → 100644
View file @
6b616db9
#include <ITAPropagationModels/Utils.h>
#include <ITAGeo/Base.h>
#include <ITAGeo/Material/Utils.h>
#include <ITAGeo/Directivity/Utils.h>
#include <ITAConstants.h>
#include <ITAException.h>
#include <cassert>
float
ITAPropagationModels
::
Utils
::
EstimateFilterLengthSamples
(
const
ITAGeo
::
CPropagationPath
&
oPath
,
const
float
fSampleRate
,
const
float
fMinimumSamples
,
const
float
fSpeedOfSound
)
{
float
fEstimatedFilterLengthSamples
=
fSampleRate
*
(
float
)
oPath
.
GetLength
();
for
(
auto
a
:
oPath
)
{
switch
(
a
->
iAnchorType
)
{
case
ITAGeo
::
CPropagationAnchor
::
ACOUSTIC_EMITTER
:
{
auto
p
=
std
::
dynamic_pointer_cast
<
const
ITAGeo
::
CEmitter
>
(
a
);
if
(
p
->
pDirectivity
)
fEstimatedFilterLengthSamples
+=
ITAGeo
::
Directivity
::
Utils
::
EstimateFilterLengthSamples
(
p
->
pDirectivity
,
fSampleRate
,
fSpeedOfSound
);
break
;
}
case
ITAGeo
::
CPropagationAnchor
::
ACOUSTIC_SENSOR
:
{
auto
p
=
std
::
dynamic_pointer_cast
<
const
ITAGeo
::
CSensor
>
(
a
);
if
(
p
->
pDirectivity
)
fEstimatedFilterLengthSamples
+=
ITAGeo
::
Directivity
::
Utils
::
EstimateFilterLengthSamples
(
p
->
pDirectivity
,
fSampleRate
,
fSpeedOfSound
);
break
;
}
case
ITAGeo
::
CPropagationAnchor
::
SPECULAR_REFLECTION
:
{
auto
p
=
std
::
dynamic_pointer_cast
<
const
ITAGeo
::
CSpecularReflection
>
(
a
);
if
(
p
->
pMaterial
)
fEstimatedFilterLengthSamples
+=
ITAGeo
::
Material
::
Utils
::
EstimateFilterLengthSamples
(
p
->
pMaterial
,
fSampleRate
,
fSpeedOfSound
);
break
;
}
default:
{
if
(
fEstimatedFilterLengthSamples
<
fMinimumSamples
)
fEstimatedFilterLengthSamples
=
fMinimumSamples
;
}
}
}
return
fEstimatedFilterLengthSamples
;
}
tests/CMakeLists.txt
View file @
6b616db9
...
...
@@ -4,3 +4,5 @@ add_subdirectory( "Maekawa" )
add_subdirectory
(
"Svensson"
)
add_subdirectory
(
"UTD"
)
add_subdirectory
(
"FilterEngine"
)
add_subdirectory
(
"ReceiverDirectivityTest"
)
add_subdirectory
(
"SourceDirectivityTest"
)
tests/FilterEngine/FilterEngineTest.cpp
View file @
6b616db9
...
...
@@ -38,9 +38,9 @@ int main( int, char** )
auto
pSource
=
make_shared
<
CEmitter
>
(
VistaVector3D
(
-
2.0
f
,
0.0
f
,
0.0
f
)
);
auto
pReceiver
=
make_shared
<
CSensor
>
(
VistaVector3D
(
2.0
f
,
0.0
f
,
0.0
f
)
);
CMaterialDirectory
oMaterialDirectory
(
"./"
);
auto
pMaterialDirectory
=
std
::
make_shared
<
Material
::
CDirectory
>
(
"./"
);
auto
pReflection
=
make_shared
<
CSpecularReflection
>
(
VistaVector3D
(
0.0
f
,
2.0
f
,
0.0
f
)
);
pReflection
->
p
AcousticMaterial
=
oMaterialDirectory
.
GetMaterial
(
"stonewall"
);
pReflection
->
p
Material
=
pMaterialDirectory
->
GetMaterial
(
"stonewall"
);
auto
pW
=
std
::
make_shared
<
CITADiffractionOuterWedgeAperture
>
();
pW
->
v3AperturePoint
.
SetValues
(
0.0
f
,
1.0
f
,
0.0
f
);
...
...
@@ -71,17 +71,16 @@ int main( int, char** )
oPathList
.
push_back
(
oPathDiffraction
);
CFilterEngine
oFilterEngine
;
oFilterEngine
.
SetMaterialManager
(
&
o
MaterialDirectory
);
oFilterEngine
.
SetMaterialManager
(
p
MaterialDirectory
);
// Set filter length according to the maximum path length
const
float
fSpeedOfSound
=
SPEED_OF_SOUND_F
;
//Approximation of speed of sound at ~20C
const
float
fSpeedOfSound
=
DEFAULT_
SPEED_OF_SOUND_F
;
//Approximation of speed of sound at ~20C
const
float
fSampleRate
=
44.1e3
f
;
int
iFilterLengthSamples
=
(
int
)
(
oPathList
.
GetMaxLength
()
/
fSpeedOfSound
*
fSampleRate
);
iFilterLengthSamples
=
int
(
iFilterLengthSamples
+
4096
);
ITABase
::
CHDFTSpectra
oTransmissionFilter
(
fSampleRate
,
pReceiver
->
iNumChannels
,
iFilterLengthSamples
);
ITABase
::
CHDFTSpectra
oTransmissionFilter
(
fSampleRate
,
pReceiver
->
GetNumChannels
()
,
iFilterLengthSamples
);
bool
bDFTDegreeTooSmallFlag
;
oFilterEngine
.
ApplyAcousticModels
(
oPathList
);
// @todo aer remove / merge into Generate()
oFilterEngine
.
Generate
(
oPathList
,
oTransmissionFilter
,
&
bDFTDegreeTooSmallFlag
);
if
(
bDFTDegreeTooSmallFlag
)
...
...
tests/ReceiverDirectivityTest/CMakeLists.txt
0 → 100644
View file @
6b616db9
cmake_minimum_required
(
VERSION 2.8
)
project
(
ITAPropagationModelsTest
)
list
(
APPEND CMAKE_MODULE_PATH
"$ENV{VISTA_CMAKE_COMMON}"
)
include
(
VistaCommon
)
vista_use_package
(
ITABase REQUIRED FIND_DEPENDENCIES
)
vista_use_package
(
ITAGeo REQUIRED FIND_DEPENDENCIES
)
vista_use_package
(
ITAPropagationModels REQUIRED FIND_DEPENDENCIES
)
vista_use_package
(
ITAFFT REQUIRED FIND_DEPENDENCIES
)
if
(
ITA_CORE_LIBS_BUILD_STATIC
)
add_definitions
(
-DITA_BASE_STATIC
)
endif
(
)
if
(
ITA_GEOMETRICAL_ACOUSTICS_BUILD_STATIC
)
add_definitions
(
-DITA_PROPAGATION_MODELS_STATIC _DITA_PROPAGATION_PATH_SIM_STATIC -DITA_GEO_STATIC
)
endif
(
)
add_executable
(
ReceiverDirectivityTest ReceiverDirectivityTest.cpp
)
target_link_libraries
(
ReceiverDirectivityTest
${
VISTA_USE_PACKAGE_LIBRARIES
}
)
vista_configure_app
(
ReceiverDirectivityTest
)
vista_install
(
ReceiverDirectivityTest
)
vista_create_default_info_file
(
ReceiverDirectivityTest
)
set_property
(
TARGET ReceiverDirectivityTest PROPERTY FOLDER
"ITAGeometricalAcoustics/Tests/ITAPropagationModels"
)
tests/ReceiverDirectivityTest/ITA_Artificial_Head_5x5_44kHz_128.v17.ir.daff
0 → 100644
View file @
6b616db9
File added
tests/ReceiverDirectivityTest/ReceiverDirectivityTest.cpp
0 → 100644
View file @
6b616db9
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#include <ITAPropagationModels/FilterEngine.h>
#include <ITAPropagationModels/Utils.h>
#include <ITAGeo/Base.h>
#include <ITAGeo/Directivity/Base.h>
#include <ITAGeo/Directivity/DAFF_ImpulseResponse.h>
#include <ITAGeo/Directivity/DAFF_MagnitudeSpectrum.h>
#include <ITAFFTUtils.h>
using
namespace
std
;
using
namespace
ITAConstants
;
using
namespace
ITAGeo
;
using
namespace
ITAPropagationModels
;
const
float
fSampleRate
=
44.1e3
f
;
int
main
(
int
,
char
**
)
{
auto
pSenderLeft
=
make_shared
<
CEmitter
>
(
VistaVector3D
(
-
2.0
f
,
0.0
f
,
0.0
f
));
auto
pSenderRight
=
make_shared
<
CEmitter
>
(
VistaVector3D
(
2.0
f
,
0.0
f
,
0.0
f
));
auto
pHRIR
=
make_shared
<
Directivity
::
CDAFF_ImpulseResponse
>
();
pHRIR
->
LoadFromFile
(
"ITA_Artificial_Head_5x5_44kHz_128.v17.ir.daff"
);
auto
pReceiver
=
make_shared
<
CSensor
>
(
VistaVector3D
(
0.0
f
,
0.0
f
,
0.0
f
));
pReceiver
->
pDirectivity
=
pHRIR
;
CPropagationPath
oPathFromLeft
;
oPathFromLeft
.
push_back
(
pSenderLeft
);
oPathFromLeft
.
push_back
(
pReceiver
);
CPropagationPath
oPathFromRight
;
oPathFromRight
.
push_back
(
pSenderRight
);
oPathFromRight
.
push_back
(
pReceiver
);
CFilterEngine
oFilterEngine
(
OPENGL
);
oFilterEngine
.
oPropagationModelConfiguration
.
iAtmosphericAbsorption
=
CFilterEngine
::
EAtmoshpericAbsorption
::
NONE
;
oFilterEngine
.
oPropagationModelConfiguration
.
iGeometricalSpreading
=
CFilterEngine
::
EGeometricalSpreading
::
PLANE_WAVE
;
int
iFilterLengthSamples
=
(
int
)
ceil
(
Utils
::
EstimateFilterLengthSamples
(
oPathFromLeft
,
fSampleRate
));
ITABase
::
CHDFTSpectra
oTransmissionFilterLeft
(
fSampleRate
,
pReceiver
->
GetNumChannels
(),
iFilterLengthSamples
);
bool
bDFTDegreeTooSmallFlag
;
oFilterEngine
.
Generate
(
oPathFromLeft
,
oTransmissionFilterLeft
,
&
bDFTDegreeTooSmallFlag
);
if
(
bDFTDegreeTooSmallFlag
)
cerr
<<
"DFT lengh too small, could not include all path completely into target filter"
<<
endl
;
ITAFFTUtils
::
Export
(
&
oTransmissionFilterLeft
,
"SourceFromLeft.wav"
);
// Exports in time domain as impulse response (IR)
ITABase
::
CHDFTSpectra
oTransmissionFilterRight
(
fSampleRate
,
pReceiver
->
GetNumChannels
(),
iFilterLengthSamples
);
oFilterEngine
.
Generate
(
oPathFromRight
,
oTransmissionFilterRight
,
&
bDFTDegreeTooSmallFlag
);
if
(
bDFTDegreeTooSmallFlag
)
cerr
<<
"DFT lengh too small, could not include all path completely into target filter"
<<
endl
;
ITAFFTUtils
::
Export
(
&
oTransmissionFilterRight
,
"SourceFromRight.wav"
);
}
tests/ReceiverDirectivityTest/ReceiverDirectivityTest.m
0 → 100644
View file @
6b616db9
SourceFromLeft = ita_read( 'SourceFromLeft.wav' );
SourceFromRight = ita_read( 'SourceFromRight.wav' );
SourceFromLeftAndRight = ita_merge( SourceFromLeft, SourceFromRight );
SourceFromLeftAndRight.pt
\ No newline at end of file
tests/SourceDirectivityTest/CMakeLists.txt
0 → 100644
View file @
6b616db9
cmake_minimum_required
(
VERSION 2.8
)
project
(
ITAPropagationModelsTest
)
list
(
APPEND CMAKE_MODULE_PATH
"$ENV{VISTA_CMAKE_COMMON}"
)
include
(
VistaCommon
)
vista_use_package
(
ITABase REQUIRED FIND_DEPENDENCIES
)
vista_use_package
(
ITAPropagationModels REQUIRED FIND_DEPENDENCIES
)
vista_use_package
(
ITAFFT REQUIRED FIND_DEPENDENCIES
)
if
(
ITA_CORE_LIBS_BUILD_STATIC
)
add_definitions
(
-DITA_BASE_STATIC
)
endif
(
)
if
(
ITA_GEOMETRICAL_ACOUSTICS_BUILD_STATIC
)
add_definitions
(
-DITA_PROPAGATION_MODELS_STATIC _DITA_PROPAGATION_PATH_SIM_STATIC -DITA_GEO_STATIC
)
endif
(
)
add_executable
(
SourceDirectivityTest SourceDirectivityTest.cpp
)
target_link_libraries
(
SourceDirectivityTest
${
VISTA_USE_P