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

Adding measurement test for portaudio

parent de588df9
......@@ -64,8 +64,6 @@ const float* ITAStreamProbe::GetBlockPointer( unsigned int uiChannel, const ITAS
m_sfBuffer[ uiChannel ].write( pfData, GetBlocklength() );
m_vbDataPresent[ uiChannel ] = true;
}
else
assert( false );
return pfData;
}
......
......@@ -31,3 +31,15 @@ vista_install( ITAPortaudioInterfaceTest )
vista_create_default_info_file( ITAPortaudioInterfaceTest )
set_property( TARGET ITAPortaudioInterfaceTest PROPERTY FOLDER "ITATests/ITADataSources" )
add_executable( ITAPortaudioMeasurementTest ITAPortaudioMeasurementTest.cpp )
target_link_libraries( ITAPortaudioMeasurementTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_set_target_msvc_arguments( ITAPortaudioMeasurementTest "ITAPortaudioMeasurement_ExcitationSignal.wav ITAPortaudioMeasurement_Record.wav 44100 512" )
vista_configure_app( ITAPortaudioMeasurementTest )
vista_install( ITAPortaudioMeasurementTest )
vista_create_default_info_file( ITAPortaudioMeasurementTest )
set_property( TARGET ITAPortaudioMeasurementTest PROPERTY FOLDER "ITATests/ITADataSources" )
#include <ITADatasourceUtils.h>
#include <ITAPortaudioInterface.h>
#include <ITAStreamProbe.h>
#include <ITAFileDataSource.h>
#include <ITAException.h>
#include <ITAStringUtils.h>
#include <iostream>
#include <string>
using namespace std;
int main( int argc, char *argv[] )
{
if( argc != 5 )
ITA_EXCEPT1( INVALID_PARAMETER, "Syntax error: ITAPortaudioMeasurementTest.exe excitation.wav recording.wav samplerate blocklength" );
std::string sExcitationSignalPath = std::string( argv[ 1 ] );
std::string sRecordingSignalPath = std::string( argv[ 2 ] );
double dSampleRate = StringToDouble( std::string( argv[ 3 ] ) );
int iBlockLength = StringToInt( std::string( argv[ 4 ] ) );
// Recording
ITAPortaudioInterface ITAPA_IN( dSampleRate, iBlockLength );
int iInputDevice = ITAPA_IN.GetDefaultInputDevice();;
ITAPA_IN.Initialize( iInputDevice );
std::string sInDevice = ITAPA_IN.GetDeviceName( iInputDevice );
std::cout << sInDevice << std::endl;
int iNumInputChannels, temp;
ITAPA_IN.GetNumChannels( iInputDevice, iNumInputChannels, temp );
ITAPA_IN.SetPlaybackEnabled( false );
ITAPA_IN.SetRecordEnabled( true );
ITAStreamProbe oRecordStreamProbe( ITAPA_IN.GetRecordDatasource(), sRecordingSignalPath );
ITAPA_IN.Open();
// Playback
ITAPortaudioInterface ITAPA_OUT( dSampleRate, iBlockLength );
int iOutputDevice = ITAPA_OUT.GetDefaultOutputDevice();;
ITAPA_OUT.Initialize( iOutputDevice );
std::string sOutDevice = ITAPA_OUT.GetDeviceName( iOutputDevice );
std::cout << sOutDevice << std::endl;
int iNumOutputChannels;
ITAPA_OUT.GetNumChannels( iOutputDevice, temp, iNumOutputChannels );
ITAFileDatasource oPlayback( sExcitationSignalPath, iBlockLength );
// Start streaming
ITAPA_OUT.SetRecordEnabled( false );
ITAPA_OUT.SetPlaybackEnabled( true );
ITAPA_OUT.SetPlaybackDatasource( &oPlayback );
ITAPA_OUT.Open();
ITAPA_IN.Start();
ITAPA_OUT.Start();
// Measurement
WriteFromDatasourceToFile( &oRecordStreamProbe, sRecordingSignalPath, oPlayback.GetFileCapacity(), 1.0, true, true );
// Stop streaming
ITAPA_OUT.Stop();
ITAPA_OUT.Close();
ITAPA_OUT.Finalize();
ITAPA_IN.Stop();
ITAPA_IN.Close();
ITAPA_IN.Finalize();
return 0;
}
\ No newline at end of file
sweep = ita_generate_sweep;
ita_write_wav( sweep, 'ITAPortaudioInterfaceMeasurement_ExcitationSignal.wav', 'nBits', 32 );
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