diff --git a/src/buffer.h b/src/buffer.h index c53a4328..1eb088ac 100755 --- a/src/buffer.h +++ b/src/buffer.h @@ -32,7 +32,7 @@ /* Definitions ****************************************************************/ // time for fading effect for masking drop outs #define FADE_IN_OUT_TIME ( (double) 0.3 ) // ms -#define FADE_IN_OUT_NUM_SAM ( (int) ( SAMPLE_RATE * FADE_IN_OUT_TIME ) / 1000 ) +#define FADE_IN_OUT_NUM_SAM ( (int) ( SERVER_SAMPLE_RATE * FADE_IN_OUT_TIME ) / 1000 ) // for extrapolation a shorter time for fading #define FADE_IN_OUT_NUM_SAM_EXTRA 5 // samples diff --git a/src/channel.cpp b/src/channel.cpp index 1677d8a6..247cf899 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -679,7 +679,7 @@ for (int i = 0; i < BLOCK_SIZE_SAMPLES; i++) vecdResInData[i] = (double) vecsData[i]; const int iInSize = ResampleObj.Resample(vecdResInData, vecdResOutData, - (double) SAMPLE_RATE / (SAMPLE_RATE - dSamRateOffset)); + (double) SERVER_SAMPLE_RATE / (SERVER_SAMPLE_RATE - dSamRateOffset)); */ vecdResOutData.Init ( iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES ); @@ -798,7 +798,7 @@ CVector CChannel::PrepSendPacket ( const CVector& vecsNPac void CSampleOffsetEst::Init() { /* init sample rate estimation */ - dSamRateEst = SAMPLE_RATE; + dSamRateEst = SERVER_SAMPLE_RATE; /* init vectors storing the data */ veciTimeElapsed.Init(VEC_LEN_SAM_OFFS_EST); diff --git a/src/client.cpp b/src/client.cpp index 9b161a88..5d95229f 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -93,8 +93,9 @@ void CClient::OnNewConnection() void CClient::OnReceivePingMessage ( QTime time ) { - // calculate difference between received time and current time - emit PingTimeReceived ( time.msecsTo ( QTime().currentTime() ) ); + // calculate difference between received time and current time, add one + // ms because QT seems to use a "floor" operation on "msecsTo()" function + emit PingTimeReceived ( time.msecsTo ( QTime().currentTime() ) + 1 /* ms */ ); } bool CClient::SetServerAddr ( QString strNAddr ) @@ -172,12 +173,12 @@ void CClient::Init() // resample objects are always initialized with the input block size // record - ResampleObjDownL.Init ( iSndCrdBlockSizeSam, SND_CRD_SAMPLE_RATE, SAMPLE_RATE ); - ResampleObjDownR.Init ( iSndCrdBlockSizeSam, SND_CRD_SAMPLE_RATE, SAMPLE_RATE ); + ResampleObjDownL.Init ( iSndCrdBlockSizeSam, SND_CRD_SAMPLE_RATE, SERVER_SAMPLE_RATE ); + ResampleObjDownR.Init ( iSndCrdBlockSizeSam, SND_CRD_SAMPLE_RATE, SERVER_SAMPLE_RATE ); // playback - ResampleObjUpL.Init ( iBlockSizeSam, SAMPLE_RATE, SND_CRD_SAMPLE_RATE ); - ResampleObjUpR.Init ( iBlockSizeSam, SAMPLE_RATE, SND_CRD_SAMPLE_RATE ); + ResampleObjUpL.Init ( iBlockSizeSam, SERVER_SAMPLE_RATE, SND_CRD_SAMPLE_RATE ); + ResampleObjUpR.Init ( iBlockSizeSam, SERVER_SAMPLE_RATE, SND_CRD_SAMPLE_RATE ); // init network buffers vecsNetwork.Init ( iBlockSizeSam ); @@ -266,7 +267,7 @@ void CClient::run() // add reverberation effect if activated if ( iReverbLevel != 0 ) { - // first attenuation amplification factor + // calculate attenuation amplification factor const double dRevLev = (double) iReverbLevel / AUD_REVERB_MAX / 2; if ( bReverbOnLeftChan ) @@ -332,7 +333,7 @@ void CClient::run() connected to the server. In this case, exactly the same audio material is coming back and we can simply compare the samples */ /* store send data instatic buffer (may delay is 100 ms) */ -const int iMaxDelaySamples = (int) ((float) 0.3 /*0.1*/ * SAMPLE_RATE); +const int iMaxDelaySamples = (int) ((float) 0.3 /*0.1*/ * SERVER_SAMPLE_RATE); static CVector vecsOutBuf(iMaxDelaySamples); /* update buffer */ diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index b2bda28c..13ac8006 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -215,9 +215,18 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime ) void CClientSettingsDlg::UpdateDisplay() { - // response time - TextLabelStdDevTimer->setText ( QString(). - setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" ); + if ( pClient->IsRunning() ) + { + // response time + TextLabelStdDevTimer->setText ( QString(). + setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" ); + } + else + { + // clear text labels with client parameters + TextLabelStdDevTimer->setText ( "" ); + TextLabelPingTime->setText ( "" ); + } } void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus ) diff --git a/src/clientsettingsdlgbase.ui b/src/clientsettingsdlgbase.ui index 63b8773d..55b38c0b 100755 --- a/src/clientsettingsdlgbase.ui +++ b/src/clientsettingsdlgbase.ui @@ -5,8 +5,8 @@ 0 0 - 425 - 257 + 443 + 244 @@ -770,6 +770,12 @@ + + + 40 + 0 + + val diff --git a/src/global.h b/src/global.h index 18e207dd..7b6aec94 100755 --- a/src/global.h +++ b/src/global.h @@ -52,8 +52,8 @@ // defined port number for client and server #define LLCON_PORT_NUMBER 22122 -// sample rate -#define SAMPLE_RATE 24000 +// server sample rate +#define SERVER_SAMPLE_RATE 24000 // sound card sample rate. Should be always 48 kHz to avoid sound card driver // internal sample rate conversion which might be buggy @@ -63,11 +63,11 @@ // of this duration #define MIN_BLOCK_DURATION_MS 2 // ms -#define MIN_BLOCK_SIZE_SAMPLES ( MIN_BLOCK_DURATION_MS * SAMPLE_RATE / 1000 ) +#define MIN_BLOCK_SIZE_SAMPLES ( MIN_BLOCK_DURATION_MS * SERVER_SAMPLE_RATE / 1000 ) #define MIN_SND_CRD_BLOCK_SIZE_SAMPLES ( MIN_BLOCK_DURATION_MS * SND_CRD_SAMPLE_RATE / 1000 ) // maximum value of factor for network block size -#define MAX_NET_BLOCK_SIZE_FACTOR 4 +#define MAX_NET_BLOCK_SIZE_FACTOR 3 // default network block size factor #define DEF_NET_BLOCK_SIZE_FACTOR 3 diff --git a/src/util.cpp b/src/util.cpp index 9ff58b34..2c6d821c 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -140,7 +140,7 @@ CAudioReverb::CAudioReverb ( const double rT60 ) // delay lengths for 44100 Hz sample rate int lengths[9] = { 1777, 1847, 1993, 2137, 389, 127, 43, 211, 179 }; - const double scaler = (double) SAMPLE_RATE / 44100.0; + const double scaler = (double) SERVER_SAMPLE_RATE / 44100.0; if ( scaler != 1.0 ) { @@ -224,7 +224,7 @@ void CAudioReverb::setT60 ( const double rT60 ) for ( int i = 0; i < 4; i++ ) { combCoefficient_[i] = pow ( (double) 10.0, (double) ( -3.0 * - combDelays_[i].Size() / ( rT60 * SAMPLE_RATE ) ) ); + combDelays_[i].Size() / ( rT60 * SERVER_SAMPLE_RATE ) ) ); } }