Skip to content
Snippets Groups Projects
Select Git revision
  • 960e909f29d39d69c4485c724dde8cf85b34d6ff
  • master default protected
  • develop protected
  • feature/asio-profile
  • ti_lab_build
  • mbe
  • asio_stream_debugging_tools
  • ba_2016_heimes
  • jst
  • fabian
  • ITADataSources_v2024a
  • VA_v2023b
  • VA_v2023a
  • VA_v2022a
  • before_cmake_rework
  • v2021.a
  • v2020.a
  • v2019.a
  • v2018.b
  • v2018.a
  • v2017.d
  • v2017.c
  • v2017.b
  • good_after_refactoring
  • first_good_running_netaudio
  • v2017.a
  • v2016.a
27 results

ITANetAudioStreamingServerTest.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ITANetAudioStreamingServerTest.cpp 3.00 KiB
    #include <ITANetAudioStreamingServer.h>
    #include <ITAStreamFunctionGenerator.h>
    #include <ITAStreamMultiplier1N.h>
    #include <ITAFileDataSource.h>
    #include <ITAException.h>
    
    #include <VistaBase/VistaTimeUtils.h>
    
    #include <iostream>
    #include <string>
    #include <sstream>
    
    using namespace std;
    
    string g_sServerName = "localhost";
    int g_iServerPort = 12480;
    double g_dSampleRate = 44100.0;
    int g_iBlockLength = 512;
    int g_iChannels = 1;
    int g_iTargetLatencySamples = 4 * g_iBlockLength; // 1.4512ms
    int g_iRingBufferSize = 2 * g_iTargetLatencySamples;
    int g_iSendingBlockLength = 8;
    double g_dClientStatusMessageTimeout = 0.001; // seconds
    string g_sFileName = "gershwin-mono.wav";
    bool g_bDebuggingEnabled = true;
    
    int main( int argc, char** argv )
    {
    
    	if ( argc >= 8 )
    	{
    		g_sServerName = argv[ 1 ];
    
    		if ( argc >= 3 )
    		{
    			g_iServerPort = atoi( argv[ 2 ] );
    			g_dSampleRate = strtod( argv[ 3 ], NULL );
    			g_iBlockLength = atoi( argv[ 4 ] );
    			g_iChannels = atoi( argv[ 5 ] );
    			g_iTargetLatencySamples = atoi(argv[6]);
    			g_iRingBufferSize = atoi(argv[7]);
    			g_iSendingBlockLength = atoi(argv[8]);
    		}
    	}
    	else
    	{
    		cout << "Syntax: ServerName ServerPort SampleRate BufferSize Channel TargetLatencySamples RingBufferSize SnedingBlockLength" << endl;
    		cout << "Using default values ..." << endl;
    	}
    
    	ITADatasource* pSource = NULL;
    	try
    	{
    		pSource = new ITAFileDatasource( g_sFileName, g_iBlockLength );
    		static_cast< ITAFileDatasource* >( pSource )->SetIsLooping( true );
    		cout << "Found file " << g_sFileName << ", will use it for playback." << endl;
    
    	}
    	catch( ITAException& )
    	{
    		cout << "Could not find file " << g_sFileName << ", will use SINE signal instead." << endl;
    		pSource = new ITAStreamFunctionGenerator( 1, g_dSampleRate, g_iBlockLength, ITAStreamFunctionGenerator::SINE, 250.0f, 0.7171f, true );
    	}
    
    	ITAStreamMultiplier1N oMuliplier( pSource, g_iChannels );
    	CITANetAudioStreamingServer oStreamingServer;
    
    	stringstream ss;
    	ss << "ITANetAudioStreamingServerTest";
    	ss << "_C" << g_iChannels;