Commit 45ea3591 authored by Armin Erraji's avatar Armin Erraji

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

parents 50a5eaea bf80ef43
......@@ -18,7 +18,6 @@ include_directories( "include" )
set( ITAPropagationModelsHeader
"include/ITAPropagationModels/Base.h"
"include/ITAPropagationModels/Definitions.h"
"include/ITAPropagationModels/DiffractionFilter.h"
"include/ITAPropagationModels/FilterEngine.h"
"include/ITAPropagationModels/Maekawa.h"
"include/ITAPropagationModels/Svensson.h"
......
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_DIFFRACTION_FILTER
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_DIFFRACTION_FILTER
#include "Definitions.h"
// ITA includes
#include <ITASampleBuffer.h>
namespace ITAPropagationModels
{
//! Diffraction filter impulse response in time domain
/**
*
* Because only the diffraction part is described, leading
* zeros from the propagation delay is discarded in the IR.
*/
class ITA_PROPAGATION_MODELS_API CITADiffractionFilter
{
CITADiffractionFilter();
ITASampleBuffer sbFIRFilter;
int nLeadingZeros;
int nFilterLength;
};
}
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_DIFFRACTION_FILTER
......@@ -103,14 +103,14 @@ namespace ITAPropagationModels
/**
* @todo AER
*/
void Generate( const ITAGeo::CPropagationPathList& oPathList, ITABase::CHDFTSpectra& oFilter );
void Generate( const ITAGeo::CPropagationPathList& oPathList, ITABase::CHDFTSpectra& oFilter, bool* pbDFTDegreeTooSmall = NULL );
//! Generate single-channel propagation path (for single-channel receiver directivity)
inline void Generate( const ITAGeo::CPropagationPathList& oPathList, ITABase::CHDFTSpectrum& oFilter )
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 );
Generate( oPathList, oTF, pbDFTDegreeTooSmall );
};
//! Sets a connection to the material manager
......
......@@ -264,8 +264,11 @@ void CFilterEngine::ApplyTransmissionModel( ITAGeo::CPropagationPathList & oPath
#pragma warning( pop )
void CFilterEngine::Generate( const ITAGeo::CPropagationPathList & oPathList, ITABase::CHDFTSpectra & oHDFTSpectra )
void CFilterEngine::Generate( const ITAGeo::CPropagationPathList & oPathList, ITABase::CHDFTSpectra & oHDFTSpectra, bool* pbDFTDegreeTooSmall )
{
if( pbDFTDegreeTooSmall )
*pbDFTDegreeTooSmall = false;
//Check for correct structur of oPathList
if( !HasSameSensorAnchor( oPathList ) )
ITA_EXCEPT1( INVALID_PARAMETER, "The propagation path list has more than multiple sensor anchors or last anchor of paths is not a sensor." );
......@@ -360,7 +363,7 @@ void CFilterEngine::Generate( const ITAGeo::CPropagationPathList & oPathList, IT
//Get the delay [samples] and calculate the phase shift according to the shift theorem
// DFT(x(k-Delta)) = exp(-j * omega_k * delta) * X(k) , with omega_k = 2 * pi * k / N
float fDelaySamples = fPathLength / m_fSpeedOfSound * ( float ) oHDFTSpectra.GetSampleRate();
float fDelayPhase = -fDelaySamples* ITAConstants::TWO_PI_F * i / oHDFTSpectra.GetDFTSize();
float fDelayPhase = -fDelaySamples* ITAConstants::TWO_PI_F * i / (float) oHDFTSpectra.GetDFTSize();
( *m_pTempPropPathSpectra )[ 0 ]->SetPhasePreserveMagnitude( i, fDelayPhase );
......
......@@ -81,16 +81,20 @@ int main( int, char** )
CFilterEngine oFilterEngine;
oFilterEngine.SetMaterialManager( &oMaterialDirectory );
oFilterEngine.ApplyAcousticModels( oPathList );
// 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 fSampleRate = 44.1e3f;
int iFilterLengthSamples = ( int ) ( oPathList.GetMaxLength() / fSpeedOfSound * fSampleRate );
iFilterLengthSamples = int( iFilterLengthSamples * 1.5f );
iFilterLengthSamples = int( iFilterLengthSamples + 4096 );
ITABase::CHDFTSpectra oTransmissionFilter( fSampleRate, pReceiver->iNumChannels, iFilterLengthSamples );
oFilterEngine.Generate( oPathList, oTransmissionFilter );
bool bDFTDegreeTooSmallFlag;
oFilterEngine.ApplyAcousticModels( oPathList ); // @todo aer remove / merge into Generate()
oFilterEngine.Generate( oPathList, 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)
}
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