From 576d7fa7198d98c7b76caf75ce134947afb026cd Mon Sep 17 00:00:00 2001 From: Jonas Stienen Date: Thu, 18 May 2017 16:34:15 +0200 Subject: [PATCH] Finished refactoring and renaming --- apps/ita_convoi/ita_convoi.cpp | 10 +- include/ITAUPFilter.h | 2 +- include/ITAUPFilterPool.h | 2 +- src/ITAUPConvolution.cpp | 4 +- tests/CMakeLists.txt | 24 ++-- tests/DSMBCTest.cpp | 203 --------------------------------- tests/ITAConvolutionTest.cpp | 52 --------- 7 files changed, 21 insertions(+), 276 deletions(-) delete mode 100644 tests/DSMBCTest.cpp delete mode 100644 tests/ITAConvolutionTest.cpp diff --git a/apps/ita_convoi/ita_convoi.cpp b/apps/ita_convoi/ita_convoi.cpp index eacfdc6..18bf0cf 100644 --- a/apps/ita_convoi/ita_convoi.cpp +++ b/apps/ita_convoi/ita_convoi.cpp @@ -42,11 +42,11 @@ #include -class ITAStreamConvolver : public ITADatasourceRealizationEventHandler, public DSMBCConvolver +class ITAStreamConvolver : public ITADatasourceRealizationEventHandler, public ITAUPConvolution { public: inline ITAStreamConvolver( const double dSampleRate, const int iBlockLength, const int iFilterLength ) - : DSMBCConvolver( iBlockLength, iFilterLength ) + : ITAUPConvolution( iBlockLength, iFilterLength ) , pdsInput( NULL ) { m_pdsOutput = new ITADatasourceRealization( 1, dSampleRate, iBlockLength ); @@ -59,7 +59,7 @@ public: ITA_EXCEPT1( MODAL_EXCEPTION, "Input data source not defined yet" ); const float* pfInputData = pdsInput->GetBlockPointer( 0, pStreamInfo ); - process( pfInputData, getBlocklength(), m_pdsOutput->GetWritePointer( 0 ), getBlocklength(), DSMBCConvolver::OUTPUT_OVERWRITE ); + process( pfInputData, getBlocklength(), m_pdsOutput->GetWritePointer( 0 ), getBlocklength(), ITAUPConvolution::OUTPUT_OVERWRITE ); m_pdsOutput->IncrementWritePointer(); }; @@ -303,7 +303,7 @@ std::string ita_convoi_commands() void ita_convio_exchange_channel( ITAStreamConvolver* pSC, const ITASampleFrame& sfIR, const int iChannelIndex ) { assert( sfIR.channels() > iChannelIndex ); - DSMBCFilter* pFilter = pSC->requestFilter(); + ITAUPFilter* pFilter = pSC->requestFilter(); pFilter->load( sfIR[ iChannelIndex ].GetData(), sfIR.GetLength() ); pSC->exchangeFilter( pFilter ); pSC->releaseFilter( pFilter ); @@ -313,7 +313,7 @@ void ita_convio_exchange_channel( ITAStreamConvolver* pSC, const ITASampleFrame& void ita_convio_dirac_channel( ITAStreamConvolver* pSC ) { - DSMBCFilter* pFilter = pSC->requestFilter(); + ITAUPFilter* pFilter = pSC->requestFilter(); pFilter->identity(); pSC->exchangeFilter( pFilter ); pSC->releaseFilter( pFilter ); diff --git a/include/ITAUPFilter.h b/include/ITAUPFilter.h index 86fd188..94a6260 100644 --- a/include/ITAUPFilter.h +++ b/include/ITAUPFilter.h @@ -34,7 +34,7 @@ class ITAFFT; /** * Diese Klasse realisiert Filter (d.h. Representationen von Impulsantworten im Frequenzbereich) - * für DSMBCConvolver. Solche Filter haben einen Zustand: 1) unbenutzt oder 2) momentan in einem + * für ITAUPConvolution. Solche Filter haben einen Zustand: 1) unbenutzt oder 2) momentan in einem * Falter in Benutzung. Generell kann 1 Filter in beliebig vielen Faltern verwendet werden. * Seine Daten dürfen aber nur modifiziert werden, wenn es nicht in Benutzung ist. * diff --git a/include/ITAUPFilterPool.h b/include/ITAUPFilterPool.h index 214a87e..713f434 100644 --- a/include/ITAUPFilterPool.h +++ b/include/ITAUPFilterPool.h @@ -76,7 +76,7 @@ public: /** * Ist das Filter nicht in Benutzung, so kann es sofort weiterbenutzt werden. * Ist das Filter in Benutzung, so wird es für die Weiterbenutzung freigebenen, - * sobald es in einem Falter (DSMBCConvolver) nicht mehr in Benutzung ist + * sobald es in einem Falter (ITAUPConvolution) nicht mehr in Benutzung ist */ void releaseFilter( ITAUPFilter* pFilter ); diff --git a/src/ITAUPConvolution.cpp b/src/ITAUPConvolution.cpp index 660ff9d..90d4d55 100644 --- a/src/ITAUPConvolution.cpp +++ b/src/ITAUPConvolution.cpp @@ -223,7 +223,7 @@ ITAUPFilter* ITAUPConvolution::getActiveFilter() void ITAUPConvolution::exchangeFilter( ITAUPFilter* pNewFilter, const int iExchangeMode, const int iCrossfadeLength ) { - //DEBUG_PRINTF("[DSMBCConvolver 0x%08Xh] Exchanging to filter 0x%08Xh\n", this, pNewFilter); + //DEBUG_PRINTF("[ITAUPConvolution 0x%08Xh] Exchanging to filter 0x%08Xh\n", this, pNewFilter); // Platzierung des Filter vermerken if( pNewFilter ) @@ -327,7 +327,7 @@ void ITAUPConvolution::process( const float* pfInputData, const int iInputLength // Wichtig: Ein Switching bei den Updates ist dominant bForceSwitch |= ( xmode == SWITCH ); - //DEBUG_PRINTF("[DSMBCConvolver 0x%08Xh] Popped next filter 0x%08Xh\n", this, Z); + //DEBUG_PRINTF("[ITAUPConvolution 0x%08Xh] Popped next filter 0x%08Xh\n", this, Z); if( N ) N->m_oState.removePrep(); N = Z; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4cb2713..a2d47e8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,21 +10,21 @@ if( NOT ITA_CORE_LIBS_BUILD_STATIC ) add_definitions( -DITA_BASE_STATIC -DITA_FFT_STATIC -DITA_CONVOLUTION_STATIC ) endif( ) -add_executable( ITAConvolutionTest "ITAConvolutionTest.cpp" ) -target_link_libraries( ITAConvolutionTest ${VISTA_USE_PACKAGE_LIBRARIES} ) +add_executable( ITADirectConvolutionTest "ITADirectConvolutionTest.cpp" ) +target_link_libraries( ITADirectConvolutionTest ${VISTA_USE_PACKAGE_LIBRARIES} ) -vista_configure_app( ITAConvolutionTest ) -vista_install( ITAConvolutionTest ) -vista_create_default_info_file( ITAConvolutionTest ) +vista_configure_app( ITADirectConvolutionTest ) +vista_install( ITADirectConvolutionTest ) +vista_create_default_info_file( ITADirectConvolutionTest ) -set_property( TARGET ITAConvolutionTest PROPERTY FOLDER "ITACoreLibs/Tests/ITAConvolution" ) +set_property( TARGET ITADirectConvolutionTest PROPERTY FOLDER "ITACoreLibs/Tests/ITAConvolution" ) -add_executable( DSMBCTest "DSMBCTest.cpp" ) -target_link_libraries( DSMBCTest ${VISTA_USE_PACKAGE_LIBRARIES} ) +add_executable( ITAUniformPartitionedConvolutionTest "ITAUniformPartitionedConvolutionTest.cpp" ) +target_link_libraries( ITAUniformPartitionedConvolutionTest ${VISTA_USE_PACKAGE_LIBRARIES} ) -vista_configure_app( DSMBCTest ) -vista_install( DSMBCTest ) -vista_create_default_info_file( DSMBCTest ) +vista_configure_app( ITAUniformPartitionedConvolutionTest ) +vista_install( ITAUniformPartitionedConvolutionTest ) +vista_create_default_info_file( ITAUniformPartitionedConvolutionTest ) -set_property( TARGET DSMBCTest PROPERTY FOLDER "ITACoreLibs/Tests/ITAConvolution" ) +set_property( TARGET ITAUniformPartitionedConvolutionTest PROPERTY FOLDER "ITACoreLibs/Tests/ITAConvolution" ) diff --git a/tests/DSMBCTest.cpp b/tests/DSMBCTest.cpp deleted file mode 100644 index dd3098d..0000000 --- a/tests/DSMBCTest.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace std; - -ITAAudiofileReader *pInputReader=NULL, *pFilterReader=NULL; -ITAAudiofileWriter *pOutputWriter=NULL; -vector vpfInputData; -vector vpfOutputData; -vector vpfFilterData; - -void test1() { - // Einfaches Durchfalten. Kein Austausch - const int m=16; - const int n=8; - const int b=4; - int o = uprmul(m+n-1, b); - - float* s = new float[m]; - float* h = new float[n]; - float* g = new float[o]; - - memset(s, 0, m*sizeof(float)); - memset(h, 0, n*sizeof(float)); - memset(g, 0, o*sizeof(float)); - - for (int i=0; i<(m>>1); i++) s[i] = 1; - for (int i=0; i<(n>>1); i++) h[i] = 1; - - DSMBCConvolver* conv = new DSMBCConvolver(b, n); - - DSMBCFilter* filter1 = new DSMBCFilter(b, n); - filter1->load(h, n); - - conv->exchangeFilter(filter1); - - int j=0; - for (int i=0; iprocess(s+j, g+j); - j += b; - } - - delete conv; - delete filter1; - - delete[] s; - delete[] h; - delete[] g; -} - -void test2() { - // Einfaches Durchfalten. Einblenden - const int m=16; - const int n=8; - const int b=4; - int o = uprmul(m+n-1, b); - - float* s = new float[m]; - float* h = new float[n]; - float* g = new float[o]; - - memset(s, 0, m*sizeof(float)); - memset(h, 0, n*sizeof(float)); - memset(g, 0, o*sizeof(float)); - - for (int i=0; i<(m>>1); i++) s[i] = 1; - for (int i=0; i<(n>>1); i++) h[i] = 1; - - DSMBCConvolver* conv = new DSMBCConvolver(b, n); - conv->setFilterExchangeMode(DSMBCConvolver::CROSSFADE_LINEAR); - conv->setFilterCrossfadeLength(3); - - DSMBCFilter* filter1 = new DSMBCFilter(b, n); - //conv->destroyFilter(filter1); - filter1->load(h, n); - - conv->exchangeFilter(filter1); - - int j=0; - for (int i=0; iprocess(s, g); - j += b; - } - - delete conv; - delete filter1; - - delete[] s; - delete[] h; - delete[] g; -} - -void test3() { - // Einfaches Durchfalten. Einblenden - const int m=16; - const int n=8; - const int b=4; - int o = uprmul(m+n-1, b); - - float* s = new float[m]; - float* h1 = new float[n]; - float* h2 = new float[n]; - float* g = new float[o]; - - memset(s, 0, m*sizeof(float)); - memset(h1, 0, n*sizeof(float)); - memset(h2, 0, n*sizeof(float)); - memset(g, 0, o*sizeof(float)); - - for (int i=0; i<(m>>1); i++) s[i] = 1; - for (int i=0; i<(n>>1); i++) h1[i] = 1; - h2[n-1] = 1; - - DSMBCConvolver* conv = new DSMBCConvolver(b, n); - conv->setFilterExchangeMode(DSMBCConvolver::CROSSFADE_LINEAR); - conv->setFilterCrossfadeLength(3); - - DSMBCFilterPool* pool = new DSMBCFilterPool(b, n, 0); - DSMBCFilter* filter1 = pool->requestFilter(); - DSMBCFilter* filter2 = pool->requestFilter(); - //conv->destroyFilter(filter1); - filter1->load(h1, n); - filter2->load(h2, n); - - conv->exchangeFilter(filter1); - - int j=0; - for (int i=0; iexchangeFilter(filter2); - // vvv f�r Bereichspr�fung auf s - conv->process(s, g); - j += b; - } - - //writeAudiofile("out.wav", g, o, 44100); - printf("s = (%s)\n", FloatArrayToString(s, m, 1).c_str()); - printf("h1 = (%s)\n", FloatArrayToString(h1, n, 1).c_str()); - printf("h2 = (%s)\n", FloatArrayToString(h2, n, 1).c_str()); - printf("g = (%s)\n", FloatArrayToString(g, m+n-1, 1).c_str()); - - - delete conv; - delete pool; - - delete[] s; - delete[] h1; - delete[] h2; - delete[] g; -} - -void test_filterpool() { - // Einfaches Durchfalten. Einblenden - const int b=8; - const int n=8; - float* s = new float[n]; - - DSMBCConvolver* conv = new DSMBCConvolver(b, n); - DSMBCFilterPool* pool = new DSMBCFilterPool(b, n, 0); - - DSMBCFilter* f1 = pool->requestFilter(); - conv->exchangeFilter(f1); - conv->process(s, s); - f1->release(); - - DSMBCFilter* f2 = pool->requestFilter(); - conv->exchangeFilter(f2); - conv->process(s, s); - - DSMBCFilter* f3 = pool->requestFilter(); - conv->exchangeFilter(f2); - conv->process(s, s); - - delete conv; - delete pool; - - delete[] s; -} - -int main(int argc, char* argv[]) { - - test1(); - //test2(); - //test3(); - //test_filterpool(); - return 0; -} - diff --git a/tests/ITAConvolutionTest.cpp b/tests/ITAConvolutionTest.cpp deleted file mode 100644 index 273a4d7..0000000 --- a/tests/ITAConvolutionTest.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include - -#include -#include - -#include -#include - -using namespace std; - - -void test1() -{ - // Einfaches Durchfalten. Kein Austausch - const int m = 7; - const int n = 5; - int o = m + n - 1; - - float* s = new float[ m ]; - float* h = new float[ n ]; - float* g = new float[ o ]; - - memset( s, 0, m*sizeof( float ) ); - memset( h, 0, n*sizeof( float ) ); - memset( g, 0, o*sizeof( float ) ); - - for( int i = 0; i < ( m >> 1 ); i++ ) s[ i ] = 1; - for( int i = 0; i < ( n >> 1 ); i++ ) h[ i ] = 1; - //for (int i=0; i