API changes from ITAHDFTSpectrum

parent b615ebf0
......@@ -219,35 +219,35 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
// --- WICK factor ---
// First, store original energy of HRTF (left channel)
const float fEnergyLeftChannel = ( *pHRTF )[ 0 ]->getEnergy();
const float fEnergyLeftChannel = ( *pHRTF )[ 0 ]->GetEnergy();
// Apply WICK factor only on magnitudes (left channel)
for( int i = 0; i < ( *pHRTF )[ 0 ]->GetSize(); i++ )
{
float fMag = ( *pHRTF )[ 0 ]->calcMagnitude( i );
( *pHRTF )[ 0 ]->setMagnitudePreservePhase( i, std::pow( fMag, m_fWaveIncidenceAngleCompensationFactor ) );
float fMag = ( *pHRTF )[ 0 ]->CalcMagnitude( i );
( *pHRTF )[ 0 ]->SetMagnitudePreservePhase( i, std::pow( fMag, m_fWaveIncidenceAngleCompensationFactor ) );
}
// Compensate initial HRTF energy when WICK is used (left channel)
assert( fEnergyLeftChannel > 0 );
const float fEnergyCompensationLeftChannel = std::pow( fEnergyLeftChannel, ( 1 - m_fWaveIncidenceAngleCompensationFactor ) );
( *pHRTF )[ 0 ]->mul( fEnergyCompensationLeftChannel );
( *pHRTF )[ 0 ]->Mul( fEnergyCompensationLeftChannel );
// First, store original energy of HRTF only on magnitudes (right channel)
const float fEnergyRightChannel = ( *pHRTF )[ 1 ]->getEnergy();
const float fEnergyRightChannel = ( *pHRTF )[ 1 ]->GetEnergy();
// Apply WICK factor only on magnitude (right channel)
for( int i = 0; i < ( *pHRTF )[ 1 ]->GetSize(); i++ )
{
float fMag = ( *pHRTF )[ 1 ]->calcMagnitude( i );
( *pHRTF )[ 1 ]->setMagnitudePreservePhase( i, std::pow( fMag, m_fWaveIncidenceAngleCompensationFactor ) );
float fMag = ( *pHRTF )[ 1 ]->CalcMagnitude( i );
( *pHRTF )[ 1 ]->SetMagnitudePreservePhase( i, std::pow( fMag, m_fWaveIncidenceAngleCompensationFactor ) );
}
// Compensate initial HRTF energy when WICK is used (right channel)
assert( fEnergyRightChannel > 0 );
const float fEnergyCompensationRightChannel = std::pow( fEnergyRightChannel, ( 1 - m_fWaveIncidenceAngleCompensationFactor ) );
( *pHRTF )[ 1 ]->mul( fEnergyCompensationRightChannel );
( *pHRTF )[ 1 ]->Mul( fEnergyCompensationRightChannel );
#ifdef NCTC_EXPORT_FILTER_TO_HARDDRIVE
......@@ -266,8 +266,8 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
if( iLSSide == Config::Loudspeaker::RIGHT_SIDE )
fLeftChannelCTC *= m_fCrossTalkCancellationFactor; // only apply to right channel if LS is at right side
( *pHRTF )[ 0 ]->mul( fLeftChannelCTC );
( *pHRTF )[ 1 ]->mul( fRightChannelCTC );
( *pHRTF )[ 0 ]->Mul( fLeftChannelCTC );
( *pHRTF )[ 1 ]->Mul( fRightChannelCTC );
#ifdef NCTC_EXPORT_FILTER_TO_HARDDRIVE
ITAFFTUtils::Export(pHRTF, "HRIR_LS" + IntToString(n + 1) + "_WICKedPlusCTCFactor");
......@@ -277,43 +277,43 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
const float& fWeight( m_vfWeights[ n ] ); // diag element
// Element wise (a and d): HWH* -> 2x2
t->copy( ( *pHRTF )[ 0 ] );
t->mul( fWeight );
t->Copy( ( *pHRTF )[ 0 ] );
t->Mul( fWeight );
t->mul_conj( ( *pHRTF )[ 0 ] );
n == 0 ? a->copy( t ) : a->add( t );
t->MulConj( ( *pHRTF )[ 0 ] );
n == 0 ? a->Copy( t ) : a->Add( t );
t->copy( ( *pHRTF )[ 1 ] );
t->mul( fWeight );
t->Copy( ( *pHRTF )[ 1 ] );
t->Mul( fWeight );
t->mul_conj( ( *pHRTF )[ 1 ] );
n == 0 ? d->copy( t ) : d->add( t );
t->MulConj( ( *pHRTF )[ 1 ] );
n == 0 ? d->Copy( t ) : d->Add( t );
// Cross elements (b and c): HWH*
t->copy( ( *pHRTF )[ 1 ] );
t->mul( fWeight );
t->Copy( ( *pHRTF )[ 1 ] );
t->Mul( fWeight );
t->mul_conj( ( *pHRTF )[ 0 ] );
n == 0 ? b->copy( t ) : b->add( t );
t->MulConj( ( *pHRTF )[ 0 ] );
n == 0 ? b->Copy( t ) : b->Add( t );
t->copy( ( *pHRTF )[ 0 ] );
t->mul( fWeight );
t->Copy( ( *pHRTF )[ 0 ] );
t->Mul( fWeight );
t->mul_conj( ( *pHRTF )[ 1 ] );
n == 0 ? c->copy( t ) : c->add( t );
t->MulConj( ( *pHRTF )[ 1 ] );
n == 0 ? c->Copy( t ) : c->Add( t );
}
// Regularize
a->add( m_fRegularizationFactor );
d->add( m_fRegularizationFactor );
a->Add( m_fRegularizationFactor );
d->Add( m_fRegularizationFactor );
ITAHDFTSpectra abcd( m_oConfig.fSampleRate, 4, m_oConfig.iCTCFilterLength );
abcd[ 0 ]->copyFrom( *a );
abcd[ 1 ]->copyFrom( *b );
abcd[ 2 ]->copyFrom( *c );
abcd[ 3 ]->copyFrom( *d );
abcd[ 0 ]->CopyFrom( *a );
abcd[ 1 ]->CopyFrom( *b );
abcd[ 2 ]->CopyFrom( *c );
abcd[ 3 ]->CopyFrom( *d );
// Invert via determinant (simple 2x2 matrix inversion)
......@@ -321,21 +321,21 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
* d/det -b/det
* -c/det a/det
*/
det->copy( a );
det->mul( d );
t->copy( b );
t->mul( c );
det->sub( t );
t->copy( d );
d->copy( a );
a->copy( t );
b->mul( -1.0f );
c->mul( -1.0f );
a->div( det );
b->div( det );
c->div( det );
d->div( det );
det->Copy( a );
det->Mul( d );
t->Copy( b );
t->Mul( c );
det->Sub( t );
t->Copy( d );
d->Copy( a );
a->Copy( t );
b->Mul( -1.0f );
c->Mul( -1.0f );
a->Div( det );
b->Div( det );
c->Div( det );
d->Div( det );
// Calculate CTC filter WH*Inv (Nx2)
......@@ -348,24 +348,24 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
ITAHDFTSpectra* pCTCFilter( vpCTCFilter[ n ] ); // two-channel
const float& fWeight( m_vfWeights[ n ] ); // diag element
t->copy( a );
t->mul_conj( ( *pHRTF )[ 0 ] );
t->mul( fWeight );
( *pCTCFilter )[ 0 ]->copy( t );
t->copy( b );
t->mul_conj( ( *pHRTF )[ 1 ] );
t->mul( fWeight );
( *pCTCFilter )[ 0 ]->add( t );
t->copy( c );
t->mul_conj( ( *pHRTF )[ 0 ] );
t->mul( fWeight );
( *pCTCFilter )[ 1 ]->copy( t );
t->copy( d );
t->mul_conj( ( *pHRTF )[ 1 ] );
t->mul( fWeight );
( *pCTCFilter )[ 1 ]->add( t );
t->Copy( a );
t->MulConj( ( *pHRTF )[ 0 ] );
t->Mul( fWeight );
( *pCTCFilter )[ 0 ]->Copy( t );
t->Copy( b );
t->MulConj( ( *pHRTF )[ 1 ] );
t->Mul( fWeight );
( *pCTCFilter )[ 0 ]->Add( t );
t->Copy( c );
t->MulConj( ( *pHRTF )[ 0 ] );
t->Mul( fWeight );
( *pCTCFilter )[ 1 ]->Copy( t );
t->Copy( d );
t->MulConj( ( *pHRTF )[ 1 ] );
t->Mul( fWeight );
( *pCTCFilter )[ 1 ]->Add( t );
#ifdef NCTC_EXPORT_FILTER_TO_HARDDRIVE
ITAFFTUtils::Export(pCTCFilter, "CTCFilter_noshift_" + IntToString(n + 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