Commit a9cd985c authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

WIP on SIMO VDL benchmarks

parent 0c70c50a
......@@ -25,6 +25,7 @@
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>
#include <ITAStopWatch.h>
#include <ITAConfigUtils.h>
#include <ITAStreamFunctionGenerator.h>
#include <ITAFileDataSource.h>
......@@ -36,90 +37,149 @@
#include <vector>
using namespace std;
const std::string sBMFilePath = "ITADSP_BM_SIMO_VDL.ini";
const unsigned int iBlockLength = 128;
const double dSampleRate = 44.1e3;
const float fMaxReservedDelaySamples = 5 * iBlockLength;
const float fSimulateSeconds = 10;
const float fInitialDelaySamples = 10 * 2 * iBlockLength - 1;
const int g_iNumCursors = 128;
struct ParameterSet
{
unsigned int iBlockLength;
double dSampleRate;
float fMaxReservedDelaySamples;
float fInitialDelaySamples;
int iNumCursors;
string sWAVOutFilePath;
int iInterpolationType;
int iNumFrames;
float fDelayIncrementSample;
inline ParameterSet()
{
iBlockLength = 32;
dSampleRate = 44.1e3;
fMaxReservedDelaySamples = 100 * iBlockLength;
fInitialDelaySamples = 10 * 2 * iBlockLength - 1;
iNumCursors = 256;
sWAVOutFilePath = "ITADSP_BM_SIMOVDL_L32.wav";
iInterpolationType = CITASIMOVariableDelayLine::CUBIC_SPLINE_INTERPOLATION;
iNumFrames = 1e6;
fDelayIncrementSample = 1.0f;
};
inline void WriteToINIFile( const std::string& sSection ) const
{
INIFileWriteDouble( sBMFilePath, sSection, "SampleRate", dSampleRate );
INIFileWriteDouble( sBMFilePath, sSection, "BlockTimeSeconds", iBlockLength / dSampleRate );
INIFileWriteString( sBMFilePath, sSection, "BlockTime", timeToString( iBlockLength / dSampleRate ) );
};
};
const string sOutFilePath = "ITADSP_BM_SIMOVDL_out.wav";
void run_benchmark( const ParameterSet&, const std::string& );
int main( int, char** )
{
cout << "Starting single-input multiple-output variable delay line benchmark" << endl;
ParameterSet pm;
pm.iNumFrames = 100;
// 32 samples block length
pm.iBlockLength = 32;
pm.fDelayIncrementSample = 1.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p1" );
pm.fDelayIncrementSample = 2.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p2" );
pm.fDelayIncrementSample = 4.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p4" );
pm.fDelayIncrementSample = 8.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p8" );
pm.fDelayIncrementSample = 16.0f;
run_benchmark( pm, "Benchmark_L32_stretch_p16" );
pm.fDelayIncrementSample = -1.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n1" );
pm.fDelayIncrementSample = -2.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n2" );
pm.fDelayIncrementSample = -4.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n4" );
pm.fDelayIncrementSample = -8.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n8" );
pm.fDelayIncrementSample = -16.0f;
run_benchmark( pm, "Benchmark_L32_stretch_n16" );
// 64 samples block length
pm.iBlockLength = 64;
pm.fDelayIncrementSample = 1.0f;
run_benchmark( pm, "Benchmark_L64_stretch_p1" );
cout << "Done." << endl;
ITAStreamFunctionGenerator sinesignal( 1, dSampleRate, iBlockLength, ITAStreamFunctionGenerator::SINE, 500.0f, 0.9f, true );
ITADatasource* pIntputStream = &sinesignal;
CITASIMOVariableDelayLine* pSIMOVDL = new CITASIMOVariableDelayLine( dSampleRate, iBlockLength, fMaxReservedDelaySamples, CITASIMOVariableDelayLine::CUBIC_SPLINE_INTERPOLATION );
return 255;
}
double dSamplerate = dSampleRate;
unsigned int uiBlocklength = iBlockLength;
unsigned int uiNumberOfFrames = ( unsigned int ) std::ceil( dSamplerate * fSimulateSeconds / ( float ) uiBlocklength );
void run_benchmark( const ParameterSet& pm, const std::string& sName )
{
pm.WriteToINIFile( sName );
ITAStreamFunctionGenerator sinesignal( 1, pm.dSampleRate, pm.iBlockLength, ITAStreamFunctionGenerator::SINE, 500.0f, 0.9f, true );
ITADatasource* pIntputStream = &sinesignal;
CITASIMOVariableDelayLine* pSIMOVDL = new CITASIMOVariableDelayLine( pm.dSampleRate, pm.iBlockLength, pm.fMaxReservedDelaySamples, pm.iInterpolationType );
std::vector< int > viCursors;
for( int i = 0; i < g_iNumCursors; i++ )
for( int i = 0; i < pm.iNumCursors; i++ )
{
viCursors.push_back( pSIMOVDL->AddCursor() );
pSIMOVDL->SetDelaySamples( viCursors[ i ], float( iBlockLength * ( 2 + i ) ) );
pSIMOVDL->SetDelaySamples( viCursors[ i ], float( pm.iBlockLength * ( 50 + i ) ) );
}
ITAAudiofileProperties props_out;
props_out.iChannels = 1;
props_out.dSampleRate = dSamplerate;
props_out.dSampleRate = pm.dSampleRate;
props_out.eQuantization = ITAQuantization::ITA_FLOAT;
props_out.eDomain = ITADomain::ITA_TIME_DOMAIN;
props_out.iLength = uiNumberOfFrames * uiBlocklength;
props_out.iChannels = pSIMOVDL->GetNumCursors();
ITAAudiofileWriter* writer_out = ITAAudiofileWriter::create( sOutFilePath, props_out );
props_out.iLength = pm.iNumFrames * ( unsigned int ) ( pm.iBlockLength );
props_out.iChannels = 1;
ITAAudiofileWriter* writer_out = ITAAudiofileWriter::create( pm.sWAVOutFilePath, props_out );
ITAStreamInfo oState;
ITASampleBuffer* psbInput = new ITASampleBuffer( uiBlocklength, true );
ITASampleFrame* psfOutput = new ITASampleFrame( pSIMOVDL->GetNumCursors(), uiBlocklength, true );
cout << "Processing ";
ITASampleBuffer* psbInput = new ITASampleBuffer( pm.iBlockLength, true );
ITASampleFrame* psfOutput = new ITASampleFrame( pSIMOVDL->GetNumCursors(), pm.iBlockLength, true );
ITASampleFrame sfTemp( 1, pm.iBlockLength, true );
ITAStopWatch swBenchmark;
unsigned int n = 0;
while( n < uiNumberOfFrames )
while( n < pm.iNumFrames )
{
// Add new samples
psbInput->write( pIntputStream->GetBlockPointer( 0, &oState ), uiBlocklength );
psbInput->write( pIntputStream->GetBlockPointer( 0, &oState ), pm.iBlockLength );
pSIMOVDL->WriteBlock( psbInput );
for( size_t i = 0; i < viCursors.size(); i++ )
{
const float fCurrentDelay = pSIMOVDL->GetCurrentDelaySamples( viCursors[ i ] );
pSIMOVDL->SetDelaySamples( viCursors[ i ], fCurrentDelay + 1.0f ); // Keep Doppler ratio constant
pSIMOVDL->SetDelaySamples( viCursors[ i ], fCurrentDelay + pm.fDelayIncrementSample ); // Keep Doppler ratio constant
}
swBenchmark.start();
pSIMOVDL->ReadBlockAndIncrement( psfOutput );
swBenchmark.stop();
writer_out->write( psfOutput, uiBlocklength );
sfTemp.zero();
for( int i = 0; i < psfOutput->GetNumChannels(); i++ )
sfTemp[0].add_buf( ( *psfOutput )[ i ] );
writer_out->write( &sfTemp, sfTemp.GetLength() );
n++;
pIntputStream->IncrementBlockPointer();
if( n % ( uiNumberOfFrames / 40 ) == 0 )
if( n % ( pm.iNumFrames / 100 ) == 0 )
cout << ".";
}
cout << " done." << endl;
cout << "Output file: " << sOutFilePath << endl;
cout << "Benchmark: " << swBenchmark << endl;
delete writer_out;
delete psbInput;
delete psfOutput;
return 255;
}
Supports Markdown
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