adding a new feature to set a desired delay for each channel individually...

adding a new feature to set a desired delay for each channel individually (affecting the two convolvers per N-CTC channel), i.e. to account for delay differences within loudspeakers. Still, the setter for a single delay is available and overwrites all individual values, if used.
parent 191f6370
......@@ -208,13 +208,28 @@ public:
/**
* \return Delay in seconds
*/
float GetDelay();
std::vector< float > GetDelayTime();
//! Set additional delay parameter in seconds
//! Set additional delay parameter in seconds (affects all channels)
/**
* \param fDelay Set the beta fading parameter
* The default value is half of the filter length.
*
* @note Will overwrite existing individual values.
*
* @param fDelayTime Set the time delay (all channels)
*/
void SetDelayTime( float fDelayTime );
//! Set delay parameter in seconds for each loudspeaker channel individually
/**
* The CTC filter set for each channel (loudspeaker) will be delayd by given time. This is
* helpful to overcome latency issues with different types of loudspeakers.
*
* The default value is half of the filter length.
*
* \param vfDelayTime Set the time delay (each channel/loudspeaker individually)
*/
void SetDelayTime( float fDelay );
void SetDelayTime( std::vector< float > vfDelayTime );
//! Sets the optimization
/**
......@@ -282,14 +297,14 @@ private:
const Config m_oConfig; //!< CTC Configuration
ITAAtomicFloat m_fBeta; //!< Beta parameter (regularization)
ITAAtomicFloat m_fDelayTime; //!< Add a delay [seconds] to the resulting CTC filter
std::vector< float > m_vfDelayTime; //!< Add a delay [seconds] to the resulting CTC filter (individual channels)
ITAAtomicInt m_iOptimization; //!< Optimization (see Config enum)
const DAFFContentIR* m_pHRIR; //!< HRIR dataset pointer
Pose m_oHeadPose; //!< Current head Pose data
std::vector<std::vector<Config::ImageSource*>*> m_voImageSources; //!< Image Source Data
std::vector<Wall*> m_oCaveWalls; //!< CAVE walls data
std::vector<VistaVector3D*> m_voCaveVertices; //!< contains all corner indices of all CAVE walls
std::vector< std::vector< Config::ImageSource* >* > m_voImageSources; //!< Image Source Data
std::vector< Wall* > m_oCaveWalls; //!< CAVE walls data
std::vector< VistaVector3D* > m_voCaveVertices; //!< contains all corner indices of all CAVE walls
ITAFFT m_fft, m_ifft; //!< Internal FFT and IFFT transformations
ITASampleFrame m_sfCTC_temp; //!< Internal CTC helper
......
......@@ -21,7 +21,7 @@ ITANCTC::ITANCTC( const Config& oNCTCConfig )
, m_pHRIR( NULL )
{
m_fBeta = float( 1e-4 );
m_fDelayTime = float( m_oConfig.iCTCFilterLength / m_oConfig.dSampleRate / 2.0f );
m_iOptimization = m_oConfig.iOptimization;
m_oHeadPose.vPos.SetToZeroVector();
......@@ -36,6 +36,7 @@ ITANCTC::ITANCTC( const Config& oNCTCConfig )
{
m_vdWeights.push_back( 1.0f );
m_vpHRTFs.push_back( new ITAHDFTSpectra( m_oConfig.dSampleRate, 2, iDFTSize, true ) );
m_vfDelayTime.push_back( float( m_oConfig.iCTCFilterLength / m_oConfig.dSampleRate / 2.0f ) );
}
for( int i=0; i<2; i++ )
......@@ -65,19 +66,14 @@ ITANCTC::~ITANCTC()
delete t, det;
for (int i = m_voImageSources.size()-1; i >= 0 ; i--)
{
for (int j = m_voImageSources[i]->size()-1; j >= 0 ; j--)
delete m_voImageSources[i]->at(j);
}
for (int i = m_oCaveWalls.size()-1; i >= 0 ; i--)
{
delete m_oCaveWalls[i];
}
for( size_t i = 0; i < m_voImageSources.size(); i++ )
for( size_t j = 0; j < m_voImageSources[ i ]->size(); j++ )
delete m_voImageSources[ i ]->at( j );
for( size_t i = 0; i < m_oCaveWalls.size(); i++ )
delete m_oCaveWalls[ i ];
return;
}
const ITANCTC::Config& ITANCTC::GetConfig() const
......@@ -185,14 +181,14 @@ void ITANCTC::CalculateBRIR( const Pose& oLoudspeakerPose, ITASampleFrame& sfBRI
void ITANCTC::GenerateImageSources()
{
// create list of all wall vertices
m_voCaveVertices.push_back(new VistaVector3D(-2.626,0,2.625));
m_voCaveVertices.push_back(new VistaVector3D(2.626,0,2.625));
m_voCaveVertices.push_back(new VistaVector3D(2.626,0,-2.625));
m_voCaveVertices.push_back(new VistaVector3D(-2.626,0,-2.625));
m_voCaveVertices.push_back(new VistaVector3D(-2.626,3.3,2.625));
m_voCaveVertices.push_back(new VistaVector3D(2.626,3.3,2.625));
m_voCaveVertices.push_back(new VistaVector3D(2.626,3.3,-2.625));
m_voCaveVertices.push_back(new VistaVector3D(-2.626,3.3,-2.625));
m_voCaveVertices.push_back(new VistaVector3D(-2.626f,0.0f,2.625f));
m_voCaveVertices.push_back(new VistaVector3D(2.626f,0.0f,2.625f));
m_voCaveVertices.push_back(new VistaVector3D(2.626f,0.0f,-2.625f));
m_voCaveVertices.push_back(new VistaVector3D(-2.626f,0.0f,-2.625f));
m_voCaveVertices.push_back(new VistaVector3D(-2.626f,3.3f,2.625f));
m_voCaveVertices.push_back(new VistaVector3D(2.626f,3.3f,2.625f));
m_voCaveVertices.push_back(new VistaVector3D(2.626f,3.3f,-2.625f));
m_voCaveVertices.push_back(new VistaVector3D(-2.626f,3.3f,-2.625f));
// right handed coordinate system!
m_oCaveWalls.push_back(new ITANCTC::Wall(0,1,2,3,VistaVector3D(0,1,0),m_voCaveVertices)); // ground
m_oCaveWalls.push_back(new ITANCTC::Wall(0,3,7,4,VistaVector3D(1,0,0),m_voCaveVertices)); // left wall
......@@ -440,13 +436,13 @@ bool ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter )
m_sfCTC_temp.div_scalar( float( m_sfCTC_temp.length() ) );
// Shift the CTC filter according to desired delay
int iShiftSamples = int( m_oConfig.dSampleRate * m_fDelayTime );
if( m_fDelayTime < 0.0f )
int iShiftSamples = int( m_oConfig.dSampleRate * m_vfDelayTime[ n ] );
if( m_vfDelayTime[ n ] < 0.0f )
iShiftSamples = m_sfCTC_temp.length() / 2; // if invalid, shift by half length
sfTargetData_shift.cyclic_write( m_sfCTC_temp, m_sfCTC_temp.length(), 0, iShiftSamples );
m_fft.execute( sfTargetData_shift[0].data(), (*pCTCFilter)[0]->data() );
m_fft.execute( sfTargetData_shift[1].data(), (*pCTCFilter)[1]->data() );
m_fft.execute( sfTargetData_shift[ 0 ].data(), ( *pCTCFilter )[ 0 ]->data() );
m_fft.execute( sfTargetData_shift[ 1 ].data(), ( *pCTCFilter )[ 1 ]->data() );
//pCTCFilter->Export( "CTCFilter_shift_" + IntToString( n+1 ) );
}
......@@ -503,9 +499,20 @@ void ITANCTC::SetBeta( float fBeta )
{
m_fBeta = fBeta;
}
void ITANCTC::SetDelayTime( float fDelay )
void ITANCTC::SetDelayTime( float fDelayTime )
{
for( int n = 0; n < GetN(); n++ )
m_vfDelayTime[ n ] = fDelayTime;
}
void ITANCTC::SetDelayTime( std::vector< float > vfDelayTime )
{
m_fDelayTime = fDelay;
if( int( vfDelayTime.size() ) != GetN() )
ITA_EXCEPT1( INVALID_PARAMETER, "Provide as many delay values as channels for NCTC" );
for( int n = 0; n < GetN(); n++ )
m_vfDelayTime[ n ] = vfDelayTime[ n ];
}
float ITANCTC::GetBeta()
......@@ -513,9 +520,12 @@ float ITANCTC::GetBeta()
return m_fBeta;
}
float ITANCTC::GetDelay()
std::vector< float > ITANCTC::GetDelayTime()
{
return m_fDelayTime;
std::vector< float > vfDelayTime( GetN() );
for( int n = 0; n < GetN(); n++ )
vfDelayTime[ n ] = m_vfDelayTime[ n ];
return vfDelayTime;
}
void ITANCTC::SetOptimization( int iOptimization )
......
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