Refactoring NCTC

parent 74a0c562
......@@ -88,7 +88,7 @@ public:
/**
* \note All angles in degrees [°]
*/
void SetOrientationYPRdeg( double fYaw, double fPitch, double fRoll );
void SetOrientationYPRdeg( const float fYaw, const float fPitch, const float fRoll );
//! Get YPR angles
void GetOrientationYPRdeg( float& fYaw, float& fPitch, float& fRoll ) const;
......@@ -122,6 +122,7 @@ public:
int iOptimization; //!< Optimization algorithm (future work, see features/room_compensation)
float fCrossTalkCancellationFactor; //!< Factor for cross-talk cancellation (none = 0.0, full = 1.0)
float fWaveIncidenceAngleCompensationFactor; //!< Factor for cross-talk cancellation (none = 0.0, full = 1.0)
float fRegularizationFactor; //!< Regularization factor (beta)
class ITA_CTC_API Loudspeaker
{
......@@ -149,9 +150,9 @@ public:
* through the configuration's SelectedSpeakers list. The configuration may have more
* loudspeakers defined than are selected in the end.
*
* \note Throws ITAException errors
* @note Throws ITAException errors
*
* \param oNCTCConfig The configuration, see \Config
* @param[in] oNCTCConfig The configuration, see @Config
*
*/
ITANCTC( const Config& oNCTCConfig );
......@@ -159,12 +160,12 @@ public:
//! Destructor
~ITANCTC();
//! Get the number of loudspeaker for this CTC enginge
//! Get the number of loudspeakers/channels for this CTC engine
/**
* \return number of channels (N)
* @return Number of channels (N)
*
*/
int GetN() const;
int GetNumChannels() const;
//! Configuration getter
/**
......@@ -173,47 +174,47 @@ public:
const Config& GetConfig() const;
//! Get beta parameter
//! Get regularization factor (beta)
/**
* \return Beta parameter
*/
float GetBeta();
* @return Regularization factor
*/
float GetRegularizationFactor() const;
//! Set beta parameter
//! Set regularization factor
/**
* \param fBeta Set the beta regularization parameter
*/
void SetBeta( float fBeta );
* @param fRegularizationFator Set the regularization factor (beta)
*/
void SetRegularizationFactor( const float fRegularizationFator );
//! Get cross-talk cancellation factor
/**
* \return Factor [0..1]
*/
float GetCrossTalkCancellationFactor();
float GetCrossTalkCancellationFactor() const;
//! Set cross-talk cancellation factor
/**
* \param fFactor number between [0..1] (none: 0, max range = 1.0)
*/
void SetCrossTalkCancellationFactor( float fFactor );
void SetCrossTalkCancellationFactor( const float fFactor );
//! Get cross-talk cancellation factor
/**
* \return Factor [0..1]
*/
float GetWaveIncidenceAngleCompensation();
float GetWaveIncidenceAngleCompensation() const;
//! Set cross-talk cancellation factor
/**
* \param fFactor number between [0..1] (none: 0, max range = 1.0)
*/
void SetWaveIncidenceAngleCompensationFactor( float fFactor );
void SetWaveIncidenceAngleCompensationFactor( const float fFactor );
//! Get additional delay parameter
/**
* \return Delay in seconds
*/
std::vector< float > GetDelayTime();
std::vector< float > GetDelayTime() const;
//! Set additional delay parameter in seconds (affects all channels)
/**
......@@ -223,7 +224,7 @@ public:
*
* @param fDelayTime Set the time delay (all channels)
*/
void SetDelayTime( float fDelayTime );
void SetDelayTime( const float fDelayTime );
//! Set delay parameter in seconds for each loudspeaker channel individually
/**
......@@ -234,13 +235,13 @@ public:
*
* \param vfDelayTime Set the time delay (each channel/loudspeaker individually)
*/
void SetDelayTime( std::vector< float > vfDelayTime );
void SetDelayTime( const std::vector< float >& vfDelayTime );
//! Sets the optimization
/**
* Optimization setter, i.e. early reflection compensation for aixCAVE (see enum of Config)
*/
void SetOptimization( int iOptimization );
void SetOptimization( const int iOptimization );
//! Optimization getter
/**
......@@ -254,7 +255,7 @@ public:
* \return Returns the pose of a loudspeaker
*/
const Pose& GetLoudspeakerPose( int iLoudspeakerID ) const;
const Pose& GetLoudspeakerPose( const int iLoudspeakerID ) const;
//! Set HRIR dataset
/**
......@@ -302,18 +303,18 @@ public:
void CalculateFilter( std::vector< ITAHDFTSpectra* >& vpSpectra ) const;
//! Calculate the Wiener-Hopf factorization
void WienerHopfFactorization( ITAHDFTSpectrum* voSpecIn, ITAHDFTSpectrum* voSpecOutPlus, ITAHDFTSpectrum* voSpecOutMinus );
void WienerHopfFactorization( const ITAHDFTSpectrum* voSpecIn, ITAHDFTSpectrum* voSpecOutPlus, ITAHDFTSpectrum* voSpecOutMinus );
protected:
private:
const Config m_oConfig; //!< CTC Configuration
std::atomic< float > m_fBeta; //!< Beta parameter (regularization)
std::vector< float > m_vfDelayTime; //!< Add a delay [seconds] to the resulting CTC filter (individual channels)
std::atomic <int > m_iOptimization; //!< Optimization (see Config enum)
std::atomic< float > m_fCrossTalkCancellationFactor; //!< Factor for cross-talk cancellation (none = 0.0, full = 1.0)
std::atomic< float > m_fWaveIncidenceAngleCompensationFactor; //!< Factor for cross-talk cancellation (none = 0.0, full = 1.0)
mutable std::atomic< float > m_fRegularizationFactor; //!< Beta parameter (regularization)
mutable std::vector< float > m_vfDelayTime; //!< Add a delay [seconds] to the resulting CTC filter (individual channels)
std::atomic< int > m_iOptimization; //!< Optimization (see Config enum)
mutable std::atomic< float > m_fCrossTalkCancellationFactor; //!< Factor for cross-talk cancellation (none = 0.0, full = 1.0)
mutable std::atomic< float > m_fWaveIncidenceAngleCompensationFactor; //!< Factor for cross-talk cancellation (none = 0.0, full = 1.0)
const DAFFContentIR* m_pHRIR; //!< HRIR dataset pointer
Pose m_oHeadPose; //!< Current head Pose data
......@@ -321,13 +322,13 @@ private:
mutable ITAFFT m_fft, m_ifft; //!< Internal FFT and IFFT transformations
mutable ITASampleFrame m_sfCTC_temp; //!< Internal CTC helper
std::vector< double > m_vdWeights; //!< Diagonal values for the weighting matrix (W or Z), only non-zero entries allowed
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
int GetLoudspeakerSide( int ) const;
int GetLoudspeakerSide( const int ) const;
//! Adds a HRIR into the target filter
/**
......
This diff is collapsed.
......@@ -90,14 +90,14 @@ int main( int, char** )
ITANCTC ctc( oNCTCConfig );
// Settings
ctc.SetBeta( 0.001f );
ctc.SetRegularizationFactor( 0.001f );
// Update and calculate filter
ctc.SetHRIR( pHRIR );
ctc.UpdateHeadPose( oHead );
std::vector< ITAHDFTSpectra* > vpCTCFilter;
for( int n=0; n<ctc.GetN(); n++ )
for( int n=0; n<ctc.GetNumChannels(); n++ )
vpCTCFilter.push_back( new ITAHDFTSpectra( oNCTCConfig.fSampleRate, 2, oNCTCConfig.iCTCFilterLength+1, true ) );
try
......@@ -109,7 +109,7 @@ int main( int, char** )
std::cout << e << std::endl;
}
for( int i=0; i<ctc.GetN(); i++ )
for( int i=0; i<ctc.GetNumChannels(); i++ )
ITAFFTUtils::Export( vpCTCFilter[i], "CTCFilter_" + IntToString( i ) );
ITAStopWatch sw;
......@@ -133,7 +133,7 @@ int main( int, char** )
// Export resulting filter set to WAV file
for( int n=0; n<ctc.GetN(); n++ )
for( int n=0; n<ctc.GetNumChannels(); n++ )
{
ITAFFTUtils::Export( vpCTCFilter[ n ], "CTCFilter_LS" + IntToString( int( n + 1 ) ) );
ITAFFTUtils::Export( vpHRTF[ n ], "HRTFs_LS" + IntToString( int( 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