Commit a96af048 authored by Anne Heimes's avatar Anne Heimes
Browse files

Merge branch 'develop' of https://git.rwth-aachen.de/ita/ITADataSources into develop

# Conflicts:
#	tests/CMakeLists.txt
parents 8f4b64ff 3992ffe3
......@@ -523,12 +523,16 @@ static int PortaudioCallbackFunction( const void* pInBuffer, void* pOutBuffer, u
{
int iNumOutputChannels = pipdsPlaybackDatasource->GetNumberOfChannels();
const float* pOutDataBlock;
std::vector< const float* > vpBlockPointer( iNumOutputChannels );
for( int j = 0; j < iNumOutputChannels; j++ )
vpBlockPointer[ j ] = pipdsPlaybackDatasource->GetBlockPointer( j, &oStreamInfo );
for( unsigned int i = 0; i < ulBuffersize; i++ )
{
for( int j = 0; j < iNumOutputChannels; j++ )
{
int index = i*iNumOutputChannels + j;
pOutDataBlock = pipdsPlaybackDatasource->GetBlockPointer( j, &oStreamInfo );
pOutDataBlock = vpBlockPointer[ j ];
float fValue = pOutDataBlock ? pOutDataBlock[ i ] : 0.0f;
out[ index ] = fValue;
}
......
......@@ -10,10 +10,6 @@ endif()
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
if( VASIO_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO )
add_subdirectory( ITAAsioTests )
endif( VASIO_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO )
if( ITA_CORE_LIBS_BUILD_STATIC AND DEFINED ITA_CORE_LIBS_BUILD_STATIC )
add_definitions( -DITA_BASE_STATIC -DITA_DATA_SOURCES_STATIC )
endif( ITA_CORE_LIBS_BUILD_STATIC AND DEFINED ITA_CORE_LIBS_BUILD_STATIC )
......@@ -121,14 +117,18 @@ set_property( TARGET StreamProbeTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataS
# set_property( TARGET YJunctionTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
# Portaudio tests
if( VPORTAUDIO_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO )
add_subdirectory( "ITAPortaudioTests" )
endif( VPORTAUDIO_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO )
# tests
if( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO )
add_subdirectory( ITAAsioTests )
endif( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO )
if( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO )
add_subdirectory( "ITAPortaudioTests" )
endif( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO )
if( VJACK_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_JACK )
add_subdirectory( "ITAJACKTests" )
endif( VJACK_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_JACK )
add_subdirectory( "NetAudio" )
add_subdirectory( "VistaNetTest" )
......@@ -20,7 +20,7 @@ vista_configure_app( ListDevices )
vista_install( ListDevices )
vista_create_default_info_file( ListDevices )
set_property( TARGET ListDevices PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET ListDevices PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/Asio" )
add_executable( Loopback Loopback.cpp )
......@@ -30,7 +30,7 @@ vista_configure_app( Loopback )
vista_install( Loopback )
vista_create_default_info_file( Loopback )
set_property( TARGET Loopback PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET Loopback PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/Asio" )
add_executable( Play Play.cpp )
......@@ -40,7 +40,7 @@ vista_configure_app( Play )
vista_install( Play )
vista_create_default_info_file( Play )
set_property( TARGET Play PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET Play PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/Asio" )
add_executable( Record Record.cpp )
......@@ -50,7 +50,7 @@ vista_configure_app( Record )
vista_install( Record )
vista_create_default_info_file( Record )
set_property( TARGET Record PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET Record PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/Asio" )
add_executable( ThreadInit ThreadInit.cpp )
......@@ -60,5 +60,5 @@ vista_configure_app( ThreadInit )
vista_install( ThreadInit )
vista_create_default_info_file( ThreadInit )
set_property( TARGET ThreadInit PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET ThreadInit PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/Asio" )
......@@ -20,7 +20,7 @@ vista_configure_app( ITAPortaudioInterfaceRecorder )
vista_install( ITAPortaudioInterfaceRecorder )
vista_create_default_info_file( ITAPortaudioInterfaceRecorder )
set_property( TARGET ITAPortaudioInterfaceRecorder PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET ITAPortaudioInterfaceRecorder PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/Portaudio" )
add_executable( ITAPortaudioInterfaceTest ITAPortaudioInterfaceTest.cpp )
......@@ -30,7 +30,7 @@ vista_configure_app( ITAPortaudioInterfaceTest )
vista_install( ITAPortaudioInterfaceTest )
vista_create_default_info_file( ITAPortaudioInterfaceTest )
set_property( TARGET ITAPortaudioInterfaceTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET ITAPortaudioInterfaceTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/Portaudio" )
add_executable( ITAPortaudioMeasurementTest ITAPortaudioMeasurementTest.cpp )
......@@ -42,4 +42,4 @@ vista_configure_app( ITAPortaudioMeasurementTest )
vista_install( ITAPortaudioMeasurementTest )
vista_create_default_info_file( ITAPortaudioMeasurementTest )
set_property( TARGET ITAPortaudioMeasurementTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET ITAPortaudioMeasurementTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/Portaudio" )
cmake_minimum_required( VERSION 2.9 )
if( NOT ITADATASOURCES_COMMON_BUILD )
project( ITANetAudioTests )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
endif()
vista_use_package( VistaCoreLibs REQUIRED COMPONENTS VistaInterProcComm FIND_DEPENDENCIES )
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
add_executable( ITANABufferServerTest ITANABufferServerTest.cpp )
target_link_libraries( ITANABufferServerTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITANABufferServerTest )
vista_install( ITANABufferServerTest )
vista_create_default_info_file( ITANABufferServerTest )
set_property( TARGET ITANABufferServerTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
add_executable( ITANAPlayerTest ITANAPlayerTest.cpp )
target_link_libraries( ITANAPlayerTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITANAPlayerTest )
vista_install( ITANAPlayerTest )
vista_create_default_info_file( ITANAPlayerTest )
set_property( TARGET ITANAPlayerTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
#include <iostream>
#include <string>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaInterProcComm/IPNet/VistaTCPServer.h>
#include <VistaInterProcComm/IPNet/VistaTCPSocket.h>
//#include <VistaBase/VistaTimeUtils.h>
#include <VistaInterProcComm/IPNet/VistaIPAddress.h>
#include <ITASampleFrame.h>
#include <cassert>
using namespace std;
static string g_sServerName = "localhost";
static int g_iServerPort = 12480;
//! NetAudio buffer server
class CITANAServer : public VistaThreadLoop
{
public:
CITANAServer()
{
m_pServer = new VistaTCPServer( g_sServerName, g_iServerPort, 1 );
cout << "ITANA server running, waiting for connection" << endl;
m_sfBuffer.Load( "Bauer.wav" );
m_iReadPointer = 0;
m_pSocket = m_pServer->GetNextClient();
Run();
}
~CITANAServer()
{
delete m_pServer;
}
bool LoopBody()
{
if( m_pSocket->GetIsConnected() == false )
{
cout << "Connection closed. Stopping loop." << endl;
StopGently( true );
return false;
}
size_t nGetReceiveBufferSize = m_pSocket->GetReceiveBufferSize();
cout << "Waiting for new incoming data" << endl;
long nIncomingBytes = m_pSocket->WaitForIncomingData( 0 );
cout << "Server incoming bytes: " << nIncomingBytes << " bytes" << endl;
if( nGetReceiveBufferSize == nIncomingBytes )
cout << "Warning: payload as long as receiver buffer size ... problem will occur!" << endl;
if( nIncomingBytes == 0 )
{
cout << "Connection closed. Stopping loop." << endl;
StopGently( true );
return false;
}
assert( sizeof( int ) <= nIncomingBytes );
int iChannelIndex;
int iBytesReceived = m_pSocket->ReceiveRaw( &iChannelIndex, sizeof( int ) );
nIncomingBytes = m_pSocket->WaitForIncomingData( 0 );
assert( sizeof( int ) <= nIncomingBytes );
int iNumSamples;
iBytesReceived = m_pSocket->ReceiveRaw( &iNumSamples, sizeof( int ) );
if( m_sfOutBuffer.channels() <= iChannelIndex || m_sfOutBuffer.length() != iNumSamples )
m_sfOutBuffer.init( iChannelIndex + 1, iNumSamples, true );
else
m_sfOutBuffer.zero();
cout << "Server sending samples";
ITASampleBuffer* pBuf = &m_sfBuffer[ iChannelIndex ];
pBuf->cyclic_read( m_sfOutBuffer[ iChannelIndex ].data(), iNumSamples, m_iReadPointer );
m_pSocket->SendRaw( m_sfOutBuffer[ iChannelIndex ].data(), iNumSamples * sizeof( float ) );
m_pSocket->WaitForSendFinish( 0 );
cout << " ... finished" << endl;
m_iReadPointer += iNumSamples;
m_iReadPointer = m_iReadPointer % m_sfBuffer.length();
return true;
}
private:
VistaTCPServer* m_pServer;
VistaTCPSocket* m_pSocket;
ITASampleFrame m_sfBuffer;
ITASampleFrame m_sfOutBuffer;
int m_iReadPointer;
};
int main( int , char** )
{
CITANAServer oITANAServer;
cout << "Press any key to quit" << endl;
int iIn;
cin >> iIn;
return 0;
}
#include <iostream>
#include <string>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaInterProcComm/IPNet/VistaTCPServer.h>
#include <VistaInterProcComm/IPNet/VistaTCPSocket.h>
#include <VistaInterProcComm/IPNet/VistaIPAddress.h>
#include <ITAPortaudioInterface.h>
#include <ITADataSource.h>
#include <ITASampleFrame.h>
#include <ITAStreamMultiplier1N.h>
using namespace std;
static string g_sServerName = "localhost";
static int g_iServerPort = 12480;
static double g_dSampleRate = 44.1e3;
static int g_iBufferSize = 256;
class CITANAStream : public ITADatasource
{
public:
inline CITANAStream( int iChannels, double dSamplingRate, int iBufferSize )
: m_iBufferSize( iBufferSize )
, m_dSampleRate( dSamplingRate )
, m_iNumChannels( iChannels )
, m_sfOutBuffer( iChannels, iBufferSize, true )
, m_pConnection( NULL )
{
m_pConnection = new VistaConnectionIP( VistaConnectionIP::CT_TCP, g_sServerName, g_iServerPort );
if( m_pConnection->GetIsConnected() )
{
cout << "Connection established" << endl;
}
};
inline ~CITANAStream()
{
delete m_pConnection;
};
inline unsigned int GetBlocklength() const
{
return m_iBufferSize;
};
inline unsigned int GetNumberOfChannels() const
{
return m_iNumChannels;
};
inline double GetSampleRate() const
{
return m_dSampleRate;
};
inline const float* GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* )
{
// get buffer from net audio stream
if( m_pConnection->GetIsConnected() )
{
m_pConnection->Send( &uiChannel, sizeof( int ) );
m_pConnection->Send( &m_iBufferSize, sizeof( int ) );
void* pDestination = ( void* ) m_sfOutBuffer[ uiChannel ].data();
int iReceiveBufferLength = sizeof( float ) * m_iBufferSize;
int l = m_pConnection->Receive( pDestination, iReceiveBufferLength );
assert( l == iReceiveBufferLength );
//cout << "Data received: " << l << endl;
}
else
{
m_sfOutBuffer.zero();
}
return m_sfOutBuffer[ uiChannel].GetData();
};
void IncrementBlockPointer()
{
//cout << "Block pointer increment" << endl;
};
private:
int m_iBufferSize;
int m_iNumChannels;
double m_dSampleRate;
ITASampleFrame m_sfOutBuffer;
VistaConnectionIP* m_pConnection;
};
int main(int , char** )
{
CITANAStream* pNetAudioStream = new CITANAStream( 1, g_dSampleRate, g_iBufferSize );
ITAStreamMultiplier1N oMultiplier( pNetAudioStream, 2 );
ITAPortaudioInterface ITAPA( g_dSampleRate, g_iBufferSize );
ITAPA.Initialize();
ITAPA.SetPlaybackDatasource( &oMultiplier );
ITAPA.Open();
ITAPA.Start();
// Playback
float seconds = 10.0f;
cout << "Playback started, waiting " << seconds << " seconds" << endl;
ITAPA.Sleep( seconds ); // blocking
cout << "Done." << endl;
ITAPA.Stop();
ITAPA.Close();
ITAPA.Finalize();
delete pNetAudioStream;
return 0;
}
......@@ -20,7 +20,7 @@ vista_configure_app( ITAVistaNetTest )
vista_install( ITAVistaNetTest )
vista_create_default_info_file( ITAVistaNetTest )
set_property( TARGET ITAVistaNetTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET ITAVistaNetTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/VistaNet" )
add_executable( ITAVistaNetClient VistaNetClient.cpp )
......@@ -32,7 +32,7 @@ vista_configure_app( ITAVistaNetClient )
vista_install( ITAVistaNetClient )
vista_create_default_info_file( ITAVistaNetClient )
set_property( TARGET ITAVistaNetClient PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET ITAVistaNetClient PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/VistaNet" )
add_executable( ITAVistaNetServer VistaNetServer.cpp )
......@@ -44,5 +44,5 @@ vista_configure_app( ITAVistaNetServer )
vista_install( ITAVistaNetServer )
vista_create_default_info_file( ITAVistaNetServer )
set_property( TARGET ITAVistaNetServer PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources" )
set_property( TARGET ITAVistaNetServer PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/VistaNet" )
......@@ -24,7 +24,8 @@ public:
Run();
}
~CServer() {
~CServer()
{
delete m_pServer;
}
......
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