some fixes and preparations

This commit is contained in:
Volker Fischer 2008-08-03 21:38:24 +00:00
parent 0720d74a29
commit 0b7c401c9a
7 changed files with 38 additions and 22 deletions

View file

@ -32,7 +32,7 @@
/* Definitions ****************************************************************/ /* Definitions ****************************************************************/
// time for fading effect for masking drop outs // time for fading effect for masking drop outs
#define FADE_IN_OUT_TIME ( (double) 0.3 ) // ms #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 // for extrapolation a shorter time for fading
#define FADE_IN_OUT_NUM_SAM_EXTRA 5 // samples #define FADE_IN_OUT_NUM_SAM_EXTRA 5 // samples

View file

@ -679,7 +679,7 @@ for (int i = 0; i < BLOCK_SIZE_SAMPLES; i++)
vecdResInData[i] = (double) vecsData[i]; vecdResInData[i] = (double) vecsData[i];
const int iInSize = ResampleObj.Resample(vecdResInData, vecdResOutData, 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 ); vecdResOutData.Init ( iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES );
@ -798,7 +798,7 @@ CVector<unsigned char> CChannel::PrepSendPacket ( const CVector<short>& vecsNPac
void CSampleOffsetEst::Init() void CSampleOffsetEst::Init()
{ {
/* init sample rate estimation */ /* init sample rate estimation */
dSamRateEst = SAMPLE_RATE; dSamRateEst = SERVER_SAMPLE_RATE;
/* init vectors storing the data */ /* init vectors storing the data */
veciTimeElapsed.Init(VEC_LEN_SAM_OFFS_EST); veciTimeElapsed.Init(VEC_LEN_SAM_OFFS_EST);

View file

@ -93,8 +93,9 @@ void CClient::OnNewConnection()
void CClient::OnReceivePingMessage ( QTime time ) void CClient::OnReceivePingMessage ( QTime time )
{ {
// calculate difference between received time and current time // calculate difference between received time and current time, add one
emit PingTimeReceived ( time.msecsTo ( QTime().currentTime() ) ); // 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 ) bool CClient::SetServerAddr ( QString strNAddr )
@ -172,12 +173,12 @@ void CClient::Init()
// resample objects are always initialized with the input block size // resample objects are always initialized with the input block size
// record // record
ResampleObjDownL.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, SAMPLE_RATE ); ResampleObjDownR.Init ( iSndCrdBlockSizeSam, SND_CRD_SAMPLE_RATE, SERVER_SAMPLE_RATE );
// playback // playback
ResampleObjUpL.Init ( iBlockSizeSam, SAMPLE_RATE, SND_CRD_SAMPLE_RATE ); ResampleObjUpL.Init ( iBlockSizeSam, SERVER_SAMPLE_RATE, SND_CRD_SAMPLE_RATE );
ResampleObjUpR.Init ( iBlockSizeSam, SAMPLE_RATE, SND_CRD_SAMPLE_RATE ); ResampleObjUpR.Init ( iBlockSizeSam, SERVER_SAMPLE_RATE, SND_CRD_SAMPLE_RATE );
// init network buffers // init network buffers
vecsNetwork.Init ( iBlockSizeSam ); vecsNetwork.Init ( iBlockSizeSam );
@ -266,7 +267,7 @@ void CClient::run()
// add reverberation effect if activated // add reverberation effect if activated
if ( iReverbLevel != 0 ) if ( iReverbLevel != 0 )
{ {
// first attenuation amplification factor // calculate attenuation amplification factor
const double dRevLev = (double) iReverbLevel / AUD_REVERB_MAX / 2; const double dRevLev = (double) iReverbLevel / AUD_REVERB_MAX / 2;
if ( bReverbOnLeftChan ) if ( bReverbOnLeftChan )
@ -332,7 +333,7 @@ void CClient::run()
connected to the server. In this case, exactly the same audio material is connected to the server. In this case, exactly the same audio material is
coming back and we can simply compare the samples */ coming back and we can simply compare the samples */
/* store send data instatic buffer (may delay is 100 ms) */ /* 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<short> vecsOutBuf(iMaxDelaySamples); static CVector<short> vecsOutBuf(iMaxDelaySamples);
/* update buffer */ /* update buffer */

View file

@ -215,9 +215,18 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
void CClientSettingsDlg::UpdateDisplay() void CClientSettingsDlg::UpdateDisplay()
{ {
if ( pClient->IsRunning() )
{
// response time // response time
TextLabelStdDevTimer->setText ( QString(). TextLabelStdDevTimer->setText ( QString().
setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" ); 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 ) void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus )

View file

@ -5,8 +5,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>425</width> <width>443</width>
<height>257</height> <height>244</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -770,6 +770,12 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="TextLabelPingTime" > <widget class="QLabel" name="TextLabelPingTime" >
<property name="minimumSize" >
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="text" > <property name="text" >
<string>val</string> <string>val</string>
</property> </property>

View file

@ -52,8 +52,8 @@
// defined port number for client and server // defined port number for client and server
#define LLCON_PORT_NUMBER 22122 #define LLCON_PORT_NUMBER 22122
// sample rate // server sample rate
#define SAMPLE_RATE 24000 #define SERVER_SAMPLE_RATE 24000
// sound card sample rate. Should be always 48 kHz to avoid sound card driver // sound card sample rate. Should be always 48 kHz to avoid sound card driver
// internal sample rate conversion which might be buggy // internal sample rate conversion which might be buggy
@ -63,11 +63,11 @@
// of this duration // of this duration
#define MIN_BLOCK_DURATION_MS 2 // ms #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 ) #define MIN_SND_CRD_BLOCK_SIZE_SAMPLES ( MIN_BLOCK_DURATION_MS * SND_CRD_SAMPLE_RATE / 1000 )
// maximum value of factor for network block size // 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 // default network block size factor
#define DEF_NET_BLOCK_SIZE_FACTOR 3 #define DEF_NET_BLOCK_SIZE_FACTOR 3

View file

@ -140,7 +140,7 @@ CAudioReverb::CAudioReverb ( const double rT60 )
// delay lengths for 44100 Hz sample rate // delay lengths for 44100 Hz sample rate
int lengths[9] = { 1777, 1847, 1993, 2137, 389, 127, 43, 211, 179 }; 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 ) if ( scaler != 1.0 )
{ {
@ -224,7 +224,7 @@ void CAudioReverb::setT60 ( const double rT60 )
for ( int i = 0; i < 4; i++ ) for ( int i = 0; i < 4; i++ )
{ {
combCoefficient_[i] = pow ( (double) 10.0, (double) ( -3.0 * combCoefficient_[i] = pow ( (double) 10.0, (double) ( -3.0 *
combDelays_[i].Size() / ( rT60 * SAMPLE_RATE ) ) ); combDelays_[i].Size() / ( rT60 * SERVER_SAMPLE_RATE ) ) );
} }
} }