Finished refactoring and renaming

parent 3a334d98
......@@ -42,11 +42,11 @@
#include <VistaTools/VistaFileSystemFile.h>
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 );
......
......@@ -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.
*
......
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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" )
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <string>
#include <ITAException.h>
#include <ITAAudiofileReader.h>
#include <ITAAudiofileWriter.h>
#include <ITAUPConvolution.h>
#include <ITAUPFilter.h>
#include <ITAUPFilterPool.h>
#include <ITAFunctors.h>
#include <ITANumericUtils.h>
#include <ITAStringUtils.h>
using namespace std;
ITAAudiofileReader *pInputReader=NULL, *pFilterReader=NULL;
ITAAudiofileWriter *pOutputWriter=NULL;
vector<float*> vpfInputData;
vector<float*> vpfOutputData;
vector<float*> 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; i<uprdiv(o,b); i++) {
//for (int i=0; i<1; i++) {
conv->process(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; i<uprdiv(o,b); i++) {
//for (int i=0; i<1; i++) {
conv->process(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; i<uprdiv(o,b); i++) {
//for (int i=0; i<1; i++) {
if (i == 1) conv->exchangeFilter(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;
}
#include <stdio.h>
#include <cstring>
#include <ITAAudiofileReader.h>
#include <ITAAudiofileWriter.h>
#include <ITADirectConvolution.h>
#include <ITAStringUtils.h>
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<n; i++) h[i] = 1;
printf( "s = %s\n", FloatArrayToString( s, m ).c_str() );
printf( "h = %s\n", FloatArrayToString( h, n ).c_str() );
ITAConvolution conv( m, n );
conv.convolve( s, m, h, n, g, o );
printf( "g = %s\n", FloatArrayToString( g, o ).c_str() );
delete[] s;
delete[] h;
delete[] g;
}
int main( int argc, char* argv[] )
{
test1();
return 0;
}
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