Commit e52b29d6 authored by Anne's avatar Anne

running, aber kleine nerfige laute drin

parent 56b316b1
......@@ -39,22 +39,13 @@ bool CITANetAudioStream::GetIsConnected() const
const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* )
{
// @todo: is connected?
m_sfOutputStreamBuffer[uiChannel].Zero();
if (this->GetIsConnected())
{
// todo restlichen kopieren und dann rein und raus faden
int iCurrentWritePointer = m_iWriteCursor;
if (iCurrentWritePointer > m_iReadCursor) {
m_sfRingBuffer[uiChannel].cyclic_read(m_sfOutputStreamBuffer[uiChannel].GetData(),
m_sfOutputStreamBuffer.GetLength(), m_iReadCursor);
}
else
{
// Hallo
int a = 0;
}
m_sfRingBuffer[uiChannel].cyclic_read(m_sfOutputStreamBuffer[uiChannel].GetData(),
m_sfOutputStreamBuffer.GetLength(), m_iReadCursor);
}
return m_sfOutputStreamBuffer[ uiChannel ].GetData();
}
......@@ -63,7 +54,7 @@ void CITANetAudioStream::IncrementBlockPointer()
{
// Increment read cursor by one audio block and wrap around if exceeding ring buffer
m_iReadCursor = ( m_iReadCursor + m_sfOutputStreamBuffer.GetLength() ) % m_sfRingBuffer.GetLength();
m_pNetAudioStreamingClient->TriggerBlockIncrement();
m_pNetAudioStreamingClient->TriggerBlockIncrement( );
}
int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSamples )
......@@ -75,7 +66,7 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
iCurrentReadCursor, m_iWriteCursor);
// set write curser
m_iWriteCursor = ( m_iWriteCursor + iNumSamples ) % m_sfRingBuffer.GetLength();
m_iWriteCursor = ( m_iWriteCursor + iNumSamples ) % m_sfRingBuffer.GetLength( );
// return free BufferSize
if (iCurrentReadCursor > m_iWriteCursor) {
......
......@@ -52,11 +52,16 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
m_pInputStream->GetBlocklength() == oClientParams.iBlockSize)
{
bOK = true;
std::cout << " Alle Daten Stimmen: \nAnzahl Channel: " << oClientParams.iChannels << std::endl;
std::cout << "SampleRate: " << oClientParams.dSampleRate << std::endl;
std::cout << "Blockgroesse: " << oClientParams.iBlockSize << std::endl;
}
std::cout << " Client Data: \nAnzahl Channel: " << oClientParams.iChannels << std::endl;
std::cout << "SampleRate: " << oClientParams.dSampleRate << std::endl;
std::cout << "Blockgroesse: " << oClientParams.iBlockSize << std::endl;
std::cout << " Server Data: \nAnzahl Channel: " << m_pInputStream->GetNumberOfChannels() << std::endl;
std::cout << "SampleRate: " << m_pInputStream->GetSampleRate() << std::endl;
std::cout << "Blockgroesse: " << m_pInputStream->GetBlocklength() << std::endl;
m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_OPEN );
m_pMessage->WriteBool( bOK );
m_pMessage->WriteAnswer();
......@@ -130,9 +135,13 @@ bool CITANetAudioStreamingServer::LoopBody()
for( int i = 0; i < m_pInputStream->GetNumberOfChannels(); i++ )
{
ITAStreamInfo oStreamInfo;
oStreamInfo.nSamples = m_sfTempTransmitBuffer.GetLength();
const float* pfData = m_pInputStream->GetBlockPointer( i, &oStreamInfo );
m_sfTempTransmitBuffer[ i ].write( pfData, m_pInputStream->GetBlocklength() );
//std::cout << *pfData << std::endl;
if (pfData != 0)
m_sfTempTransmitBuffer[i].write(pfData, m_sfTempTransmitBuffer.GetLength());
}
m_pInputStream->IncrementBlockPointer();
m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_SEND_SAMPLES );
m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer );
}
......
......@@ -10,17 +10,17 @@ using namespace std;
static string g_sServerName = "localhost";
static int g_iServerPort = 12480;
static double g_dSampleRate = 44.1e3;
static double g_dSampleRate = 44100;
static int g_iBufferSize = 256;
int main( int , char** )
{
CITANetAudioStream oNetAudioStream( 1, g_dSampleRate, g_iBufferSize, 4 * g_iBufferSize );
ITAStreamMultiplier1N oMultiplier( &oNetAudioStream, 2 );
CITANetAudioStream oNetAudioStream( 2, g_dSampleRate, g_iBufferSize, 100 * g_iBufferSize );
//ITAStreamMultiplier1N oMultiplier( &oNetAudioStream, 2 );
ITAPortaudioInterface ITAPA( g_dSampleRate, g_iBufferSize );
ITAPA.Initialize();
ITAPA.SetPlaybackDatasource( &oMultiplier );
ITAPA.SetPlaybackDatasource(&oNetAudioStream);
ITAPA.Open();
ITAPA.Start();
......
......@@ -4,20 +4,21 @@
#include <ITANetAudioStreamingServer.h>
#include <ITANetAudioServer.h>
#include <ITAStreamFunctionGenerator.h>
#include <ITAFileDatasource.h>
using namespace std;
static string g_sServerName = "localhost";
static int g_iServerPort = 12480;
static double g_dSampleRate = 44.1e3;
static double g_dSampleRate = 44100;
static int g_iBlockLength = 256;
int main( int , char** )
{
ITAStreamFunctionGenerator oGenerator( 1, g_dSampleRate, g_iBlockLength, ITAStreamFunctionGenerator::SINE, 456.78f, 0.81f, true );
ITAFileDatasource oDatei("Gershwin.wav", g_iBlockLength);
CITANetAudioStreamingServer oStreamingServer;
oStreamingServer.SetInputStream( &oGenerator );
oStreamingServer.SetInputStream(&oDatei);
cout << "Starting server and waiting for connections on '" << g_sServerName << "' on port " << g_iServerPort << endl;
oStreamingServer.Start( g_sServerName, g_iServerPort );
......
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