Changes in tests and generate function

parent e3a3e49f
......@@ -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