diff --git a/CMakeLists.txt b/CMakeLists.txt index 33e5d442bcbbf1eac46ace170a1a23d753c0027e..3641dda2bfa7372508a602d52a97523e8ae8081c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,15 +43,8 @@ include_directories( "include" ) # sources -set( ITACTCHeader - "include/ITACTCDefinitions.h" - "include/ITACTCUtils.h" - "include/ITAHDFTSpectra.h" - ) -set( ITACTCSources - "src/ITACTCUtils.cpp" - "src/ITAHDFTSpectra.cpp" - ) +set( ITACTCHeader "include/ITACTCDefinitions.h" ) +set( ITACTCSources ) if( ITA_CTC_WITH_DUAL_CTC ) set( ITACTCHeader "${ITACTCHeader}" "include/ITADualCTC.h" "include/ITADualCTCStreamFilter.h" ) diff --git a/include/ITACTCUtils.h b/include/ITACTCUtils.h deleted file mode 100644 index 57172d327ed3575d0b03b662061967361af3a747..0000000000000000000000000000000000000000 --- a/include/ITACTCUtils.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -* ---------------------------------------------------------------- -* -* ITA core libs -* (c) Copyright Institute of Technical Acoustics (ITA) -* RWTH Aachen University, Germany, 2015-2016 -* -* ---------------------------------------------------------------- -* ____ __________ _______ -* // / //__ ___/ // _ | -* // / // / // /_| | -* // / // / // ___ | -* //__/ //__/ //__/ |__| -* -* ---------------------------------------------------------------- -* -*/ -// $Id: ITACTCHelper.h 2395 2012-04-20 06:58:52Z stienen $ - -#ifndef INCLUDE_WATCHER_ITA_CTC_UTILS -#define INCLUDE_WATCHER_ITA_CTC_UTILS - -#include - -class ITAHDFTSpectrum; - -#include - -// Helper -ITA_CTC_API void Export( const ITAHDFTSpectrum* pSpectrum, const std::string& sFilePath ); - -#endif // INCLUDE_WATCHER_ITA_CTC_UTILS diff --git a/include/ITAHDFTSpectra.h b/include/ITAHDFTSpectra.h deleted file mode 100644 index fe37c8af6c099cb7fb4648372955e7c599191a7e..0000000000000000000000000000000000000000 --- a/include/ITAHDFTSpectra.h +++ /dev/null @@ -1,118 +0,0 @@ -/* -* ---------------------------------------------------------------- -* -* ITA core libs -* (c) Copyright Institute of Technical Acoustics (ITA) -* RWTH Aachen University, Germany, 2015-2016 -* -* ---------------------------------------------------------------- -* ____ __________ _______ -* // / //__ ___/ // _ | -* // / // / // /_| | -* // / // / // ___ | -* //__/ //__/ //__/ |__| -* -* ---------------------------------------------------------------- -* -*/ -// $Id: ITAHDFTSpectra.h 2727 2012-06-26 13:15:00Z stienen $ - -#ifndef INCLUDE_WATCHER_ITA_HDFT_SPECTRUM -#define INCLUDE_WATCHER_ITA_HDFT_SPECTRUM - -// ITA includes -#include -#include - -// STL includes -#include - -class ITAHDFTSpectrum; - -//! Multi-channel half-sided discrete fourier spectra -/** - * - * This class describes DFT spectrum data with variable number channels - * and provides functionality for manipulation and math operations. - * - * This class extends the \ITAHDFTSpectrum for multi-channel applications. - * - */ -class ITA_CTC_API ITAHDFTSpectra -{ -public: - - //! Constructor that initializes the - ITAHDFTSpectra( const double dSampleRate, const int iNumChannels, const int iDFTSize, const bool bZeroInit=true ); - - //! Constructor that uses a non-empty HDFTSpectrum vector - ITAHDFTSpectra( const std::vector< ITAHDFTSpectrum* >& vpSpectrumVec ); - - //! Standard destructor - ~ITAHDFTSpectra(); - - //! Return number of channels - /** - * \return Number of spectra / dimension of filter - */ - int GetNumChannels() const; - - //! Return DFT size - /** - * \return Number of coeffs + 1 for DC value - */ - int GetDFTSize() const; - - //! Return sampling rate - double GetSampleRate() const; - - //! Adds the given spectra channel-wise - void add( const ITAHDFTSpectra* ); - - //! Subtracts the given spectra channel-wise - void sub( const ITAHDFTSpectra* ); - - //! Multiplies the given spectra channel-wise - void mul( const ITAHDFTSpectra* ); - - //! Multiplies the conjugate of the given spectra without data copy channel-wise - void mul_conj( const ITAHDFTSpectra* ); - - //! Multiplies a scalar - void mul_scalar( double ); - - //! Divides the given spectra channel-wise - void div( const ITAHDFTSpectra* ); - - //! Set unity (all coefficiants real one) - void SetUnity(); - - //! Set unity (all coefficiants real one) - void SetZero(); - - //! Copy from another Spectra - void CopyFrom(const ITAHDFTSpectra* otherSpectra); - - //! Subscript operator gives direct access to spectrum channel - const ITAHDFTSpectrum* operator[]( const int ) const; - ITAHDFTSpectrum* operator[]( const int ); - - //! Export to hard drive - /** - * This function exports the data to hard drive - * by converting to time domain and saving a - * multi-channel WAV file. - * - * \param sFilePath Path to the taget file (auto-adds '.wav' if no suffix given) - * \param bNormalize normalizes using max peak in all channels (perserving relative difference between channels) - */ - void Export( const std::string& sFilePath, bool bNormalize = false ) const; - -private: - //! Standard constructor - ITAHDFTSpectra(); - - std::vector< ITAHDFTSpectrum* > m_vpSpectra; //! DFT spectra -}; - -#endif // INCLUDE_WATCHER_ITA_HDFT_SPECTRUM \ No newline at end of file diff --git a/src/ITACTCUtils.cpp b/src/ITACTCUtils.cpp deleted file mode 100644 index d3cc50eac9481aa1e6aec1cb70d0132959bbacb1..0000000000000000000000000000000000000000 --- a/src/ITACTCUtils.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include - -// Helper -void Export( const ITAHDFTSpectrum* pSpectrum, const std::string& sFilePath ) -{ - - ITASampleBuffer sbImpulseResponse( pSpectrum->getDFTSize()-1, true ); - ITASampleBuffer sbSpectrum( pSpectrum->getDFTSize(), true ); // local copy - - ITAFFT ifft( ITAFFT::IFFT_C2R, sbImpulseResponse.length(), sbSpectrum.GetData(), sbImpulseResponse.GetData() ); - - // Make local copy of input (will be destroyed by in-place FFT) - sbSpectrum.write( pSpectrum->data(), sbSpectrum.length() ); - float* fIn = sbSpectrum.GetData(); - float* fOut = sbImpulseResponse.GetData(); - ifft.execute( fIn, fOut ); - - // Normalize after IFFT - sbImpulseResponse.div_scalar( float( sbImpulseResponse.length() ) ); - - std::string sFilePathComplete = sFilePath; - if( getFilenameSuffix( sFilePath ).empty() ) - sFilePathComplete += ".wav"; - - //writeAudiofile( correctPath( sFilePathComplete ), &sbImpulseResponse, pSpectrum->getSamplerate(), ITA_FLOAT ); - - return; -} diff --git a/src/ITAHDFTSpectra.cpp b/src/ITAHDFTSpectra.cpp deleted file mode 100644 index 4a899f0c8354e3c2864b746947e5ece1e27cf080..0000000000000000000000000000000000000000 --- a/src/ITAHDFTSpectra.cpp +++ /dev/null @@ -1,210 +0,0 @@ -#include "ITAHDFTSpectra.h" - -#include -#include -#include -#include -#include -#include - -ITAHDFTSpectra::ITAHDFTSpectra( const double dSampleRate, const int iNumChannels, const int iDFTSize, const bool bZeroInit/*=true*/ ) -{ - if( iNumChannels < 1 ) - ITA_EXCEPT1( INVALID_PARAMETER, "At least one DFT channel must be used" ); - if( iDFTSize < 1 ) - ITA_EXCEPT1( INVALID_PARAMETER, "Invalid DFT size" ); - - for( int i=0; i& vpSpectrumVec ) -{ - if( vpSpectrumVec.size() == 0 ) - ITA_EXCEPT1( INVALID_PARAMETER, "At least one DFT channel must be used" ); - - for( size_t i=0; igetDFTSize() <= 0 ) - ITA_EXCEPT1( INVALID_PARAMETER, "Invalid DFT size in spectrum number " + IntToString( int(i) ) ); - - if( pSpectrum->getSamplerate() <= 0 ) - ITA_EXCEPT1( INVALID_PARAMETER, "Invalid sampling rate in spectrum number " + IntToString( int(i) ) ); - - m_vpSpectra.push_back( new ITAHDFTSpectrum( pSpectrum ) ); // copy - } -} - -ITAHDFTSpectra::~ITAHDFTSpectra() -{ - for( size_t i=0; iGetNumChannels(); - - m_vpSpectra.clear(); - - for( int i=0; iGetSampleRate()),int(otherSpectra->GetDFTSize())); - ITAHDFTSpectrum* tempSpectrum = new ITAHDFTSpectrum((*otherSpectra)[i]); - //tempSpectrum->copyFrom((*otherSpectra)[i]); - m_vpSpectra.push_back(tempSpectrum); - } -} - -void ITAHDFTSpectra::SetUnity() -{ - for( size_t i=0; iSetUnity(); - } -} - -void ITAHDFTSpectra::SetZero() -{ - for( size_t i=0; imul( 0.0f ); - } -} - - -void ITAHDFTSpectra::Export( const std::string& sFilePath, bool bNormalize/*=false*/ ) const -{ - ITASampleFrame sfTargetData( GetNumChannels(), GetDFTSize()-1, true ); - ITASampleBuffer sbSourceData( GetDFTSize(), true ); // local copy - - ITAFFT ifft( ITAFFT::IFFT_C2R, sfTargetData.GetLength(), sbSourceData.GetData(), sfTargetData[0].GetData() ); - - for( int i=0; idata(), sbSourceData.GetLength() ); - float* fIn = sbSourceData.GetData(); - float* fOut = sfTargetData[i].GetData(); - ifft.execute( fIn, fOut ); - } - - // Normalize after IFFT - sfTargetData.div_scalar( float( sfTargetData.length() ) ); - if( bNormalize ) sfTargetData.normalize(); - - std::string sFilePathComplete = sFilePath; - if( getFilenameSuffix( sFilePath ).empty() ) - sFilePathComplete += ".wav"; - - writeAudiofile( correctPath( sFilePathComplete ), &sfTargetData, GetSampleRate(), ITAQuantization::ITA_FLOAT ); - - return; -} - -int ITAHDFTSpectra::GetNumChannels() const -{ - return int( m_vpSpectra.size() ); -} - -int ITAHDFTSpectra::GetDFTSize() const -{ - return m_vpSpectra[0]->getDFTSize(); -} - -double ITAHDFTSpectra::GetSampleRate() const -{ - return m_vpSpectra[0]->getSamplerate(); -} - -void ITAHDFTSpectra::add( const ITAHDFTSpectra* pSource ) -{ - if( GetNumChannels() != pSource->GetNumChannels() ) - ITA_EXCEPT1( INVALID_PARAMETER, "Channel number mismatch" ); - - for( int i=0; iadd( pSourceSpectrum ); - } - - return; -} - -void ITAHDFTSpectra::sub( const ITAHDFTSpectra* pSource ) -{ - if( GetNumChannels() != pSource->GetNumChannels() ) - ITA_EXCEPT1( INVALID_PARAMETER, "Channel number mismatch" ); - - for( int i=0; isub( pSourceSpectrum ); - } - - return; -} - -void ITAHDFTSpectra::mul( const ITAHDFTSpectra* pSource ) -{ - if( GetNumChannels() != pSource->GetNumChannels() ) - ITA_EXCEPT1( INVALID_PARAMETER, "Channel number mismatch" ); - - for( int i=0; imul( pSourceSpectrum ); - } - - return; -} - -void ITAHDFTSpectra::mul_conj( const ITAHDFTSpectra* pSource ) -{ - if( GetNumChannels() != pSource->GetNumChannels() ) - ITA_EXCEPT1( INVALID_PARAMETER, "Channel number mismatch" ); - - for( int i=0; imul( pSourceSpectrum ); - } - - return; -} - -void ITAHDFTSpectra::mul_scalar( double ) -{ - ITA_EXCEPT0( NOT_IMPLEMENTED ); -} - -void ITAHDFTSpectra::div( const ITAHDFTSpectra* pSource ) -{ - if( GetNumChannels() != pSource->GetNumChannels() ) - ITA_EXCEPT1( INVALID_PARAMETER, "Channel number mismatch" ); - - for( int i=0; idiv( pSourceSpectrum ); - } - - return; -} - -const ITAHDFTSpectrum* ITAHDFTSpectra::operator[]( const int iIdx ) const -{ - return m_vpSpectra[iIdx]; -} -ITAHDFTSpectrum* ITAHDFTSpectra::operator[]( const int iIdx ) -{ - return m_vpSpectra[iIdx]; -} diff --git a/src/ITANCTC.cpp b/src/ITANCTC.cpp index 71e23be701acd6e869069d4e9a90902ec30a52b8..862343f3faac1aa4b7a3d2ec0fd655175c4753b4 100644 --- a/src/ITANCTC.cpp +++ b/src/ITANCTC.cpp @@ -1,7 +1,6 @@ // $Id: ITANCTC.cpp 2395 2012-04-20 06:58:52Z stienen $ #include -#include #include #include diff --git a/tests/NCTC_CTCFilterTest.cpp b/tests/NCTC_CTCFilterTest.cpp index d46c16da94e4bd248faad9268e349cb3a08f3411..ed076170f559aef7c6d8452905e89a13c7368619 100644 --- a/tests/NCTC_CTCFilterTest.cpp +++ b/tests/NCTC_CTCFilterTest.cpp @@ -1,15 +1,15 @@ #include -#include #include #include #include +#include #include #include -int main( int argc, char* argv[] ) +int main( int, char** ) { // HRIR //std::string sHRIRFileName = correctPath( "../../../../VAData/HRIR/ITA-Kunstkopf_HRIR_AP11_Pressure_Equalized_3x3_256.daff" ); @@ -110,7 +110,7 @@ int main( int argc, char* argv[] ) } for( int i=0; iExport( "CTCFilter_" + IntToString( i ) ); + ITAFFTUtils::Export( vpCTCFilter[i], "CTCFilter_" + IntToString( i ) ); ITAStopWatch sw; std::cout << "Starting loop "; @@ -118,7 +118,7 @@ int main( int argc, char* argv[] ) { sw.start(); ctc.CalculateFilter( vpCTCFilter ); - double desr = sw.stop(); + sw.stop(); if( i % 100 == 0 ) std::cout << "."; } std::cout << std::endl; @@ -135,8 +135,8 @@ int main( int argc, char* argv[] ) // Export resulting filter set to WAV file for( int n=0; nExport( "CTCFilter_LS" + IntToString( int(n+1) ) ); - vpHRTF[n]->Export("HRTFs_LS" + IntToString(int(n+1))); + ITAFFTUtils::Export( vpCTCFilter[ n ], "CTCFilter_LS" + IntToString( int( n + 1 ) ) ); + ITAFFTUtils::Export( vpHRTF[ n ], "HRTFs_LS" + IntToString( int( n + 1 ) ) ); } delete pHRIR;