Commit 39a0c4ef authored by Anne's avatar Anne

added test for Portaudio

parent c6835c7b
......@@ -9,6 +9,16 @@ vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
add_definitions(-DIEEE754_64FLOAT)
add_executable( ITANetAudioStreamingPortaudioClientTest ITANetAudioStreamingPortaudioClientTest.cpp )
target_link_libraries( ITANetAudioStreamingPortaudioClientTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITANetAudioStreamingPortaudioClientTest )
vista_install( ITANetAudioStreamingPortaudioClientTest )
vista_create_default_info_file( ITANetAudioStreamingPortaudioClientTest )
set_property( TARGET ITANetAudioStreamingPortaudioClientTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
add_executable( ITANABufferServerTest ITANABufferServerTest.cpp )
target_link_libraries( ITANABufferServerTest ${VISTA_USE_PACKAGE_LIBRARIES} )
......
#include <iostream>
#include <string>
#include <ITANetAudioStream.h>
#include <ITAPortaudioInterface.h>
#include <ITAStreamMultiplier1N.h>
#include <ITAException.h>
#include <ITAFileDatasource.h>
#include <ITAStreamProbe.h>
#include <ITAStreamPatchbay.h>
using namespace std;
int main(int argc, char* argv[])
{
if (argc != 7)
{
cout << "argc = " << argc << endl;
cout << "sServerName = " << argv[1] << endl;
cout << "iServerPort = " << argv[2] << endl;
cout << "dSampleRate = " << argv[3] << endl;
cout << "iBlockLength = " << argv[4] << endl;
cout << "iChannels = " << argv[5] << endl;
cout << "iBufferSize = " << argv[6] << endl;
fprintf(stderr, "Fehler: Syntax = ServerName ServerPort SampleRate BufferSize Channel RingBufferSize!\n");
}
string sServerName = argv[1];
unsigned int iServerPort = atoi(argv[2]);
double dSampleRate = strtod(argv[3], NULL);
int iBlockLength = atoi(argv[4]);
int iChannels = atoi(argv[5]);
int iBufferSize = atoi(argv[6]);
CITANetAudioStream oNetAudioStream( iChannels, dSampleRate, iBlockLength, iBufferSize );
ITAStreamPatchbay oPatchbay( dSampleRate, iBufferSize );
oPatchbay.AddInput( &oNetAudioStream );
int iOutputID = oPatchbay.AddOutput( 2 );
int N = int( oNetAudioStream.GetNumberOfChannels( ) );
for ( int i = 0; i < N; i++ )
oPatchbay.ConnectChannels( 0, i, 0, i % 2, 1 / double( N ) );
ITAStreamProbe oProbe( oPatchbay.GetOutputDatasource( iOutputID ), "ITANetAudioTest.stream.wav" );
ITAPortaudioInterface ITAPA( dSampleRate, iBufferSize );
ITAPA.Initialize();
ITAPA.SetPlaybackDatasource( &oProbe );
ITAPA.Open();
ITAPA.Start();
cout << "Waiting 3 seconds (net audio stream not connected and returning zeros)" << endl;
ITAPA.Sleep( 2.0f );
cout << "Will now connect to '" << sServerName << "' on port " << iServerPort << endl;
try
{
if( !oNetAudioStream.Connect( sServerName, iServerPort ) )
ITA_EXCEPT1( INVALID_PARAMETER, "Could not connect to server" );
}
catch( ITAException e )
{
cout << "Connection failed." << endl;
cerr << e << endl;
return 255;
}
cout << "Connected." << endl;
// Playback
float fSeconds = 20.0f; // 15min
cout << "Playback started, waiting " << fSeconds << " seconds" << endl;
ITAPA.Sleep( fSeconds ); // blocking
cout << "Done." << endl;
cout << "Will now disconnect from '" << sServerName << "' and port " << iServerPort << endl;
cout << "Closing in 3 seconds (net audio stream not connected and returning zeros)" << endl;
ITAPA.Sleep( 1.0f );
ITAPA.Stop();
ITAPA.Close();
ITAPA.Finalize();
return 0;
}
\ No newline at end of file
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