finished separate mix implementation for each connected client of the server

This commit is contained in:
Volker Fischer 2006-12-06 20:22:41 +00:00
parent cb9de2b952
commit e335718eb5
5 changed files with 149 additions and 99 deletions

View file

@ -37,11 +37,11 @@ CChannelSet::CChannelSet()
QObject::connect(&vecChannels[2],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh2(CVector<uint8_t>))); QObject::connect(&vecChannels[2],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh2(CVector<uint8_t>)));
QObject::connect(&vecChannels[3],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh3(CVector<uint8_t>))); QObject::connect(&vecChannels[3],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh3(CVector<uint8_t>)));
QObject::connect(&vecChannels[4],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh4(CVector<uint8_t>))); QObject::connect(&vecChannels[4],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh4(CVector<uint8_t>)));
// QObject::connect(&vecChannels[5],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh5(CVector<uint8_t>))); QObject::connect(&vecChannels[5],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh5(CVector<uint8_t>)));
// QObject::connect(&vecChannels[6],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh6(CVector<uint8_t>))); QObject::connect(&vecChannels[6],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh6(CVector<uint8_t>)));
// QObject::connect(&vecChannels[7],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh7(CVector<uint8_t>))); QObject::connect(&vecChannels[7],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh7(CVector<uint8_t>)));
// QObject::connect(&vecChannels[8],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh8(CVector<uint8_t>))); QObject::connect(&vecChannels[8],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh8(CVector<uint8_t>)));
// QObject::connect(&vecChannels[9],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh9(CVector<uint8_t>))); QObject::connect(&vecChannels[9],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh9(CVector<uint8_t>)));
// request jitter buffer size // request jitter buffer size
QObject::connect(&vecChannels[0],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh0())); QObject::connect(&vecChannels[0],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh0()));
@ -49,11 +49,11 @@ CChannelSet::CChannelSet()
QObject::connect(&vecChannels[2],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh2())); QObject::connect(&vecChannels[2],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh2()));
QObject::connect(&vecChannels[3],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh3())); QObject::connect(&vecChannels[3],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh3()));
QObject::connect(&vecChannels[4],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh4())); QObject::connect(&vecChannels[4],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh4()));
// QObject::connect(&vecChannels[5],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh5())); QObject::connect(&vecChannels[5],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh5()));
// QObject::connect(&vecChannels[6],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh6())); QObject::connect(&vecChannels[6],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh6()));
// QObject::connect(&vecChannels[7],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh7())); QObject::connect(&vecChannels[7],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh7()));
// QObject::connect(&vecChannels[8],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh8())); QObject::connect(&vecChannels[8],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh8()));
// QObject::connect(&vecChannels[9],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh9())); QObject::connect(&vecChannels[9],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh9()));
} }
void CChannelSet::CreateAndSendChanListForAllConClients() void CChannelSet::CreateAndSendChanListForAllConClients()
@ -142,9 +142,22 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
iCurChanID = GetFreeChan(); iCurChanID = GetFreeChan();
if ( iCurChanID != INVALID_CHANNEL_ID ) if ( iCurChanID != INVALID_CHANNEL_ID )
{ {
// initialize current channel by storing the calling host
// address
vecChannels[iCurChanID].SetAddress ( HostAdr ); vecChannels[iCurChanID].SetAddress ( HostAdr );
// reset the channel gains of current channel, at the same
// time reset gains of this channel ID for all other channels
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{
vecChannels[iCurChanID].SetGain ( i, (double) 1.0 );
// other channels (we do not distinguish the case if
// i == iCurChanID for simplicity)
vecChannels[i].SetGain ( iCurChanID, (double) 1.0 );
}
// a new client connected to the server, set flag to create and // a new client connected to the server, set flag to create and
// send all clients the updated channel list, we cannot create // send all clients the updated channel list, we cannot create
// the message here since the received data has to be put to the // the message here since the received data has to be put to the
@ -198,42 +211,41 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
return bRet; return bRet;
} }
void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID, void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID,
CVector<CVector<double> >& vecvecdData, CVector<CVector<double> >& vecvecdData,
CVector<double>& vecdGains ) CVector<CVector<double> >& vecvecdGains )
{ {
/* init temporal data vector and clear input buffers */ int i, j;
// init temporal data vector and clear input buffers
CVector<double> vecdData ( MIN_BLOCK_SIZE_SAMPLES ); CVector<double> vecdData ( MIN_BLOCK_SIZE_SAMPLES );
vecChanID.Init ( 0 ); vecChanID.Init ( 0 );
vecvecdData.Init ( 0 ); vecvecdData.Init ( 0 );
vecdGains.Init ( 0 ); vecvecdGains.Init ( 0 );
/* make put and get calls thread safe. Do not forget to unlock mutex // make put and get calls thread safe. Do not forget to unlock mutex
afterwards! */ // afterwards!
Mutex.lock(); Mutex.lock();
{ {
/* Check all possible channels */ // check all possible channels
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
/* read out all input buffers to decrease timeout counter on // read out all input buffers to decrease timeout counter on
disconnected channels */ // disconnected channels
const bool bGetOK = vecChannels[i].GetData ( vecdData ); const bool bGetOK = vecChannels[i].GetData ( vecdData );
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {
/* add ID, gain and data */ // add ID and data
vecChanID.Add ( i ); vecChanID.Add ( i );
// TEST
vecdGains.Add ( 1.0);//vecChannels[i].GetGain() );
const int iOldSize = vecvecdData.Size(); const int iOldSize = vecvecdData.Size();
vecvecdData.Enlarge ( 1 ); vecvecdData.Enlarge ( 1 );
vecvecdData[iOldSize].Init ( vecdData.Size() ); vecvecdData[iOldSize].Init ( vecdData.Size() );
vecvecdData[iOldSize] = vecdData; vecvecdData[iOldSize] = vecdData;
/* send message for get status (for GUI) */ // send message for get status (for GUI)
if ( bGetOK ) if ( bGetOK )
{ {
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, i ); PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, i );
@ -243,23 +255,40 @@ vecdGains.Add ( 1.0);//vecChannels[i].GetGain() );
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED, i ); PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED, i );
} }
} }
}
// now that we know the IDs of the connected clients, get gains
const int iNumCurConnChan = vecChanID.Size();
vecvecdGains.Init ( iNumCurConnChan );
for ( i = 0; i < iNumCurConnChan; i++ )
{
vecvecdGains[i].Init ( iNumCurConnChan );
for ( j = 0; j < iNumCurConnChan; j++ )
{
// The second index of "vecvecdGains" does not represent
// the channel ID! Therefore we have to use "vecChanID" to
// query the IDs of the currently connected channels
vecvecdGains[i][j] = vecChannels[i].GetGain( vecChanID[j] );
}
} }
} }
Mutex.unlock(); /* release mutex */ Mutex.unlock(); // release mutex
} }
void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses, void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
CVector<int>& veciJitBufSize, CVector<int>& veciJitBufSize,
CVector<int>& veciNetwOutBlSiFact, CVector<int>& veciNetwOutBlSiFact,
CVector<int>& veciNetwInBlSiFact ) CVector<int>& veciNetwInBlSiFact )
{ {
CHostAddress InetAddr; CHostAddress InetAddr;
/* init return values */ /* init return values */
vecHostAddresses.Init ( MAX_NUM_CHANNELS ); vecHostAddresses.Init ( MAX_NUM_CHANNELS );
veciJitBufSize.Init ( MAX_NUM_CHANNELS ); veciJitBufSize.Init ( MAX_NUM_CHANNELS );
veciNetwOutBlSiFact.Init ( MAX_NUM_CHANNELS ); veciNetwOutBlSiFact.Init ( MAX_NUM_CHANNELS );
veciNetwInBlSiFact.Init ( MAX_NUM_CHANNELS ); veciNetwInBlSiFact.Init ( MAX_NUM_CHANNELS );
/* Check all possible channels */ /* Check all possible channels */
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
@ -267,10 +296,10 @@ void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
if ( vecChannels[i].GetAddress ( InetAddr ) ) if ( vecChannels[i].GetAddress ( InetAddr ) )
{ {
/* get requested data */ /* get requested data */
vecHostAddresses[i] = InetAddr; vecHostAddresses[i] = InetAddr;
veciJitBufSize[i] = vecChannels[i].GetSockBufSize (); veciJitBufSize[i] = vecChannels[i].GetSockBufSize ();
veciNetwOutBlSiFact[i] = vecChannels[i].GetNetwBufSizeFactOut (); veciNetwOutBlSiFact[i] = vecChannels[i].GetNetwBufSizeFactOut ();
veciNetwInBlSiFact[i] = vecChannels[i].GetNetwBufSizeFactIn (); veciNetwInBlSiFact[i] = vecChannels[i].GetNetwBufSizeFactIn ();
} }
} }
} }
@ -310,16 +339,20 @@ CChannel::CChannel() : sName ( "" ),
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ), SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) ); this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) );
QObject::connect ( &Protocol, SIGNAL ( ChangeJittBufSize ( int ) ), QObject::connect ( &Protocol,
SIGNAL ( ChangeJittBufSize ( int ) ),
this, SLOT ( OnJittBufSizeChange ( int ) ) ); this, SLOT ( OnJittBufSizeChange ( int ) ) );
QObject::connect ( &Protocol, SIGNAL ( ReqJittBufSize() ), QObject::connect ( &Protocol,
SIGNAL ( ReqJittBufSize() ),
SIGNAL ( ReqJittBufSize() ) ); SIGNAL ( ReqJittBufSize() ) );
QObject::connect ( &Protocol, SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ), QObject::connect ( &Protocol,
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ),
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ) ); SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ) );
QObject::connect ( &Protocol, SIGNAL ( ChangeNetwBlSiFact ( int ) ), QObject::connect ( &Protocol,
SIGNAL ( ChangeNetwBlSiFact ( int ) ),
this, SLOT ( OnNetwBlSiFactChange ( int ) ) ); this, SLOT ( OnNetwBlSiFactChange ( int ) ) );
} }
@ -355,14 +388,6 @@ void CChannel::SetNetwBufSizeFactOut ( const int iNewNetwBlSiFactOut )
ConvBuf.Init ( iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES ); ConvBuf.Init ( iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES );
} }
void CChannel::OnNetwBlSiFactChange ( int iNewNetwBlSiFact )
{
// TEST
//qDebug ( "new network block size factor: %d", iNewNetwBlSiFact );
SetNetwBufSizeFactOut ( iNewNetwBlSiFact );
}
void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage ) void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
{ {
// only send messages if we are connected, otherwise delete complete queue // only send messages if we are connected, otherwise delete complete queue
@ -397,6 +422,14 @@ void CChannel::SetSockBufSize ( const int iNumBlocks )
Mutex.unlock(); Mutex.unlock();
} }
void CChannel::OnNetwBlSiFactChange ( int iNewNetwBlSiFact )
{
// TEST
//qDebug ( "new network block size factor: %d", iNewNetwBlSiFact );
SetNetwBufSizeFactOut ( iNewNetwBlSiFact );
}
void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) void CChannel::OnJittBufSizeChange ( int iNewJitBufSize )
{ {
// TEST // TEST
@ -405,6 +438,14 @@ void CChannel::OnJittBufSizeChange ( int iNewJitBufSize )
SetSockBufSize ( iNewJitBufSize ); SetSockBufSize ( iNewJitBufSize );
} }
void CChannel::OnChangeChanGain ( int iChanID, double dNewGain )
{
ASSERT ( ( iChanID >= 0 ) && ( iChanID < MAX_NUM_CHANNELS ) );
// set value
vecdGains[iChanID] = dNewGain;
}
bool CChannel::GetAddress(CHostAddress& RetAddr) bool CChannel::GetAddress(CHostAddress& RetAddr)
{ {
if ( IsConnected() ) if ( IsConnected() )

View file

@ -43,7 +43,7 @@
/* maximum number of internet connections (channels) */ /* maximum number of internet connections (channels) */
// if you want to change this paramter, change the connections in this class, too! // if you want to change this paramter, change the connections in this class, too!
#define MAX_NUM_CHANNELS 5//10 /* max number channels for server */ #define MAX_NUM_CHANNELS 10 /* max number channels for server */
/* no valid channel number */ /* no valid channel number */
#define INVALID_CHANNEL_ID (MAX_NUM_CHANNELS + 1) #define INVALID_CHANNEL_ID (MAX_NUM_CHANNELS + 1)
@ -165,6 +165,7 @@ public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage ); void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnJittBufSizeChange ( int iNewJitBufSize ); void OnJittBufSizeChange ( int iNewJitBufSize );
void OnNetwBlSiFactChange ( int iNewNetwBlSiFact ); void OnNetwBlSiFactChange ( int iNewNetwBlSiFact );
void OnChangeChanGain ( int iChanID, double dNewGain );
signals: signals:
void MessReadyForSending ( CVector<uint8_t> vecMessage ); void MessReadyForSending ( CVector<uint8_t> vecMessage );
@ -193,7 +194,7 @@ public:
void GetBlockAllConC ( CVector<int>& vecChanID, void GetBlockAllConC ( CVector<int>& vecChanID,
CVector<CVector<double> >& vecvecdData, CVector<CVector<double> >& vecvecdData,
CVector<double>& vecdGains ); CVector<CVector<double> >& vecvecdGains );
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses, void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
CVector<int>& veciJitBufSize, CVector<int>& veciJitBufSize,

View file

@ -70,20 +70,20 @@ void CClient::OnReqJittBufSize()
Channel.CreateNetwBlSiFactMes ( iNetwBufSizeFactIn ); Channel.CreateNetwBlSiFactMes ( iNetwBufSizeFactIn );
} }
bool CClient::SetServerAddr(QString strNAddr) bool CClient::SetServerAddr ( QString strNAddr )
{ {
QHostAddress InetAddr; QHostAddress InetAddr;
if (InetAddr.setAddress(strNAddr)) if ( InetAddr.setAddress ( strNAddr ) )
{ {
/* The server port is fixed and always the same */ // the server port is fixed and always the same
Channel.SetAddress(CHostAddress(InetAddr, LLCON_PORT_NUMBER)); Channel.SetAddress ( CHostAddress ( InetAddr, LLCON_PORT_NUMBER ) );
return true; return true;
} }
else else
{ {
return false; /* invalid address */ return false; // invalid address
} }
} }

View file

@ -82,10 +82,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
"red color." ) ); "red color." ) );
/* init server address line edit */ /* init server address line edit */
LineEditServerAddr->setText ( pClient->strIPAddress.c_str () ); LineEditServerAddr->setText ( pClient->strIPAddress.c_str() );
/* init status label */ /* init status label */
OnTimerStatus (); OnTimerStatus();
/* init connection button text */ /* init connection button text */
PushButtonConnect->setText ( CON_BUT_CONNECTTEXT ); PushButtonConnect->setText ( CON_BUT_CONNECTTEXT );
@ -98,26 +98,27 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
/* init slider controls --- */ /* init slider controls --- */
/* audio in fader */ // audio in fader
SliderAudInFader->setRange(0, AUD_FADER_IN_MAX); SliderAudInFader->setRange ( 0, AUD_FADER_IN_MAX );
const int iCurAudInFader = pClient->GetAudioInFader(); const int iCurAudInFader = pClient->GetAudioInFader();
SliderAudInFader->setValue(iCurAudInFader); SliderAudInFader->setValue ( iCurAudInFader );
SliderAudInFader->setTickInterval(AUD_FADER_IN_MAX / 9); SliderAudInFader->setTickInterval ( AUD_FADER_IN_MAX / 9 );
/* audio reverberation */ // audio reverberation
SliderAudReverb->setRange(0, AUD_REVERB_MAX); SliderAudReverb->setRange ( 0, AUD_REVERB_MAX );
const int iCurAudReverb = pClient->GetReverbLevel(); const int iCurAudReverb = pClient->GetReverbLevel();
SliderAudReverb->setValue ( AUD_REVERB_MAX - iCurAudReverb ); SliderAudReverb->setValue ( AUD_REVERB_MAX - iCurAudReverb );
SliderAudReverb->setTickInterval(AUD_REVERB_MAX / 9); SliderAudReverb->setTickInterval ( AUD_REVERB_MAX / 9 );
/* set radio buttons --- */ /* set radio buttons --- */
/* reverb channel */ // reverb channel
if (pClient->IsReverbOnLeftChan()) if (pClient->IsReverbOnLeftChan())
RadioButtonRevSelL->setChecked(true); RadioButtonRevSelL->setChecked(true);
else else
RadioButtonRevSelR->setChecked(true); RadioButtonRevSelR->setChecked(true);
/* Settings menu ------------------------------------------------------- */ /* Settings menu ------------------------------------------------------- */
pSettingsMenu = new QPopupMenu ( this ); pSettingsMenu = new QPopupMenu ( this );
CHECK_PTR ( pSettingsMenu ); CHECK_PTR ( pSettingsMenu );
@ -139,23 +140,23 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
/* connections ---------------------------------------------------------- */ /* connections ---------------------------------------------------------- */
/* push-buttons */ // push-buttons
QObject::connect(PushButtonConnect, SIGNAL(clicked()), QObject::connect(PushButtonConnect, SIGNAL(clicked()),
this, SLOT(OnConnectDisconBut())); this, SLOT(OnConnectDisconBut()));
/* timers */ // timers
QObject::connect(&TimerSigMet, SIGNAL(timeout()), QObject::connect(&TimerSigMet, SIGNAL(timeout()),
this, SLOT(OnTimerSigMet())); this, SLOT(OnTimerSigMet()));
QObject::connect(&TimerStatus, SIGNAL(timeout()), QObject::connect(&TimerStatus, SIGNAL(timeout()),
this, SLOT(OnTimerStatus())); this, SLOT(OnTimerStatus()));
/* sliders */ // sliders
QObject::connect(SliderAudInFader, SIGNAL(valueChanged(int)), QObject::connect(SliderAudInFader, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderAudInFader(int))); this, SLOT(OnSliderAudInFader(int)));
QObject::connect(SliderAudReverb, SIGNAL(valueChanged(int)), QObject::connect(SliderAudReverb, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderAudReverb(int))); this, SLOT(OnSliderAudReverb(int)));
/* radio buttons */ // radio buttons
QObject::connect(RadioButtonRevSelL, SIGNAL(clicked()), QObject::connect(RadioButtonRevSelL, SIGNAL(clicked()),
this, SLOT(OnRevSelL())); this, SLOT(OnRevSelL()));
QObject::connect(RadioButtonRevSelR, SIGNAL(clicked()), QObject::connect(RadioButtonRevSelR, SIGNAL(clicked()),
@ -167,7 +168,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
/* timers --------------------------------------------------------------- */ /* timers --------------------------------------------------------------- */
/* start timer for status bar */ // start timer for status bar
TimerStatus.start(STATUSBAR_UPDATE_TIME); TimerStatus.start(STATUSBAR_UPDATE_TIME);
@ -176,7 +177,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
//vecpChanFader.Init(0); //vecpChanFader.Init(0);
//vecpChanFader.Add(new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout, "test")); //vecpChanFader.Add(new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout, "test"));
//FrameAudioFadersLayout->addWidget(new QLabel ( "test", FrameAudioFaders ));
/* /*
for ( int z = 0; z < 100; z++) for ( int z = 0; z < 100; z++)
{ {
@ -256,7 +257,7 @@ void CLlconClientDlg::OnOpenGeneralSettings()
} }
void CLlconClientDlg::OnTimerSigMet () void CLlconClientDlg::OnTimerSigMet ()
{ {
/* get current input levels */ /* get current input levels */
double dCurSigLevelL = pClient->MicLevelL (); double dCurSigLevelL = pClient->MicLevelL ();
double dCurSigLevelR = pClient->MicLevelR (); double dCurSigLevelR = pClient->MicLevelR ();
@ -292,6 +293,14 @@ void CLlconClientDlg::OnConClientListMesReceived ( CVector<CChannelShortInfo> ve
{ {
int i; int i;
//FrameAudioFadersLayout->addWidget(new QLabel ( "test", FrameAudioFaders ));
// TODO // TODO
// remove old controls // remove old controls
@ -310,7 +319,7 @@ for ( i = 0; i < vecChanInfo.Size(); i++ )
vecpChanFader[i] = new CLlconClientDlg::CChannelFader ( FrameAudioFaders, vecpChanFader[i] = new CLlconClientDlg::CChannelFader ( FrameAudioFaders,
FrameAudioFadersLayout, addrTest.toString() ); FrameAudioFadersLayout, addrTest.toString() );
} }
//FrameAudioFadersLayout->addWidget(new QLabel ( "test", FrameAudioFaders ));
} }

View file

@ -30,10 +30,10 @@ CServer::CServer() : Socket ( &ChannelSet, this )
{ {
vecsSendData.Init ( MIN_BLOCK_SIZE_SAMPLES ); vecsSendData.Init ( MIN_BLOCK_SIZE_SAMPLES );
/* init moving average buffer for response time evaluation */ // init moving average buffer for response time evaluation
RespTimeMoAvBuf.Init ( LEN_MOV_AV_RESPONSE ); RespTimeMoAvBuf.Init ( LEN_MOV_AV_RESPONSE );
/* connect timer timeout signal */ // connect timer timeout signal
QObject::connect ( &Timer, SIGNAL ( timeout() ), QObject::connect ( &Timer, SIGNAL ( timeout() ),
this, SLOT ( OnTimer() ) ); this, SLOT ( OnTimer() ) );
@ -67,17 +67,17 @@ void CServer::Start()
{ {
if ( !IsRunning() ) if ( !IsRunning() )
{ {
/* start main timer */ // start main timer
Timer.start ( MIN_BLOCK_DURATION_MS ); Timer.start ( MIN_BLOCK_DURATION_MS );
/* init time for response time evaluation */ // init time for response time evaluation
TimeLastBlock = QTime::currentTime(); TimeLastBlock = QTime::currentTime();
} }
} }
void CServer::Stop() void CServer::Stop()
{ {
/* stop main timer */ // stop main timer
Timer.stop(); Timer.stop();
qDebug ( CLogTimeDate::toString() + "Server stopped" ); qDebug ( CLogTimeDate::toString() + "Server stopped" );
@ -87,23 +87,22 @@ void CServer::OnTimer()
{ {
CVector<int> vecChanID; CVector<int> vecChanID;
CVector<CVector<double> > vecvecdData ( MIN_BLOCK_SIZE_SAMPLES ); CVector<CVector<double> > vecvecdData ( MIN_BLOCK_SIZE_SAMPLES );
CVector<double> vecdGains; CVector<CVector<double> > vecvecdGains;
/* get data from all connected clients */ // get data from all connected clients
ChannelSet.GetBlockAllConC ( vecChanID, vecvecdData, vecdGains ); ChannelSet.GetBlockAllConC ( vecChanID, vecvecdData, vecvecdGains );
const int iNumClients = vecChanID.Size(); const int iNumClients = vecChanID.Size();
/* Check if at least one client is connected. If not, stop server until // Check if at least one client is connected. If not, stop server until
one client is connected */ // one client is connected
if ( iNumClients != 0 ) if ( iNumClients != 0 )
{ {
for ( int i = 0; i < iNumClients; i++ ) for ( int i = 0; i < iNumClients; i++ )
{ {
// TODO generate a sparate mix for each channel // generate a sparate mix for each channel
// actual processing of audio data -> mix
vecsSendData = ProcessData ( vecvecdData, vecvecdGains[i] );
// actual processing of audio data -> mix
vecsSendData = ProcessData ( vecvecdData, vecdGains );
// send separate mix to current clients // send separate mix to current clients
Socket.SendPacket ( Socket.SendPacket (
ChannelSet.PrepSendPacket ( vecChanID[i], vecsSendData ), ChannelSet.PrepSendPacket ( vecChanID[i], vecsSendData ),
@ -111,18 +110,18 @@ vecsSendData = ProcessData ( vecvecdData, vecdGains );
} }
/* update response time measurement --------------------------------- */ // update response time measurement ------------------------------------
/* add time difference */ // add time difference
const QTime CurTime = QTime::currentTime (); const QTime CurTime = QTime::currentTime ();
/* we want to calculate the standard deviation (we assume that the mean // we want to calculate the standard deviation (we assume that the mean
is correct at the block period time) */ // is correct at the block period time)
const double dCurAddVal = ( (double) TimeLastBlock.msecsTo ( CurTime ) - const double dCurAddVal = ( (double) TimeLastBlock.msecsTo ( CurTime ) -
MIN_BLOCK_DURATION_MS ); MIN_BLOCK_DURATION_MS );
RespTimeMoAvBuf.Add ( dCurAddVal * dCurAddVal ); /* add squared value */ RespTimeMoAvBuf.Add ( dCurAddVal * dCurAddVal ); // add squared value
/* store old time value */ // store old time value
TimeLastBlock = CurTime; TimeLastBlock = CurTime;
} }
else else
@ -147,7 +146,7 @@ CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData,
// 3 dB offset to avoid overload if all clients are set to gain 1 // 3 dB offset to avoid overload if all clients are set to gain 1
const double dNorm = (double) 2.0; const double dNorm = (double) 2.0;
/* mix all audio data from all clients together */ // mix all audio data from all clients together
for ( int i = 0; i < MIN_BLOCK_SIZE_SAMPLES; i++ ) for ( int i = 0; i < MIN_BLOCK_SIZE_SAMPLES; i++ )
{ {
double dMixedData = 0.0; double dMixedData = 0.0;
@ -157,7 +156,7 @@ CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData,
dMixedData += vecvecdData[j][i] * vecdGains[j]; dMixedData += vecvecdData[j][i] * vecdGains[j];
} }
/* normalization and truncating to short */ // normalization and truncating to short
vecsOutData[i] = Double2Short ( dMixedData / dNorm ); vecsOutData[i] = Double2Short ( dMixedData / dNorm );
} }
@ -166,7 +165,7 @@ CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData,
bool CServer::GetTimingStdDev ( double& dCurTiStdDev ) bool CServer::GetTimingStdDev ( double& dCurTiStdDev )
{ {
dCurTiStdDev = 0.0; /* init return value */ dCurTiStdDev = 0.0; // init return value
/* only return value if server is active and the actual measurement is /* only return value if server is active and the actual measurement is
updated */ updated */