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

Portaudio measurement test tweaks

parent a5416e73
......@@ -36,7 +36,7 @@ set_property( TARGET ITAPortaudioInterfaceTest PROPERTY FOLDER "ITATests/ITAData
add_executable( ITAPortaudioMeasurementTest ITAPortaudioMeasurementTest.cpp )
target_link_libraries( ITAPortaudioMeasurementTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_set_target_msvc_arguments( ITAPortaudioMeasurementTest "${CMAKE_CURRENT_SOURCE_DIR}/ITAPortaudioInterfaceMeasurement_ExcitationSignal.wav ${CMAKE_CURRENT_SOURCE_DIR}/ITAPortaudioInterfaceMeasurement_Record.wav 44100 512" )
vista_set_target_msvc_arguments( ITAPortaudioMeasurementTest "${CMAKE_CURRENT_SOURCE_DIR}/ITAPortaudioMeasurement_ExcitationSignal.wav ${CMAKE_CURRENT_SOURCE_DIR}/ITAPortaudioMeasurement_Record.wav 44100 512" )
vista_configure_app( ITAPortaudioMeasurementTest )
vista_install( ITAPortaudioMeasurementTest )
......
......@@ -14,59 +14,66 @@ int main( int argc, char *argv[] )
{
if( argc != 5 )
ITA_EXCEPT1( INVALID_PARAMETER, "Syntax error: ITAPortaudioMeasurementTest.exe excitation.wav recording.wav samplerate blocklength" );
try
{
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 ] ) );
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 << "Input device identifier: " << sInDevice << endl;
int iNumInputChannels, temp;
ITAPA_IN.GetNumChannels( iInputDevice, iNumInputChannels, temp );
// 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.SetPlaybackEnabled( false );
ITAPA_IN.SetRecordEnabled( true );
ITAStreamProbe oRecordStreamProbe( ITAPA_IN.GetRecordDatasource(), sRecordingSignalPath );
ITAPA_IN.Open();
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 << "Output device identifier: " << sOutDevice << endl;
int iNumOutputChannels;
ITAPA_OUT.GetNumChannels( iOutputDevice, temp, iNumOutputChannels );
// 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 );
ITAFileDatasource oPlayback( sExcitationSignalPath, iBlockLength );
// Start streaming
ITAPA_OUT.SetRecordEnabled( false );
ITAPA_OUT.SetPlaybackEnabled( true );
ITAPA_OUT.SetPlaybackDatasource( &oPlayback );
// Start streaming
ITAPA_OUT.SetRecordEnabled( false );
ITAPA_OUT.SetPlaybackEnabled( true );
ITAPA_OUT.SetPlaybackDatasource( &oPlayback );
ITAPA_OUT.Open();
ITAPA_OUT.Open();
ITAPA_IN.Start();
ITAPA_OUT.Start();
ITAPA_IN.Start();
ITAPA_OUT.Start();
// Measurement
WriteFromDatasourceToFile( &oRecordStreamProbe, sRecordingSignalPath, oPlayback.GetFileCapacity(), 1.0, true, true );
// Measurement
WriteFromDatasourceToFile( &oRecordStreamProbe, sRecordingSignalPath, oPlayback.GetFileCapacity(), 1.0, true, true );
// Stop streaming
ITAPA_OUT.Stop();
ITAPA_OUT.Close();
ITAPA_OUT.Finalize();
// Stop streaming
ITAPA_OUT.Stop();
ITAPA_OUT.Close();
ITAPA_OUT.Finalize();
ITAPA_IN.Stop();
ITAPA_IN.Close();
ITAPA_IN.Finalize();
ITAPA_IN.Stop();
ITAPA_IN.Close();
ITAPA_IN.Finalize();
}
catch( const ITAException& e )
{
cerr << e << endl;
}
return 0;
}
\ No newline at end of file
sweep = ita_generate_sweep;
ita_write_wav( sweep, 'ITAPortaudioInterfaceMeasurement_ExcitationSignal.wav', 'nBits', 32 );
sweep_raw = ita_generate_sweep;
sweep_2ch = ita_merge( sweep_raw * 0.1, sweep_raw * 0 );
ita_write_wav( sweep_2ch, 'ITAPortaudioMeasurement_ExcitationSignal.wav', 'nBits', 32, 'overwrite' );
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