Commit 4eb3c544 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Merge branch 'develop'

parents 9de0e43e ed64d04a
HTML
*.bat
*.mat
*.pdf
*.dll
*.exe
*.so*
Thumbs.db
.DS_Store
*.asv
*.wav
*.xlsx
*.docx
*.dll
*.csv
*.h5
*.ita
*.fig
*.png
*.jpeg
*.sofa
*.spk
*.unv
*.stl
svnaccess
*.lib
*.exp
......@@ -13,29 +13,21 @@ vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITAConvolution REQUIRED FIND_DEPENDENCIES )
vista_use_package( OpenDAFF REQUIRED )
if( NOT DEFINED ITA_CORE_LIBS_BUILD_STATIC )
set( ITA_CORE_LIBS_BUILD_STATIC OFF CACHE BOOL "Build all ITA core libs in static mode" )
endif( NOT DEFINED ITA_CORE_LIBS_BUILD_STATIC )
if( NOT DEFINED ITA_VISTA_BUILD_STATIC )
set( ITA_VISTA_BUILD_STATIC OFF CACHE BOOL "Build against static ViSTA libraries" )
endif( NOT DEFINED ITA_VISTA_BUILD_STATIC )
if( NOT DEFINED ITA_CTC_WITH_DUAL_CTC )
set( ITA_CTC_WITH_DUAL_CTC OFF CACHE BOOL "Build support for Crosstalk-Cancellation with arbitrary loudspeaker number and pose" )
endif( NOT DEFINED ITA_CTC_WITH_DUAL_CTC )
endif( )
if( NOT DEFINED ITA_CTC_WITH_N_CTC )
set( ITA_CTC_WITH_N_CTC ON CACHE BOOL "Build support for two-loudspeaker Crosstalk-Cancellation (deprecated)" )
endif( NOT DEFINED ITA_CTC_WITH_N_CTC )
endif( )
if( NOT DEFINED ITA_CTC_WITH_QUAD_CTC )
set( ITA_CTC_WITH_QUAD_CTC OFF CACHE BOOL "Build support for quad-loudspeaker Crosstalk-Cancellation (deprecated)" )
endif( NOT DEFINED ITA_CTC_WITH_QUAD_CTC )
endif( )
if( NOT DEFINED ITA_CTC_NCTC_EXPORT_FILTER_TO_HARDDRIVE )
set( ITA_CTC_NCTC_EXPORT_FILTER_TO_HARDDRIVE OFF CACHE BOOL "Export HRIR input,, intermediate results and final CTC filter set to harddrive (as multi-channel WAV files)" )
endif( NOT DEFINED ITA_CTC_NCTC_EXPORT_FILTER_TO_HARDDRIVE )
endif( )
# includes
......@@ -43,57 +35,43 @@ 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" )
set( ITACTCSources "${ITACTCSources}" "src/ITADualCTC.cpp" "src/ITADualCTCStreamFilter.cpp" )
endif( ITA_CTC_WITH_DUAL_CTC )
endif( )
if( ITA_CTC_WITH_N_CTC )
set( ITACTCHeader "${ITACTCHeader}" "include/ITANCTC.h" "include/ITANCTCStreamFilter.h" )
set( ITACTCSources "${ITACTCSources}" "src/ITANCTC.cpp" "src/ITANCTCStreamFilter.cpp" )
endif( ITA_CTC_WITH_N_CTC )
endif( )
if( ITA_CTC_WITH_QUAD_CTC )
set( ITACTCHeader "${ITACTCHeader}" "include/ITAQuadCTC.h" "include/ITAQuadCTCStreamFilter.h" )
set( ITACTCSources "${ITACTCSources}" "src/ITAQuadCTC.cpp" "src/ITAQuadCTCStreamFilter.cpp" )
endif( ITA_CTC_WITH_QUAD_CTC )
endif( )
if( ITA_CTC_NCTC_EXPORT_FILTER_TO_HARDDRIVE )
add_definitions( -DNCTC_EXPORT_FILTER_TO_HARDDRIVE )
endif( ITA_CTC_NCTC_EXPORT_FILTER_TO_HARDDRIVE )
endif( )
# compiler settings
if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
endif( ITA_VISTA_BUILD_STATIC )
endif( )
if( NOT ITA_CORE_LIBS_BUILD_STATIC )
if( BUILD_SHARED_LIBS )
add_definitions( -DITA_CTC_EXPORT )
else( NOT ITA_CORE_LIBS_BUILD_STATIC )
add_definitions( -DITA_FFT_STATIC -DITA_BASE_STATIC -DITA_CONVOLUTION_STATIC -DITA_CTC_STATIC )
set( BUILD_SHARED_LIBS_TEMP ${BUILD_SHARED_LIBS} )
if( BUILD_SHARED_LIBS )
set( BUILD_SHARED_LIBS OFF )
message( "Ignoring activated BUILD_SHARED_LIBS temporary because static ITA core libs requested" )
endif( BUILD_SHARED_LIBS )
endif( NOT ITA_CORE_LIBS_BUILD_STATIC )
else( )
add_definitions( -DITA_CTC_STATIC -DITA_CONVOLUTION_STATIC -DITA_FFT_STATIC -DITA_BASE_STATIC -DITA_DATA_SOURCES_STATIC )
endif( )
# linker
add_library( ITACTC ${ITACTCHeader} ${ITACTCSources} )
target_link_libraries( ITACTC ${VISTA_USE_PACKAGE_LIBRARIES} )
set( BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_TEMP} )
# configure
vista_configure_lib( ITACTC )
......@@ -106,5 +84,7 @@ set_property( TARGET ITACTC PROPERTY FOLDER "ITACoreLibs" )
# tests
set( ITACTC_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
if( ITA_CORE_LIBS_WITH_TESTS )
set( ITACTC_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
endif( )
Copyright 2015-2016 Institute of Technical Acoustics, RWTH Aachen University. Any usage and distribution is prohibited, unless explicitly granted by the authors.
\ No newline at end of file
Copyright 2015-2017 Institute of Technical Acoustics, RWTH Aachen University. Any usage and distribution is prohibited, unless explicitly granted by the authors.
\ No newline at end of file
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
......
/*
* ----------------------------------------------------------------
*
* 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 <ITACTCDefinitions.h>
class ITAHDFTSpectrum;
#include <string>
// Helper
ITA_CTC_API void Export( const ITAHDFTSpectrum* pSpectrum, const std::string& sFilePath );
#endif // INCLUDE_WATCHER_ITA_CTC_UTILS
/*
* ----------------------------------------------------------------
*
* 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 <ITACTCDefinitions.h>
#include <ITAException.h>
// STL includes
#include <vector>
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
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
// $Id: ITANCTC.h 2395 2012-04-20 06:58:52Z stienen $
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_N_CTC
#define INCLUDE_WATCHER_ITA_N_CTC
......
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
// $Id: ITACircularNCTCStreamingFilter.h 2395 2012-04-20 06:58:52Z stienen $
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_N_CTC_STREAMING_FILTER
#define INCLUDE_WATCHER_ITA_N_CTC_STREAMING_FILTER
......
#include <ITACTCUtils.h>
#include <ITAHDFTSpectra.h>
#include <ITAAudiofileWriter.h>
#include <ITAFFT.h>
#include <ITAFilesystemUtils.h>
#include <ITAHDFTSpectrum.h>
#include <ITASampleFrame.h>
// 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;
}
#include "ITAHDFTSpectra.h"
#include <ITAAudiofileWriter.h>
#include <ITAFFT.h>
#include <ITAFilesystemUtils.h>
#include <ITAHDFTSpectrum.h>
#include <ITASampleFrame.h>
#include <ITAStringUtils.h>
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<iNumChannels; i++ )
m_vpSpectra.push_back( new ITAHDFTSpectrum( dSampleRate, iDFTSize, bZeroInit ) );
}
ITAHDFTSpectra::ITAHDFTSpectra( const std::vector< ITAHDFTSpectrum* >& vpSpectrumVec )
{
if( vpSpectrumVec.size() == 0 )
ITA_EXCEPT1( INVALID_PARAMETER, "At least one DFT channel must be used" );
for( size_t i=0; i<vpSpectrumVec.size(); i++ )
{
const ITAHDFTSpectrum* pSpectrum( vpSpectrumVec[i] );
if( pSpectrum->getDFTSize() <= 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; i<m_vpSpectra.size(); i++ )
delete m_vpSpectra[i];
}
void ITAHDFTSpectra::CopyFrom(const ITAHDFTSpectra *otherSpectra)
{
int iNumChannels=otherSpectra->GetNumChannels();
m_vpSpectra.clear();
for( int i=0; i<iNumChannels; i++ )
{
//ITAHDFTSpectrum* tempSpectrum = new ITAHDFTSpectrum(double(otherSpectra->GetSampleRate()),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; i<m_vpSpectra.size(); i++ )
{
ITAHDFTSpectrum* pSpectrum( m_vpSpectra[i] );
pSpectrum->SetUnity();
}
}
void ITAHDFTSpectra::SetZero()
{
for( size_t i=0; i<m_vpSpectra.size(); i++ )
{
ITAHDFTSpectrum* pSpectrum( m_vpSpectra[i] );
pSpectrum->mul( 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; i<GetNumChannels(); i++ )
{
// Make local copy of input (will be destroyed by in-place FFT)
sbSourceData.write( m_vpSpectra[i]->data(), 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; i<GetNumChannels(); i++ )
{
ITAHDFTSpectrum* pSpectrum( m_vpSpectra[i] );
const ITAHDFTSpectrum* pSourceSpectrum( (*pSource)[i] );
pSpectrum->add( pSourceSpectrum );
}
return;
}
void ITAHDFTSpectra::sub( const ITAHDFTSpectra* pSource )
{
if( GetNumChannels() != pSource->GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Channel number mismatch" );
for( int i=0; i<GetNumChannels(); i++ )
{
ITAHDFTSpectrum* pSpectrum( m_vpSpectra[i] );
const ITAHDFTSpectrum* pSourceSpectrum( (*pSource)[i] );
pSpectrum->sub( pSourceSpectrum );
}
return;
}
void ITAHDFTSpectra::mul( const ITAHDFTSpectra* pSource )
{
if( GetNumChannels() != pSource->GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Channel number mismatch" );
for( int i=0; i<GetNumChannels(); i++ )
{
ITAHDFTSpectrum* pSpectrum( m_vpSpectra[i] );
const ITAHDFTSpectrum* pSourceSpectrum( (*pSource)[i] );
pSpectrum->mul( pSourceSpectrum );
}
return;
}
void ITAHDFTSpectra::mul_conj( const ITAHDFTSpectra* pSource )
{
if( GetNumChannels() != pSource->GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Channel number mismatch" );
for( int i=0; i<GetNumChannels(); i++ )
{
ITAHDFTSpectrum* pSpectrum( m_vpSpectra[i] );
const ITAHDFTSpectrum* pSourceSpectrum( (*pSource)[i] );
pSpectrum->mul( 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; i<GetNumChannels(); i++ )
{
ITAHDFTSpectrum* pSpectrum( m_vpSpectra[i] );
const ITAHDFTSpectrum* pSourceSpectrum( (*pSource)[i] );
pSpectrum->div( pSourceSpectrum );
}
return;
}
const ITAHDFTSpectrum* ITAHDFTSpectra::operator[]( const int iIdx ) const
{
return m_vpSpectra[iIdx];
}
ITAHDFTSpectrum* ITAHDFTSpectra::operator[]( const int iIdx )
{
return m_vpSpectra[iIdx];
}
// $Id: ITANCTC.cpp 2395 2012-04-20 06:58:52Z stienen $
#include <ITANCTC.h>
#include <ITACTCUtils.h>
#include <assert.h>
#include <complex>
......@@ -15,6 +12,7 @@
#include <ITAHDFTSpectrum.h>
#include <ITANumericUtils.h>
#include <ITAStringUtils.h>
#include <ITAFFTUtils.h>
ITANCTC::ITANCTC( const Config& oNCTCConfig )
: m_oConfig( oNCTCConfig )
......@@ -227,7 +225,7 @@ bool ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter )
m_fft.execute( m_sfCTC_temp[ 1 ].data(), ( *pHRTF )[ 1 ]->data() );
#ifdef NCTC_EXPORT_FILTER_TO_HARDDRIVE
pHRTF->Export( "HRIR_LS" + IntToString( n+1 ) + "_RAW" );
ITAFFTUtils::Export(pHRTF, "HRIR_LS" + IntToString(n + 1) + "_RAW");
#endif // NCTC_EXPORT_FILTER_TO_HARDDRIVE
}
......@@ -292,7 +290,7 @@ bool ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter )