Commit 6b616db9 authored by Armin Erraji's avatar Armin Erraji

Merge remote-tracking branch 'remotes/origin/develop' into ma_2018/erraji

parents 9e9fe320 6fcefdfc
......@@ -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"
)
......
......@@ -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;
......
......@@ -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
......@@ -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;
};
}
......
......@@ -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);
}
}
......
......@@ -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);
}
}
......
......@@ -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);
}
}
......
/*
* ----------------------------------------------------------------
*
* 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
This diff is collapsed.
#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;
}
......@@ -4,3 +4,5 @@ add_subdirectory( "Maekawa" )
add_subdirectory( "Svensson" )
add_subdirectory( "UTD" )
add_subdirectory( "FilterEngine" )
add_subdirectory( "ReceiverDirectivityTest" )
add_subdirectory( "SourceDirectivityTest" )
......@@ -38,9 +38,9 @@ int main( int, char** )
auto pSource = make_shared< CEmitter >( VistaVector3D( -2.0f, 0.0f, 0.0f ) );
auto pReceiver = make_shared< CSensor >( VistaVector3D( 2.0f, 0.0f, 0.0f ) );
CMaterialDirectory oMaterialDirectory( "./" );
auto pMaterialDirectory = std::make_shared< Material::CDirectory >( "./" );
auto pReflection = make_shared< CSpecularReflection >( VistaVector3D( 0.0f, 2.0f, 0.0f ) );
pReflection->pAcousticMaterial = oMaterialDirectory.GetMaterial( "stonewall" );
pReflection->pMaterial = pMaterialDirectory->GetMaterial( "stonewall" );
auto pW = std::make_shared< CITADiffractionOuterWedgeAperture >();
pW->v3AperturePoint.SetValues( 0.0f, 1.0f, 0.0f );
......@@ -71,17 +71,16 @@ int main( int, char** )
oPathList.push_back(oPathDiffraction);
CFilterEngine oFilterEngine;
oFilterEngine.SetMaterialManager( &oMaterialDirectory );
oFilterEngine.SetMaterialManager( pMaterialDirectory );
// 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.1e3f;
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 )
......
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" )
/*
* ----------------------------------------------------------------
*
* 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.1e3f;
int main( int, char** )
{
auto pSenderLeft = make_shared< CEmitter >(VistaVector3D(-2.0f, 0.0f, 0.0f));
auto pSenderRight = make_shared< CEmitter >(VistaVector3D(2.0f, 0.0f, 0.0f));
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.0f, 0.0f, 0.0f));
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");
}
SourceFromLeft = ita_read( 'SourceFromLeft.wav' );
SourceFromRight = ita_read( 'SourceFromRight.wav' );
SourceFromLeftAndRight = ita_merge( SourceFromLeft, SourceFromRight );
SourceFromLeftAndRight.pt
\ No newline at end of file
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_PACKAGE_LIBRARIES} )
vista_configure_app( SourceDirectivityTest )
vista_install( SourceDirectivityTest )
vista_create_default_info_file( SourceDirectivityTest )
set_property( TARGET SourceDirectivityTest PROPERTY FOLDER "ITAGeometricalAcoustics/Tests/ITAPropagationModels" )
/*
* ----------------------------------------------------------------
*
* 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 ITABase;
using namespace ITAConstants;
using namespace ITAGeo;
using namespace ITAFFTUtils;
using namespace ITAPropagationModels;
const float fSampleRate = 44.1e3f;
int main(int, char**)
{
shared_ptr< Directivity::CDAFF_MagnitudeSpectrum > pTrumpetDirectivity = make_shared< Directivity::CDAFF_MagnitudeSpectrum >();
pTrumpetDirectivity->LoadFromFile("Trumpet1.v17.ms.daff");
auto pSender = make_shared< CEmitter >(VistaVector3D(2.0f, 1.3f, 2.0f));
pSender->pDirectivity = pTrumpetDirectivity;
auto pReceiver = make_shared< CSensor >(VistaVector3D(0.0f, 0.0f, 0.0f));
CPropagationPath oPath;
oPath.push_back(pSender);
oPath.push_back(pReceiver);
CFilterEngine oFilterEngine(OPENGL);
int iFilterLengthSamples = (int)ceil(Utils::EstimateFilterLengthSamples(oPath, fSampleRate));
CHDFTSpectra oTransmissionFilter(fSampleRate, pReceiver->GetNumChannels(), iFilterLengthSamples);
bool bDFTDegreeTooSmallFlag;
oFilterEngine.Generate(oPath, oTransmissionFilter, &bDFTDegreeTooSmallFlag);
if (bDFTDegreeTooSmallFlag)
cerr << "DFT lengh too small, could not include all path completely into target filter" << endl;
Export(&oTransmissionFilter, "SourceDirectivityTest.wav"); // Exports in time domain as impulse response (IR)
}
%% Example with one diffraction and one reflaction component
ThreePath_Example = ita_read('ThreePaths_Example.wav');
ita_plot(ThreePath_Example)
%% Image source example
ImageSource_Example = ita_read('ImageSource_Example.wav');
ImageSource_Example.pf
\ No newline at end of file
......@@ -37,7 +37,7 @@ using namespace ITAGeo;
using namespace ITAPropagationModels;
static const float g_fSampleRate = 44.1e3f;
static const float g_fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F;
static const float g_fSpeedOfSound = ITAConstants::DEFAULT_SPEED_OF_SOUND_F;
//! Tests running the Svensson model functions
/**
......
......@@ -36,7 +36,7 @@ using namespace ITAPropagationModels;
static const float g_fSampleRate = 44.1e3f;
static const int g_iFilterLength = 128;
static const float g_fSpeedOfSound = ITAConstants::SPEED_OF_SOUND_F;
static const float g_fSpeedOfSound = ITAConstants::DEFAULT_SPEED_OF_SOUND_F;
//! Tests running the UTD model functions
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment