Introducing ITABaser namespace, starting with data classes

parent f8aafff2
......@@ -278,7 +278,7 @@ public:
/**
* \important Not thread safe
*/
bool GetHRTF( std::vector< ITAHDFTSpectra* >& vpHRTF ) const;
bool GetHRTF( std::vector< ITABase::CHDFTSpectra* >& vpHRTF ) const;
//! Returns the currently used head pose
/**
......@@ -300,10 +300,10 @@ public:
*
* @note Will raise ITAException on error
*/
void CalculateFilter( std::vector< ITAHDFTSpectra* >& vpSpectra ) const;
void CalculateFilter( std::vector< ITABase::CHDFTSpectra* >& vpSpectra ) const;
//! Calculate the Wiener-Hopf factorization
void WienerHopfFactorization( const ITAHDFTSpectrum* voSpecIn, ITAHDFTSpectrum* voSpecOutPlus, ITAHDFTSpectrum* voSpecOutMinus );
void WienerHopfFactorization( const ITABase::CHDFTSpectrum* voSpecIn, ITABase::CHDFTSpectrum* voSpecOutPlus, ITABase::CHDFTSpectrum* voSpecOutMinus );
protected:
......@@ -323,10 +323,10 @@ private:
mutable ITASampleFrame m_sfCTC_temp; //!< Internal CTC helper
std::vector< float > m_vfWeights; //!< Diagonal values for the weighting matrix (W or Z), only non-zero entries allowed
std::vector< ITAHDFTSpectra* > m_vpHRTFs; //!< N-dim vector with two-channel HRTF sets for each LS direction
std::vector< ITAHDFTSpectra* > m_vpHelper2x2; //!< Two-by-two helper matrix
ITAHDFTSpectrum* t; //!< Helper
ITAHDFTSpectrum* det; //!< Helper
std::vector< ITABase::CHDFTSpectra* > m_vpHRTFs; //!< N-dim vector with two-channel HRTF sets for each LS direction
std::vector< ITABase::CHDFTSpectra* > m_vpHelper2x2; //!< Two-by-two helper matrix
ITABase::CHDFTSpectrum* t; //!< Helper
ITABase::CHDFTSpectrum* det; //!< Helper
int GetLoudspeakerSide( const int ) const;
......
......@@ -24,6 +24,7 @@
#include <vector>
#include <ITADataSourceRealization.h>
#include <ITAHDFTSpectra.h>
// Forward declarations
class ITAUPConvolution;
......@@ -31,7 +32,6 @@ class ITAUPFilter;
class ITAUPFilterPool;
class ITAUPTrigger;
class ITADatasource;
class ITAHDFTSpectra;
//! ITACircularNCTCStreamFilter realizes the CTC filtering
/**
......@@ -66,7 +66,7 @@ public:
ITADatasource* GetOutputDatasource() const;
//! Exchange filters
void ExchangeFilters( const std::vector< ITAHDFTSpectra* >& vpCTCFilter );
void ExchangeFilters( const std::vector< ITABase::CHDFTSpectra* >& vpCTCFilter );
//! Set gains of loudspeaker two-channel connvolvers (N-sized vector of floats)
void SetGains( const std::vector< float >& vfGains, bool bSetImmediately=false );
......
......@@ -14,6 +14,7 @@
#include <ITAStringUtils.h>
#include <ITAFFTUtils.h>
ITANCTC::ITANCTC( const Config& oNCTCConfig )
: m_oConfig( oNCTCConfig )
, m_pHRIR( NULL )
......@@ -37,15 +38,15 @@ ITANCTC::ITANCTC( const Config& oNCTCConfig )
for( int n = 0; n < GetNumChannels(); n++ )
{
m_vfWeights.push_back( 1.0f );
m_vpHRTFs.push_back( new ITAHDFTSpectra( m_oConfig.fSampleRate, 2, iDFTSize, true ) );
m_vpHRTFs.push_back( new ITABase::CHDFTSpectra( m_oConfig.fSampleRate, 2, iDFTSize, true ) );
m_vfDelayTime.push_back( float( m_oConfig.iCTCFilterLength ) / m_oConfig.fSampleRate / 2.0f );
}
for( int i = 0; i < 2; i++ )
m_vpHelper2x2.push_back( new ITAHDFTSpectra( m_oConfig.fSampleRate, 2, iDFTSize, true ) );
m_vpHelper2x2.push_back( new ITABase::CHDFTSpectra( m_oConfig.fSampleRate, 2, iDFTSize, true ) );
t = new ITAHDFTSpectrum( m_oConfig.fSampleRate, iDFTSize, true );
det = new ITAHDFTSpectrum( m_oConfig.fSampleRate, iDFTSize, true );
t = new ITABase::CHDFTSpectrum( m_oConfig.fSampleRate, iDFTSize, true );
det = new ITABase::CHDFTSpectrum( m_oConfig.fSampleRate, iDFTSize, true );
m_fft.plan( ITAFFT::FFT_R2C, m_oConfig.iCTCFilterLength, m_sfCTC_temp[ 0 ].GetData(), ( *m_vpHRTFs[ 0 ] )[ 0 ]->GetData() );
m_ifft.plan( ITAFFT::IFFT_C2R, m_oConfig.iCTCFilterLength, ( *m_vpHRTFs[ 0 ] )[ 0 ]->GetData(), m_sfCTC_temp[ 0 ].GetData() );
......@@ -155,7 +156,7 @@ const ITANCTC::Pose& ITANCTC::GetLoudspeakerPose( const int iLoudspeakerID ) con
return m_oConfig.voLoudspeaker[ iLoudspeakerID - 1 ].oPose;
}
void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) const
void ITANCTC::CalculateFilter( std::vector< ITABase::CHDFTSpectra* >& vpCTCFilter ) const
{
if( !m_pHRIR )
ITA_EXCEPT1( MODAL_EXCEPTION, "CTC filters could not be created because HRIR is not set" );
......@@ -180,7 +181,7 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
if( bOutOfRange )
ITA_EXCEPT_INVALID_PARAMETER( "CTC filters could not be created because HRIR direction is out of bounds and not covered by input HRIR" );
ITAHDFTSpectra* pHRTF( m_vpHRTFs[ n ] );
ITABase::CHDFTSpectra* pHRTF( m_vpHRTFs[ n ] );
// Convert HRIRs to HRTFs
m_fft.execute( m_sfCTC_temp[ 0 ].GetData(), ( *pHRTF )[ 0 ]->GetData() );
......@@ -195,10 +196,10 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
* a c
* b d
*/
ITAHDFTSpectrum* a = ( *m_vpHelper2x2[ 0 ] )[ 0 ];
ITAHDFTSpectrum* b = ( *m_vpHelper2x2[ 0 ] )[ 1 ];
ITAHDFTSpectrum* c = ( *m_vpHelper2x2[ 1 ] )[ 0 ];
ITAHDFTSpectrum* d = ( *m_vpHelper2x2[ 1 ] )[ 1 ];
ITABase::CHDFTSpectrum* a = ( *m_vpHelper2x2[ 0 ] )[ 0 ];
ITABase::CHDFTSpectrum* b = ( *m_vpHelper2x2[ 0 ] )[ 1 ];
ITABase::CHDFTSpectrum* c = ( *m_vpHelper2x2[ 1 ] )[ 0 ];
ITABase::CHDFTSpectrum* d = ( *m_vpHelper2x2[ 1 ] )[ 1 ];
// Least-squares minimization: C = WH*(HWH*-\beta)^-1
// using H* as the hermitian (complex conjugated) transpose of H
......@@ -213,7 +214,7 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
for( int n = 0; n < GetNumChannels(); n++ )
{
ITAHDFTSpectra* pHRTF( m_vpHRTFs[ n ] ); // two-channel
ITABase::CHDFTSpectra* pHRTF( m_vpHRTFs[ n ] ); // two-channel
// --- WICK factor ---
......@@ -309,7 +310,7 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
a->Add( m_fRegularizationFactor );
d->Add( m_fRegularizationFactor );
ITAHDFTSpectra abcd( m_oConfig.fSampleRate, 4, m_oConfig.iCTCFilterLength );
ITABase::CHDFTSpectra abcd( m_oConfig.fSampleRate, 4, m_oConfig.iCTCFilterLength );
abcd[ 0 ]->CopyFrom( *a );
abcd[ 1 ]->CopyFrom( *b );
abcd[ 2 ]->CopyFrom( *c );
......@@ -344,8 +345,8 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
for( int n = 0; n < GetNumChannels(); n++ )
{
ITAHDFTSpectra* pHRTF( m_vpHRTFs[ n ] ); // two-channel, already WICKed
ITAHDFTSpectra* pCTCFilter( vpCTCFilter[ n ] ); // two-channel
ITABase::CHDFTSpectra* pHRTF( m_vpHRTFs[ n ] ); // two-channel, already WICKed
ITABase::CHDFTSpectra* pCTCFilter( vpCTCFilter[ n ] ); // two-channel
const float& fWeight( m_vfWeights[ n ] ); // diag element
t->Copy( a );
......@@ -500,7 +501,7 @@ int ITANCTC::GetOptimization() const
return m_iOptimization;
}
bool ITANCTC::GetHRTF( std::vector< ITAHDFTSpectra* >& vpHRTF ) const
bool ITANCTC::GetHRTF( std::vector< ITABase::CHDFTSpectra* >& vpHRTF ) const
{
if( m_vpHRTFs.empty() )
return false;
......
......@@ -76,7 +76,7 @@ ITADatasource* ITANCTCStreamFilter::GetOutputDatasource() const
return m_pdsOutput;
}
void ITANCTCStreamFilter::ExchangeFilters( const std::vector< ITAHDFTSpectra* >& vpCTCFilter )
void ITANCTCStreamFilter::ExchangeFilters( const std::vector< ITABase::CHDFTSpectra* >& vpCTCFilter )
{
// Helper (todo jst: use member variable for less alloc)
ITASampleBuffer sbImpulseResponse( oConfig.iFilterLength, true );
......@@ -88,10 +88,10 @@ void ITANCTCStreamFilter::ExchangeFilters( const std::vector< ITAHDFTSpectra* >&
for( int n=0; n < oConfig.N; n++ )
{
const ITAHDFTSpectra* oCTCFilter( vpCTCFilter[n] );
const ITABase::CHDFTSpectra* oCTCFilter( vpCTCFilter[ n ] );
const ITAHDFTSpectrum& oCTCFilterL( *(*oCTCFilter)[0] );
const ITAHDFTSpectrum& oCTCFilterR( *(*oCTCFilter)[1] );
const ITABase::CHDFTSpectrum& oCTCFilterL( *( *oCTCFilter )[ 0 ] );
const ITABase::CHDFTSpectrum& oCTCFilterR( *( *oCTCFilter )[ 1 ] );
int iIdxLeft = 2*n+0;
int iIdxRight = iIdxLeft+1;
......
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