2006-01-28 12:29:22 +01:00
|
|
|
/******************************************************************************\
|
|
|
|
* Copyright (c) 2004-2006
|
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
#include "llconclientdlg.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Implementation *************************************************************/
|
|
|
|
CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
2006-02-17 20:07:10 +01:00
|
|
|
const char* name, bool modal, WFlags f) : pClient ( pNCliP ),
|
2006-01-28 12:29:22 +01:00
|
|
|
CLlconClientDlgBase ( parent, name, modal, f )
|
|
|
|
{
|
|
|
|
/* add help text to controls */
|
|
|
|
QString strInpLevH = tr("<b>Input level meter:</b> Shows the level of the "
|
|
|
|
"input audio signal of the sound card. The level is in dB. Overload "
|
|
|
|
"should be avoided.");
|
|
|
|
QWhatsThis::add(TextLabelInputLevel, strInpLevH);
|
|
|
|
QWhatsThis::add(ProgressBarInputLevelL, strInpLevH);
|
|
|
|
QWhatsThis::add(ProgressBarInputLevelR, strInpLevH);
|
|
|
|
|
|
|
|
QWhatsThis::add(PushButtonConnect, tr("<b>Connect / Disconnect Button:"
|
|
|
|
"</b> Push this button to connect the server. A valid IP address has "
|
|
|
|
"to be specified before. If the client is connected, pressing this "
|
|
|
|
"button will disconnect the connection."));
|
|
|
|
|
|
|
|
QWhatsThis::add(TextLabelNameVersion, tr("<b>Version:</b> Shows the "
|
|
|
|
"current version of the software."));
|
|
|
|
|
|
|
|
QWhatsThis::add(TextLabelStatus, tr("<b>Status Bar:</b> In the status bar "
|
|
|
|
"different messages are displayed. E.g., if an error ocurred or the "
|
|
|
|
"status of the connection is shown."));
|
|
|
|
|
|
|
|
QString strServAddrH = tr("<b>Server Address:</b> In this edit control, "
|
|
|
|
"the IP address of the server can be set. If an invalid address was "
|
|
|
|
"chosen, an error message is shown in the status bar.");
|
|
|
|
QWhatsThis::add(TextLabelServerAddr, strServAddrH);
|
|
|
|
QWhatsThis::add(LineEditServerAddr, strServAddrH);
|
|
|
|
|
|
|
|
/* set text for version and application name */
|
|
|
|
TextLabelNameVersion->
|
2006-03-12 12:50:35 +01:00
|
|
|
setText(QString(APP_NAME) + tr(" client ") + QString(VERSION));
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* init server address line edit */
|
|
|
|
LineEditServerAddr->setText ( pClient->strIPAddress.c_str () );
|
|
|
|
|
|
|
|
/* init status label */
|
|
|
|
OnTimerStatus ();
|
|
|
|
|
|
|
|
/* init connection button text */
|
|
|
|
PushButtonConnect->setText ( CON_BUT_CONNECTTEXT );
|
|
|
|
|
|
|
|
/* Init timing jitter text label */
|
|
|
|
TextLabelStdDevTimer->setText ( "" );
|
|
|
|
|
|
|
|
/* init input level meter bars */
|
|
|
|
ProgressBarInputLevelL->setTotalSteps ( NUM_STEPS_INP_LEV_METER );
|
|
|
|
ProgressBarInputLevelL->setProgress ( 0 );
|
|
|
|
ProgressBarInputLevelR->setTotalSteps ( NUM_STEPS_INP_LEV_METER );
|
|
|
|
ProgressBarInputLevelR->setProgress ( 0 );
|
|
|
|
|
|
|
|
|
|
|
|
/* init slider controls --- */
|
|
|
|
/* sound buffer in */
|
|
|
|
SliderSndBufIn->setRange(2, AUD_SLIDER_LENGTH);
|
|
|
|
const int iCurNumInBuf = pClient->GetSndInterface()->GetInNumBuf();
|
|
|
|
SliderSndBufIn->setValue(iCurNumInBuf);
|
|
|
|
TextSndBufIn->setText("In: " + QString().setNum(iCurNumInBuf));
|
|
|
|
|
|
|
|
/* sound buffer out */
|
|
|
|
SliderSndBufOut->setRange(2, AUD_SLIDER_LENGTH);
|
|
|
|
const int iCurNumOutBuf = pClient->GetSndInterface()->GetOutNumBuf();
|
|
|
|
SliderSndBufOut->setValue(iCurNumOutBuf);
|
|
|
|
TextSndBufOut->setText("Out: " + QString().setNum(iCurNumOutBuf));
|
|
|
|
|
|
|
|
/* network buffer */
|
2006-03-12 11:43:48 +01:00
|
|
|
SliderNetBuf->setRange(0, MAX_NET_BUF_SIZE_NUM_BL);
|
2006-02-26 11:50:47 +01:00
|
|
|
const int iCurNumNetBuf = pClient->GetSockBufSize();
|
2006-01-28 12:29:22 +01:00
|
|
|
SliderNetBuf->setValue(iCurNumNetBuf);
|
|
|
|
TextNetBuf->setText("Size: " + QString().setNum(iCurNumNetBuf));
|
|
|
|
|
2006-03-13 21:23:05 +01:00
|
|
|
/* network buffer size factor in */
|
2006-10-30 21:35:46 +01:00
|
|
|
SliderNetBufSiFactIn->setRange(1, MAX_NET_BLOCK_SIZE_FACTOR);
|
2006-03-13 21:23:05 +01:00
|
|
|
const int iCurNetBufSiFactIn = pClient->GetNetwBufSizeFactIn();
|
|
|
|
SliderNetBufSiFactIn->setValue(iCurNetBufSiFactIn);
|
2006-10-04 20:05:33 +02:00
|
|
|
TextNetBufSiFactIn->setText("In:\n" + QString().setNum(
|
2006-03-13 21:23:05 +01:00
|
|
|
double(iCurNetBufSiFactIn * MIN_BLOCK_DURATION_MS), 'f', 2) +
|
|
|
|
" ms");
|
|
|
|
|
|
|
|
/* network buffer size factor out */
|
2006-10-30 21:35:46 +01:00
|
|
|
SliderNetBufSiFactOut->setRange(1, MAX_NET_BLOCK_SIZE_FACTOR);
|
2006-03-13 21:23:05 +01:00
|
|
|
const int iCurNetBufSiFactOut = pClient->GetNetwBufSizeFactOut();
|
|
|
|
SliderNetBufSiFactOut->setValue(iCurNetBufSiFactOut);
|
2006-10-04 20:05:33 +02:00
|
|
|
TextNetBufSiFactOut->setText("Out:\n" + QString().setNum(
|
2006-03-13 21:23:05 +01:00
|
|
|
double(iCurNetBufSiFactOut * MIN_BLOCK_DURATION_MS), 'f', 2) +
|
|
|
|
" ms");
|
2006-03-12 12:50:35 +01:00
|
|
|
|
2006-01-28 12:29:22 +01:00
|
|
|
/* audio in fader */
|
|
|
|
SliderAudInFader->setRange(0, AUD_FADER_IN_MAX);
|
|
|
|
const int iCurAudInFader = pClient->GetAudioInFader();
|
|
|
|
SliderAudInFader->setValue(iCurAudInFader);
|
|
|
|
SliderAudInFader->setTickInterval(AUD_FADER_IN_MAX / 9);
|
|
|
|
|
|
|
|
/* audio reverberation */
|
|
|
|
SliderAudReverb->setRange(0, AUD_REVERB_MAX);
|
|
|
|
const int iCurAudReverb = pClient->GetReverbLevel();
|
|
|
|
SliderAudReverb->setValue ( AUD_REVERB_MAX - iCurAudReverb );
|
|
|
|
SliderAudReverb->setTickInterval(AUD_REVERB_MAX / 9);
|
|
|
|
|
|
|
|
|
|
|
|
/* set radio buttons --- */
|
|
|
|
/* reverb channel */
|
|
|
|
if (pClient->IsReverbOnLeftChan())
|
|
|
|
RadioButtonRevSelL->setChecked(true);
|
|
|
|
else
|
|
|
|
RadioButtonRevSelR->setChecked(true);
|
|
|
|
|
|
|
|
|
|
|
|
/* Main menu bar -------------------------------------------------------- */
|
|
|
|
pMenu = new QMenuBar(this);
|
|
|
|
CHECK_PTR(pMenu);
|
|
|
|
pMenu->insertItem(tr("&?"), new CLlconHelpMenu(this));
|
|
|
|
pMenu->setSeparator(QMenuBar::InWindowsStyle);
|
|
|
|
|
|
|
|
/* Now tell the layout about the menu */
|
|
|
|
CLlconClientDlgBaseLayout->setMenuBar(pMenu);
|
|
|
|
|
|
|
|
|
|
|
|
/* connections ---------------------------------------------------------- */
|
|
|
|
/* push-buttons */
|
|
|
|
QObject::connect(PushButtonConnect, SIGNAL(clicked()),
|
|
|
|
this, SLOT(OnConnectDisconBut()));
|
|
|
|
|
|
|
|
/* timers */
|
|
|
|
QObject::connect(&TimerSigMet, SIGNAL(timeout()),
|
|
|
|
this, SLOT(OnTimerSigMet()));
|
|
|
|
QObject::connect(&TimerStatus, SIGNAL(timeout()),
|
|
|
|
this, SLOT(OnTimerStatus()));
|
|
|
|
|
|
|
|
/* sliders */
|
|
|
|
QObject::connect(SliderSndBufIn, SIGNAL(valueChanged(int)),
|
|
|
|
this, SLOT(OnSliderSndBufInChange(int)));
|
|
|
|
QObject::connect(SliderSndBufOut, SIGNAL(valueChanged(int)),
|
2006-03-12 12:50:35 +01:00
|
|
|
this, SLOT(OnSliderSndBufOutChange(int)));
|
|
|
|
|
2006-01-28 12:29:22 +01:00
|
|
|
QObject::connect(SliderNetBuf, SIGNAL(valueChanged(int)),
|
|
|
|
this, SLOT(OnSliderNetBuf(int)));
|
2006-03-13 21:23:05 +01:00
|
|
|
|
|
|
|
QObject::connect(SliderNetBufSiFactIn, SIGNAL(valueChanged(int)),
|
|
|
|
this, SLOT(OnSliderNetBufSiFactIn(int)));
|
|
|
|
QObject::connect(SliderNetBufSiFactOut, SIGNAL(valueChanged(int)),
|
|
|
|
this, SLOT(OnSliderNetBufSiFactOut(int)));
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
QObject::connect(SliderAudInFader, SIGNAL(valueChanged(int)),
|
|
|
|
this, SLOT(OnSliderAudInFader(int)));
|
|
|
|
QObject::connect(SliderAudReverb, SIGNAL(valueChanged(int)),
|
|
|
|
this, SLOT(OnSliderAudReverb(int)));
|
|
|
|
|
|
|
|
/* radio buttons */
|
|
|
|
QObject::connect(RadioButtonRevSelL, SIGNAL(clicked()),
|
|
|
|
this, SLOT(OnRevSelL()));
|
|
|
|
QObject::connect(RadioButtonRevSelR, SIGNAL(clicked()),
|
|
|
|
this, SLOT(OnRevSelR()));
|
2006-02-19 15:50:18 +01:00
|
|
|
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* timers --------------------------------------------------------------- */
|
|
|
|
/* start timer for status bar */
|
|
|
|
TimerStatus.start(STATUSBAR_UPDATE_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
CLlconClientDlg::~CLlconClientDlg()
|
|
|
|
{
|
|
|
|
/* if connected, terminate connection */
|
|
|
|
if (pClient->IsRunning())
|
|
|
|
{
|
|
|
|
pClient->Stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLlconClientDlg::closeEvent ( QCloseEvent * Event )
|
|
|
|
{
|
|
|
|
// store IP address
|
|
|
|
pClient->strIPAddress = LineEditServerAddr->text().latin1();
|
|
|
|
|
|
|
|
// default implementation of this event handler routine
|
|
|
|
Event->accept();
|
|
|
|
}
|
|
|
|
|
2006-10-03 23:16:23 +02:00
|
|
|
void CLlconClientDlg::OnConnectDisconBut ()
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
|
|
|
/* start/stop client, set button text */
|
2006-10-03 23:16:23 +02:00
|
|
|
if ( pClient->IsRunning () )
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
2006-10-03 23:16:23 +02:00
|
|
|
pClient->Stop ();
|
|
|
|
PushButtonConnect->setText ( CON_BUT_CONNECTTEXT );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* stop timer for level meter bars and reset them */
|
2006-10-03 23:16:23 +02:00
|
|
|
TimerSigMet.stop ();
|
|
|
|
ProgressBarInputLevelL->setProgress ( 0 );
|
|
|
|
ProgressBarInputLevelR->setProgress ( 0 );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* immediately update status bar */
|
2006-10-03 23:16:23 +02:00
|
|
|
OnTimerStatus ();
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* set address and check if address is valid */
|
2006-10-03 23:16:23 +02:00
|
|
|
if ( pClient->SetServerAddr ( LineEditServerAddr->text () ) )
|
|
|
|
{
|
|
|
|
#if ( QT_VERSION > 300 )
|
|
|
|
pClient->start ( QThread::TimeCriticalPriority );
|
|
|
|
#else
|
|
|
|
pClient->start ();
|
|
|
|
#endif
|
|
|
|
PushButtonConnect->setText ( CON_BUT_DISCONNECTTEXT );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* start timer for level meter bar */
|
2006-10-03 23:16:23 +02:00
|
|
|
TimerSigMet.start ( LEVELMETER_UPDATE_TIME );
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Restart timer to ensure that the text is visible at
|
|
|
|
least the time for one complete interval */
|
2006-10-03 23:16:23 +02:00
|
|
|
TimerStatus.changeInterval ( STATUSBAR_UPDATE_TIME );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* show the error in the status bar */
|
2006-10-03 23:16:23 +02:00
|
|
|
TextLabelStatus->setText ( tr ( "invalid address" ) );
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLlconClientDlg::OnSliderSndBufInChange(int value)
|
|
|
|
{
|
|
|
|
pClient->GetSndInterface()->SetInNumBuf(value);
|
|
|
|
TextSndBufIn->setText("In: " + QString().setNum(value));
|
2006-03-12 14:19:41 +01:00
|
|
|
UpdateDisplay();
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLlconClientDlg::OnSliderSndBufOutChange(int value)
|
|
|
|
{
|
|
|
|
pClient->GetSndInterface()->SetOutNumBuf(value);
|
|
|
|
TextSndBufOut->setText("Out: " + QString().setNum(value));
|
2006-03-12 14:19:41 +01:00
|
|
|
UpdateDisplay();
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLlconClientDlg::OnSliderNetBuf(int value)
|
|
|
|
{
|
2006-03-12 11:02:01 +01:00
|
|
|
pClient->SetSockBufSize ( value );
|
2006-01-28 12:29:22 +01:00
|
|
|
TextNetBuf->setText("Size: " + QString().setNum(value));
|
2006-03-12 14:19:41 +01:00
|
|
|
UpdateDisplay();
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
2006-03-12 12:50:35 +01:00
|
|
|
|
2006-03-13 21:23:05 +01:00
|
|
|
void CLlconClientDlg::OnSliderNetBufSiFactIn(int value)
|
2006-03-12 12:50:35 +01:00
|
|
|
{
|
2006-03-13 21:23:05 +01:00
|
|
|
pClient->SetNetwBufSizeFactIn ( value );
|
2006-10-04 20:05:33 +02:00
|
|
|
TextNetBufSiFactIn->setText("In:\n" + QString().setNum(
|
2006-03-13 21:23:05 +01:00
|
|
|
double(value * MIN_BLOCK_DURATION_MS), 'f', 2) +
|
|
|
|
" ms");
|
|
|
|
UpdateDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLlconClientDlg::OnSliderNetBufSiFactOut(int value)
|
|
|
|
{
|
|
|
|
pClient->SetNetwBufSizeFactOut ( value );
|
2006-10-04 20:05:33 +02:00
|
|
|
TextNetBufSiFactOut->setText("Out:\n" + QString().setNum(
|
2006-03-13 21:23:05 +01:00
|
|
|
double(value * MIN_BLOCK_DURATION_MS), 'f', 2) +
|
|
|
|
" ms");
|
2006-03-12 14:19:41 +01:00
|
|
|
UpdateDisplay();
|
2006-03-12 12:50:35 +01:00
|
|
|
}
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-02-18 18:03:24 +01:00
|
|
|
void CLlconClientDlg::OnTimerSigMet ()
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
|
|
|
/* get current input levels */
|
2006-02-18 18:03:24 +01:00
|
|
|
double dCurSigLevelL = pClient->MicLevelL ();
|
|
|
|
double dCurSigLevelR = pClient->MicLevelR ();
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* linear transformation of the input level range to the progress-bar
|
|
|
|
range */
|
|
|
|
dCurSigLevelL -= LOW_BOUND_SIG_METER;
|
|
|
|
dCurSigLevelL *= NUM_STEPS_INP_LEV_METER /
|
2006-02-18 18:03:24 +01:00
|
|
|
( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
|
|
|
|
|
|
|
|
// lower bound the signal
|
|
|
|
if ( dCurSigLevelL < 0 )
|
|
|
|
{
|
|
|
|
dCurSigLevelL = 0;
|
|
|
|
}
|
|
|
|
|
2006-01-28 12:29:22 +01:00
|
|
|
dCurSigLevelR -= LOW_BOUND_SIG_METER;
|
|
|
|
dCurSigLevelR *= NUM_STEPS_INP_LEV_METER /
|
2006-02-18 18:03:24 +01:00
|
|
|
( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
|
|
|
|
|
|
|
|
// lower bound the signal
|
|
|
|
if ( dCurSigLevelR < 0 )
|
|
|
|
{
|
|
|
|
dCurSigLevelR = 0;
|
|
|
|
}
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* show current level */
|
2006-02-18 18:03:24 +01:00
|
|
|
ProgressBarInputLevelL->setProgress ( (int) ceil ( dCurSigLevelL ) );
|
|
|
|
ProgressBarInputLevelR->setProgress ( (int) ceil ( dCurSigLevelR ) );
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
2006-03-12 14:19:41 +01:00
|
|
|
|
|
|
|
void CLlconClientDlg::UpdateDisplay()
|
|
|
|
{
|
|
|
|
/* show connection status in status bar */
|
2006-02-18 18:03:24 +01:00
|
|
|
if ( pClient->IsConnected () && pClient->IsRunning () )
|
2006-03-12 14:19:41 +01:00
|
|
|
{
|
2006-02-18 18:03:24 +01:00
|
|
|
TextLabelStatus->setText ( tr ( "connected" ) );
|
2006-03-12 14:19:41 +01:00
|
|
|
}
|
2006-02-18 18:03:24 +01:00
|
|
|
else
|
2006-03-12 14:19:41 +01:00
|
|
|
{
|
2006-02-18 18:03:24 +01:00
|
|
|
TextLabelStatus->setText ( tr ( "disconnected" ) );
|
2006-03-12 14:19:41 +01:00
|
|
|
}
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* response time */
|
|
|
|
TextLabelStdDevTimer->setText(QString().
|
|
|
|
setNum(pClient->GetTimingStdDev(), 'f', 2) + " ms");
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLlconClientDlg::customEvent(QCustomEvent* Event)
|
|
|
|
{
|
|
|
|
if (Event->type() == QEvent::User + 11)
|
|
|
|
{
|
|
|
|
const int iMessType = ((CLlconEvent*) Event)->iMessType;
|
|
|
|
const int iStatus = ((CLlconEvent*) Event)->iStatus;
|
|
|
|
|
|
|
|
switch(iMessType)
|
|
|
|
{
|
|
|
|
case MS_SOUND_IN:
|
|
|
|
CLEDSoundIn->SetLight(iStatus);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MS_SOUND_OUT:
|
|
|
|
CLEDSoundOut->SetLight(iStatus);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MS_JIT_BUF_PUT:
|
|
|
|
CLEDNetwPut->SetLight(iStatus);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MS_JIT_BUF_GET:
|
|
|
|
CLEDNetwGet->SetLight(iStatus);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MS_RESET_ALL:
|
|
|
|
CLEDSoundIn->Reset();
|
|
|
|
CLEDSoundOut->Reset();
|
|
|
|
CLEDNetwPut->Reset();
|
|
|
|
CLEDNetwGet->Reset();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|