Removing net stream audio classes (moved to VACore due to dependencies to ITACoreLibs)

parent 2a6b6ebf
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics (VA)
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institute of Technical Acoustics (ITA), 2015-2017
* VVVV AAA RWTH Aachen University (http://www.akustik.rwth-aachen.de)
*
* --------------------------------------------------------------------------------------------
*/
#ifndef IW_VABASE_NETWORK_STREAM_AUDIO_SIGNAL_SOURCE
#define IW_VABASE_NETWORK_STREAM_AUDIO_SIGNAL_SOURCE
#include <VABaseDefinitions.h>
#include <VASamples.h>
#include <VAStruct.h>
//! Helper class for server-side network audio signal sources
/**
* Provides network functionality for an audio signal source.
* Transmit method has to be executed by user, status information
* for the queued samples on client side can be received.
*/
class VABASE_API CVANetworkStreamAudioSignalSource
{
public:
//! Create a network signal source
/**
* @param[in] sServerBindAddress Server name or IP
* @param[in] iServerBindPort Server port number
*/
CVANetworkStreamAudioSignalSource( const std::string& sServerBindAddress = "localhost", const int iServerBindPort = 12480 );
virtual ~CVANetworkStreamAudioSignalSource();
//! Transmit samples of arbitrary lengths
/**
* Transmit a frame of samples (buffer for one or more channels) over the network
* connection. The entire length of the buffer(s) will be send and execution is blocked
* until finished.
*
* @param[in] oFrame Vector of samples in a buffer with same length
*
* @note Will raise VAException if problem with connection occurs
*/
int Transmit( const std::vector< CVASampleBuffer >& oFrame );
//! Returns the internal number of queued samples at client side (last known state)
/**
* At client side, a ring buffer with at least the number of samples for one processing block
* is used.
*
* @return Number of queued samples at client side
*
* @note thread-safe
*/
int GetNumQueuedSamples();
private:
int m_iNumQueuedSamples; //!< Client-side number of queued samples
};
#endif // IW_VABASE_NETWORK_STREAM_AUDIO_SIGNAL_SOURCE
......@@ -12,7 +12,6 @@ set( DirFiles
VACoreVersion.h
VAEventHandlerGlobalLock.h
VAException.h
VANetworkStreamAudioSignalSource.h
VAObject.h
VAObjectRegistry.h
VASamples.h
......
#include <VANetworkStreamAudioSignalSource.h>
CVANetworkStreamAudioSignalSource::CVANetworkStreamAudioSignalSource( const std::string& sServerBindAddress /* = "localhost" */, const int iServerBindPort /* = 12480 */ )
{
}
CVANetworkStreamAudioSignalSource::~CVANetworkStreamAudioSignalSource()
{
}
int CVANetworkStreamAudioSignalSource::GetNumQueuedSamples()
{
return 0;
}
int CVANetworkStreamAudioSignalSource::Transmit( const std::vector<CVASampleBuffer>& oFrame )
{
return 0;
}
\ No newline at end of file
......@@ -11,7 +11,6 @@ set( DirFiles
VACoreVersion.cpp
VAEventHandlerGlobalLock.cpp
VAException.cpp
VANetworkStreamAudioSignalSource.cpp
VAObject.cpp
VAObjectRegistry.cpp
VASamples.cpp
......
......@@ -34,13 +34,3 @@ vista_install( StructTest )
vista_create_default_info_file( StructTest )
set_property( TARGET StructTest PROPERTY FOLDER "VA/Tests/VABase" )
add_executable( NetworkStreamAudioSignalSourceTest NetworkStreamAudioSignalSourceTest.cpp )
target_link_libraries( NetworkStreamAudioSignalSourceTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( NetworkStreamAudioSignalSourceTest )
vista_install( NetworkStreamAudioSignalSourceTest )
vista_create_default_info_file( NetworkStreamAudioSignalSourceTest )
set_property( TARGET NetworkStreamAudioSignalSourceTest PROPERTY FOLDER "VA/Tests/VABase" )
#include <VAException.h>
#include <VANetworkStreamAudioSignalSource.h>
#include <VASamples.h>
#include <VistaInterProcComm/Concurrency/VistaTicker.h>
#include <VistaBase/VistaTimeUtils.h>
#include <algorithm>
using namespace std;
const static int g_iBlockLength = 128;
const static double g_dSampleRate = 44.1e3;
//! Example for a sample generator class
struct CVATestSampleGenerator
{
inline CVATestSampleGenerator()
{
voBuffer.push_back( CVASampleBuffer( g_iBlockLength ) ); // single channel
dFrequency = 567.8f;
};
inline void CalculateMoreSamples( const int nSamples )
{
// Generate a sinusoidal signal
for( int i = 0; i < nSamples; i++ )
{
dVal += i / double( g_iBlockLength ) * 2.0f * 3.1415f * dFrequency;
voBuffer[ 0 ].GetData()[ 0 ] = float( sin( dVal ) );
}
dVal = fmod( dVal, 2 * 3.1415f );
};
std::vector< CVASampleBuffer > voBuffer;
double dFrequency;
private:
double dVal;
};
//! Example sample server class that provides a network audio feed based on an own timeout
class CVATestSampleServer : public CVANetworkStreamAudioSignalSource, public VistaTicker::AfterPulseFunctor
{
public:
inline CVATestSampleServer()
{
double dBlockRate = g_dSampleRate / double( g_iBlockLength );
int iTimeoutMilliseconds = int( std::round( dBlockRate * 1.0e-3 ) );
m_pTimeoutTicker = new VistaTicker();
m_pTimeoutTicker->AddTrigger( new VistaTicker::TriggerContext( iTimeoutMilliseconds, true ) );
m_pTimeoutTicker->StartTicker();
m_pTimeoutTicker->SetAfterPulseFunctor( this );
};
inline ~CVATestSampleServer()
{
m_pTimeoutTicker->SetAfterPulseFunctor( NULL );
m_pTimeoutTicker->StopTicker();
delete m_pTimeoutTicker;
};
// Overload VistaTicker AfterPulseFunctor callback function
virtual inline bool operator()()
{
int nNumSamples = CVANetworkStreamAudioSignalSource::GetNumQueuedSamples();
// Choose your strategy ...
if( nNumSamples > 0 )
{
m_oSampleGenerator.CalculateMoreSamples( nNumSamples );
CVANetworkStreamAudioSignalSource::Transmit( m_oSampleGenerator.voBuffer );
}
return true;
};
private:
VistaTicker* m_pTimeoutTicker;
CVATestSampleGenerator m_oSampleGenerator;
};
int main( int, char** )
{
CVATestSampleServer oSampleServer;
VistaTimeUtils::Sleep( int( 10e3 ) );
return 0;
}
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