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

Adding benchmark for SIMO VDL

parent c027ee0f
......@@ -80,3 +80,10 @@ if( ITA_CORE_LIBS_WITH_TESTS )
set( ITA_DSP_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
endif( )
# benchmarks
if( ITA_CORE_LIBS_WITH_BENCHMARKS )
set( ITA_DSP_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks" )
endif( )
cmake_minimum_required( VERSION 2.8 )
project( ITADSPTest )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITADSP REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
if( ITA_CORE_LIBS_BUILD_STATIC )
add_definitions( -DITA_BASE_STATIC -DITA_DSP_STATIC -DITA_DATA_SOURCES_STATIC )
endif( )
if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTATOOLS_STATIC -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTAINTERPROCCOMM_STATIC )
endif( )
add_executable( ITADSP_BM_SIMO_VDL ITADSP_BM_SIMO_VDL.cpp )
target_link_libraries( ITADSP_BM_SIMO_VDL ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITADSP_BM_SIMO_VDL )
vista_install( ITADSP_BM_SIMO_VDL )
vista_create_default_info_file( ITADSP_BM_SIMO_VDL )
set_property( TARGET ITADSP_BM_SIMO_VDL PROPERTY FOLDER "ITACoreLibs/Benchmarks/ITADSP" )
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
* Benchmark SIMO VDL I/O
*
*/
#include <ITASIMOVariableDelayLine.h>
#include <ITAStringUtils.h>
#include <ITAAudiofileWriter.h>
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>
#include <ITAStopWatch.h>
#include <ITAStreamFunctionGenerator.h>
#include <ITAFileDataSource.h>
#include <ITAStreamInfo.h>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
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;
const string sOutFilePath = "ITADSP_BM_SIMOVDL_out.wav";
int main( int, char** )
{
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 );
double dSamplerate = dSampleRate;
unsigned int uiBlocklength = iBlockLength;
unsigned int uiNumberOfFrames = ( unsigned int ) std::ceil( dSamplerate * fSimulateSeconds / ( float ) uiBlocklength );
std::vector< int > viCursors;
for( int i = 0; i < g_iNumCursors; i++ )
{
viCursors.push_back( pSIMOVDL->AddCursor() );
pSIMOVDL->SetDelaySamples( viCursors[ i ], float( iBlockLength * ( 2 + i ) ) );
}
ITAAudiofileProperties props_out;
props_out.iChannels = 1;
props_out.dSampleRate = 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 );
ITAStreamInfo oState;
ITASampleBuffer* psbInput = new ITASampleBuffer( uiBlocklength, true );
ITASampleFrame* psfOutput = new ITASampleFrame( pSIMOVDL->GetNumCursors(), uiBlocklength, true );
cout << "Processing ";
ITAStopWatch swBenchmark;
unsigned int n = 0;
while( n < uiNumberOfFrames )
{
// Add new samples
psbInput->write( pIntputStream->GetBlockPointer( 0, &oState ), uiBlocklength );
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
}
swBenchmark.start();
pSIMOVDL->ReadBlockAndIncrement( psfOutput );
swBenchmark.stop();
writer_out->write( psfOutput, uiBlocklength );
n++;
pIntputStream->IncrementBlockPointer();
if( n % ( uiNumberOfFrames / 40 ) == 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