Fixing uninitialized WICK and CTC factors in NCTC config (using default constructor init)

parent 5fd95eea
......@@ -114,6 +114,8 @@ public:
OPTIMIZATION_NONE = 0, //!< No optimization in filter design
};
Config();
int N; //!< Number of loudspeakers
int iCTCFilterLength; //!< CTC filter taps, i.e. 4096
double dSampleRate; //!< Sampling rate
......@@ -127,8 +129,9 @@ public:
public:
enum
{
LEFT_SIDE = 1,
RIGHT_SIDE = 2
SIDE_NOT_SPECIFIED = 0, //!@ Side of the loudspeaker not specified
LEFT_SIDE = 1, //!@ Loudspeaker is left from listener viewpoint
RIGHT_SIDE = 2, //!@ Loudspeaker is right from listener viewpoint
};
Loudspeaker();
Loudspeaker( const Pose& oStaticPose );
......
......@@ -22,6 +22,9 @@ ITANCTC::ITANCTC( const Config& oNCTCConfig )
{
m_fBeta = float( 1e-4 );
if( oNCTCConfig.N <= 0 )
ITA_EXCEPT1( INVALID_PARAMETER, "Wrong configuration, N-CTC requires a valid number of loudspeakers" );
m_iOptimization = m_oConfig.iOptimization;
m_fCrossTalkCancellationFactor = m_oConfig.fCrossTalkCancellationFactor;
m_fWaveIncidenceAngleCompensationFactor = m_oConfig.fWaveIncidenceAngleCompensationFactor;
......@@ -244,27 +247,31 @@ bool ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter )
for( int n=0; n<GetN(); n++ )
{
ITAHDFTSpectra* pHRTF( m_vpHRTFs[n] ); // two-channel
float HRTFEnergy[2];
HRTFEnergy[0]=(*pHRTF)[0]->getEnergy();
assert(HRTFEnergy[0]>0);
(*pHRTF)[0]->log();
(*pHRTF)[0]->mul(m_fWaveIncidenceAngleCompensationFactor);
(*pHRTF)[0]->exp();
float fEnergyCompensation = powf(HRTFEnergy[0],(1-m_fWaveIncidenceAngleCompensationFactor));
(*pHRTF)[0]->mul(fEnergyCompensation);
HRTFEnergy[1] = (*pHRTF)[1]->getEnergy();
assert(HRTFEnergy[1] > 0) ;
// Apply WIACF in cepstrum domain
( *pHRTF )[ 0 ]->log();
( *pHRTF )[ 0 ]->mul( m_fWaveIncidenceAngleCompensationFactor );
( *pHRTF )[ 0 ]->exp();
// Compensate initial HRTF energy when WIACF is used
float fEnergy = ( *pHRTF )[ 0 ]->getEnergy();
assert( fEnergy > 0 );
float fEnergyCompensation = powf( fEnergy, ( 1 - m_fWaveIncidenceAngleCompensationFactor ) );
( *pHRTF )[ 0 ]->mul( fEnergyCompensation );
// Apply WIACF in cepstrum domain
(*pHRTF)[1]->log();
(*pHRTF)[1]->mul(m_fWaveIncidenceAngleCompensationFactor);
(*pHRTF)[1]->exp();
fEnergyCompensation = powf(HRTFEnergy[1], (1 - m_fWaveIncidenceAngleCompensationFactor));
(*pHRTF)[1]->mul(fEnergyCompensation);
// Compensate initial HRTF energy when WIACF is used
fEnergy = ( *pHRTF )[ 1 ]->getEnergy();
assert( fEnergy > 0 );
fEnergyCompensation = powf( fEnergy, ( 1 - m_fWaveIncidenceAngleCompensationFactor ) );
( *pHRTF )[ 1 ]->mul( fEnergyCompensation );
// Weighting
float fWeight = float( m_vdWeights[n] ); // diag element
float fLeftChannel = 1;
......@@ -551,13 +558,13 @@ ITANCTC::Pose ITANCTC::GetHeadPose() const
ITANCTC::Config::Loudspeaker::Loudspeaker()
: pDirectivity(NULL)
, iSide(0)
, iSide( SIDE_NOT_SPECIFIED )
{
}
ITANCTC::Config::Loudspeaker::Loudspeaker( const Pose& oStaticPose )
: pDirectivity( NULL )
, iSide(0)
, iSide( SIDE_NOT_SPECIFIED )
{
oPose = oStaticPose;
}
......@@ -590,3 +597,14 @@ void ITANCTC::Pose::SetOrientationYPRdeg( double fYaw, double fPitch, double fRo
return;
}
ITANCTC::Config::Config()
{
// Set some default values
N = 0;
iCTCFilterLength = 4096;
fSpeedOfSound = 344.0f;
iOptimization = OPTIMIZATION_NONE;
fCrossTalkCancellationFactor = 1.0f;
fWaveIncidenceAngleCompensationFactor = 1.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