WIP

parent 0511c59b
#include <ITAPropagationModels/FilterEngine.h>
// ITA includes
#include <ITAException.h>
#include <ITAGeo/Halfedge/MeshModel.h>
#include <ITAPropagationModels/UTD.h>
#include <ITAPropagationModels/Maekawa.h>
#include <ITAGeo/Halfedge/MeshModel.h>
#include <ITAGeo/Directivity/Base.h>
#include <ITAGeo/Directivity/DAFF_Format.h>
#include <ITAGeo/Directivity/DAFF_ImpulseResponse.h>
#include <ITAGeo/Directivity/DAFF_MagnitudeSpectrum.h>
#include <ITAException.h>
#include <ITAISO9613.h>
// Vista includes
......@@ -207,18 +212,48 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA
oThirdOctFactors[iFrequencyIndex] *= sqrt(1 - abs(oThirdOctAbsorption[iFrequencyIndex]));
}
//Set scalar and third octave filter components of the propagation anchors
for (auto& pAnchor : oPath)
// Process path and assemble filter components domain by domain
for (size_t i=0; i<oPath.size();i++)
{
if (pAnchor->pAcousticMaterial->GetType() == ITAGeo::Material::IMaterial::SCALAR)
auto pAnchor(oPath[i]);
switch (pAnchor->iAnchorType)
{
//Type cast of the acoustic material
auto pScalarMaterial = std::dynamic_pointer_cast<ITAGeo::Material::CScalarMaterial>(pAnchor->pAcousticMaterial);
case(ITAGeo::CPropagationAnchor::ACOUSTIC_EMITTER):
{
auto pEmitter = std::dynamic_pointer_cast<const ITAGeo::CEmitter>(pAnchor);
if (pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION)
fScalarMagnitude *= (float)abs(pScalarMaterial->cdReflectionFactor);
else
fScalarMagnitude *= (float)abs(pScalarMaterial->cdTransmissionFactor);
if (i == oPath.size())
ITA_EXCEPT_INVALID_PARAMETER("Propagation path invalid: detected an emitting anchor point at the end of the path.");
auto pNextAnchor(oPath[i + 1]);
if (pEmitter->pDirectivity)
{
switch (pEmitter->pDirectivity->GetFormat())
{
case(ITAGeo::Directivity::IDirectivity::OPENDAFF):
{
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);
pDAFFDirectivityMS->GetMagnitudeSpectrum();
}
}
}
}
/*
if (pAnchor->pAcousticMaterial->GetType() == ITAGeo::Material::IMaterial::SCALAR)
{
//Type cast of the acoustic material
auto pScalarMaterial = std::dynamic_pointer_cast<ITAGeo::Material::CScalarMaterial>(pAnchor->pAcousticMaterial);
if (pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION)
fScalarMagnitude *= (float)abs(pScalarMaterial->cdReflectionFactor);
else
fScalarMagnitude *= (float)abs(pScalarMaterial->cdTransmissionFactor);
}
*/
}
if (pAnchor->pAcousticMaterial->GetType() == ITAGeo::Material::IMaterial::THIRD_OCTAVE)
......@@ -232,6 +267,7 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA
oThirdOctFactors[i] *= pThirdOctaveMaterial->GetTransmissionFactor(i);
}
}
}
}
//Reset the HDFT spectra of the current path
......
......@@ -20,18 +20,21 @@ float ITAPropagationModels::Utils::EstimateFilterLengthSamples(const ITAGeo::CPr
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->pAcousticMaterial)
fEstimatedFilterLengthSamples += ITAGeo::Material::Utils::EstimateFilterLengthSamples(p->pAcousticMaterial, fSampleRate, fSpeedOfSound);
break;
}
default:
{
......
......@@ -22,7 +22,8 @@
#include <ITAGeo/Base.h>
#include <ITAGeo/Directivity/Base.h>
#include <ITAGeo/Directivity/DAFF_TimeDomain.h>
#include <ITAGeo/Directivity/DAFF_ImpulseResponse.h>
#include <ITAGeo/Directivity/DAFF_MagnitudeSpectrum.h>
#include <ITAFFTUtils.h>
......@@ -38,7 +39,7 @@ 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));
shared_ptr< Directivity::CDAFF_TimeDomain > pHRIR = make_shared< Directivity::CDAFF_TimeDomain >();
shared_ptr< Directivity::CDAFF_ImpulseResponse > 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));
......
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