Skip to content
Snippets Groups Projects
Commit cd2695d0 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Appyling new methods from ITAGeo (coordinates, directivities)

parent fbd1cc2a
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,7 @@ namespace ITAPropagationModels
//! Standard constructor for a filter engine
CFilterEngine();
CFilterEngine( const ITAGeo::ECoordinateSystemConvention iConvention = ITAGeo::ECoordinateSystemConvention::ISO );
//! Default destructor of a filter engine
......@@ -145,6 +145,8 @@ namespace ITAPropagationModels
std::shared_ptr< const ITAGeo::Material::IManager > m_pMaterialManager;
std::shared_ptr< const ITAGeo::Directivity::IManager > m_pDirectivityManager;
ITAGeo::ECoordinateSystemConvention m_iCoordinateSystemConvention;
};
}
......
......@@ -28,8 +28,9 @@
using namespace ITAPropagationModels;
CFilterEngine::CFilterEngine()
CFilterEngine::CFilterEngine(const ITAGeo::ECoordinateSystemConvention iCSC /* = ISO */)
: m_pMaterialManager(nullptr)
, m_iCoordinateSystemConvention(iCSC)
{
}
......@@ -201,7 +202,7 @@ void CFilterEngine::Generate( const ITAGeo::CPropagationPathList & oPathList, IT
ITA_EXCEPT_INVALID_PARAMETER("Encountered a path with no geometrical distance, could not generate filter");
//Include sound energy decrease due to the length of the path @todo this might get more complex with diffraction
dScalarMagnitude /= dPathLength;
dScalarMagnitude = 1/dPathLength;
// Air attenuation according to ISO9613-1 (overrides third octaves, so no resetting required, do not change order!)
ITABase::ISO9613::AtmosphericAbsorption(oThirdOctFactors, (float)dPathLength, oEnvironmentState.dTemperature, oEnvironmentState.dHumidity);
......@@ -227,7 +228,8 @@ void CFilterEngine::Generate( const ITAGeo::CPropagationPathList & oPathList, IT
if (pEmitter->pDirectivity)
{
ITAGeo::Coordinates::CSpherical_RightHanded_Degree oDirection;
const VistaVector3D v3Dir( pNextAnchor->v3InteractionPoint - pEmitter->v3InteractionPoint);
ITAGeo::Coordinates::CSpherical oDirection(v3Dir, m_iCoordinateSystemConvention);
switch (pEmitter->pDirectivity->GetFormat())
{
case(ITAGeo::Directivity::IDirectivity::OPENDAFF):
......@@ -235,7 +237,7 @@ void CFilterEngine::Generate( const ITAGeo::CPropagationPathList & oPathList, IT
auto pDAFFDirectivity = std::dynamic_pointer_cast<const ITAGeo::Directivity::CDAFF_Format>(pEmitter->pDirectivity);
if (pDAFFDirectivity->GetDomain() == ITADomain::ITA_FREQUENCY_DOMAIN)
{
auto pDAFFDirectivityMS = std::dynamic_pointer_cast< const ITAGeo::Directivity::CDAFF_MagnitudeSpectrum >( pAnchor );
auto pDAFFDirectivityMS = std::dynamic_pointer_cast<const ITAGeo::Directivity::CDAFF_MagnitudeSpectrum>(pEmitter->pDirectivity);
pDAFFDirectivityMS->MultiplyNearestNeighbourMagnitudeSpectrum(oDirection, oThirdOctFactors);
}
}
......
......@@ -53,7 +53,7 @@ int main( int, char** )
oPathFromRight.push_back(pSenderRight);
oPathFromRight.push_back(pReceiver);
CFilterEngine oFilterEngine;
CFilterEngine oFilterEngine( OPENGL );
int iFilterLengthSamples = (int) ceil(Utils::EstimateFilterLengthSamples(oPathFromLeft, fSampleRate));
ITABase::CHDFTSpectra oTransmissionFilterLeft(fSampleRate, pReceiver->GetNumChannels(), iFilterLengthSamples );
......
......@@ -18,82 +18,48 @@
#include <ITAPropagationModels/FilterEngine.h>
#include <ITAPropagationModels/Utils.h>
#include <ITAGeo/Base.h>
#include <ITAGeo/Material/Manager.h>
#include <ITAGeo/Directivity/Base.h>
#include <ITAGeo/Directivity/DAFF_ImpulseResponse.h>
#include <ITAGeo/Directivity/DAFF_MagnitudeSpectrum.h>
#include <ITAFFTUtils.h>
#include <ITAISO9613.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**)
{
/*
|___x___|
/\
s \ r
\ /
___x___
|______|
*/
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, 0.0f, 0.0f ) );
auto pReceiver = make_shared< CSensor >( VistaVector3D( 2.0f, 0.0f, 0.0f ) );
auto pSender = make_shared< CEmitter >(VistaVector3D(2.0f, 1.3f, 2.0f));
pSender->pDirectivity = pTrumpetDirectivity;
auto pMaterialDirectory = std::make_shared< Material::CDirectory >( "./" );
auto pReflection = make_shared< CSpecularReflection >( VistaVector3D( 0.0f, 2.0f, 0.0f ) );
pReflection->pAcousticMaterial = pMaterialDirectory->GetMaterial( "stonewall" );
auto pReceiver = make_shared< CSensor >(VistaVector3D(0.0f, 0.0f, 0.0f));
auto pW = std::make_shared< CITADiffractionOuterWedgeAperture >();
pW->v3AperturePoint.SetValues( 0.0f, 1.0f, 0.0f );
pW->v3MainWedgeFaceNormal.SetValues( -1.0f, 1.0f, .0f );
pW->v3MainWedgeFaceNormal.Normalize();
pW->v3OppositeWedgeFaceNormal.SetValues( 1.0f, 1.0f, .0f );
pW->v3OppositeWedgeFaceNormal.Normalize();
pW->v3VertextStart.SetValues( .0f, 1.0f, -1.0f );
pW->v3VertextEnd.SetValues( .0f, 1.0f, 1.0f );
CPropagationPath oPath;
oPath.push_back(pSender);
oPath.push_back(pReceiver);
CPropagationPath oPathDirect;
oPathDirect.push_back( pSender );
oPathDirect.push_back( pReceiver );
CFilterEngine oFilterEngine(OPENGL);
CPropagationPath oPathReflection;
oPathReflection.push_back( pSender );
oPathReflection.push_back( pReflection );
oPathReflection.push_back( pReceiver );
CPropagationPath oPathDiffraction;
oPathDiffraction.push_back( pSender );
oPathDiffraction.push_back( pW );
oPathDiffraction.push_back( pReceiver );
CPropagationPathList oPathList;
oPathList.push_back(oPathDirect);
oPathList.push_back(oPathReflection);
oPathList.push_back(oPathDiffraction);
CFilterEngine oFilterEngine;
oFilterEngine.SetMaterialManager( pMaterialDirectory );
// Set filter length according to the maximum path length
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->GetNumChannels(), iFilterLengthSamples );
int iFilterLengthSamples = (int)ceil(Utils::EstimateFilterLengthSamples(oPath, fSampleRate));
CHDFTSpectra oTransmissionFilter(fSampleRate, pReceiver->GetNumChannels(), iFilterLengthSamples);
bool bDFTDegreeTooSmallFlag;
oFilterEngine.Generate( oPathList, oTransmissionFilter, &bDFTDegreeTooSmallFlag );
oFilterEngine.Generate(oPath, oTransmissionFilter, &bDFTDegreeTooSmallFlag);
if (bDFTDegreeTooSmallFlag)
cerr << "DFT lengh too small, could not include all path completely into target filter" << endl;
ITAFFTUtils::Export( &oTransmissionFilter, "FilterEngineTest.wav" ); // Exports in time domain as impulse response (IR)
Export(&oTransmissionFilter, "SourceDirectivityTest.wav"); // Exports in time domain as impulse response (IR)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment