use units in constants (e.g. HZ, MS), some more work on server list

This commit is contained in:
Volker Fischer 2011-03-31 07:10:43 +00:00
parent 2b594ad000
commit d470a0bb68
11 changed files with 109 additions and 70 deletions

View file

@ -37,7 +37,7 @@ CChannel::CChannel ( const bool bNIsServer ) :
// initial value for connection time out counter, we calculate the total // initial value for connection time out counter, we calculate the total
// number of samples here and subtract the number of samples of the block // number of samples here and subtract the number of samples of the block
// which we take out of the buffer to be independent of block sizes // which we take out of the buffer to be independent of block sizes
iConTimeOutStartVal = CON_TIME_OUT_SEC_MAX * SYSTEM_SAMPLE_RATE; iConTimeOutStartVal = CON_TIME_OUT_SEC_MAX * SYSTEM_SAMPLE_RATE_HZ;
// init time-out for the buffer with zero -> no connection // init time-out for the buffer with zero -> no connection
iConTimeOut = 0; iConTimeOut = 0;
@ -47,7 +47,7 @@ CChannel::CChannel ( const bool bNIsServer ) :
// initialize cycle time variance measurement with defaults // initialize cycle time variance measurement with defaults
CycleTimeVariance.Init ( SYSTEM_FRAME_SIZE_SAMPLES, CycleTimeVariance.Init ( SYSTEM_FRAME_SIZE_SAMPLES,
SYSTEM_SAMPLE_RATE, TIME_MOV_AV_RESPONSE ); SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS );
// initialize channel name // initialize channel name
ResetName(); ResetName();
@ -155,7 +155,7 @@ void CChannel::SetAudioStreamProperties ( const int iNewNetwFrameSize,
// initialize and reset cycle time variance measurement // initialize and reset cycle time variance measurement
CycleTimeVariance.Init ( iNetwFrameSizeFact * SYSTEM_FRAME_SIZE_SAMPLES, CycleTimeVariance.Init ( iNetwFrameSizeFact * SYSTEM_FRAME_SIZE_SAMPLES,
SYSTEM_SAMPLE_RATE, TIME_MOV_AV_RESPONSE ); SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS );
CycleTimeVariance.Reset(); CycleTimeVariance.Reset();
@ -321,7 +321,7 @@ void CChannel::CreateNetTranspPropsMessFromCurrentSettings()
iNetwFrameSize, iNetwFrameSize,
iNetwFrameSizeFact, iNetwFrameSizeFact,
iNumAudioChannels, iNumAudioChannels,
SYSTEM_SAMPLE_RATE, SYSTEM_SAMPLE_RATE_HZ,
CT_CELT, // always CELT coding CT_CELT, // always CELT coding
0, // version of the codec 0, // version of the codec
0 ); 0 );
@ -546,7 +546,7 @@ int CChannel::GetUploadRateKbps()
// 8 (UDP) + 20 (IP without optional fields) = 28 bytes // 8 (UDP) + 20 (IP without optional fields) = 28 bytes
return ( iNetwFrameSize * iNetwFrameSizeFact + 28 /* header */ ) * return ( iNetwFrameSize * iNetwFrameSizeFact + 28 /* header */ ) *
8 /* bits per byte */ * 8 /* bits per byte */ *
SYSTEM_SAMPLE_RATE / iAudioSizeOut / 1000; SYSTEM_SAMPLE_RATE_HZ / iAudioSizeOut / 1000;
} }

View file

@ -58,7 +58,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
{ {
// init audio encoder/decoder (mono) // init audio encoder/decoder (mono)
CeltModeMono = celt_mode_create ( CeltModeMono = celt_mode_create (
SYSTEM_SAMPLE_RATE, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderMono = celt_encoder_create ( CeltModeMono ); CeltEncoderMono = celt_encoder_create ( CeltModeMono );
CeltDecoderMono = celt_decoder_create ( CeltModeMono ); CeltDecoderMono = celt_decoder_create ( CeltModeMono );
@ -71,7 +71,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
// init audio encoder/decoder (stereo) // init audio encoder/decoder (stereo)
CeltModeStereo = celt_mode_create ( CeltModeStereo = celt_mode_create (
SYSTEM_SAMPLE_RATE, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderStereo = celt_encoder_create ( CeltModeStereo ); CeltEncoderStereo = celt_encoder_create ( CeltModeStereo );
CeltDecoderStereo = celt_decoder_create ( CeltModeStereo ); CeltDecoderStereo = celt_decoder_create ( CeltModeStereo );
@ -557,13 +557,13 @@ void CClient::Init()
// init response time evaluation // init response time evaluation
CycleTimeVariance.Init ( iMonoBlockSizeSam, CycleTimeVariance.Init ( iMonoBlockSizeSam,
SYSTEM_SAMPLE_RATE, TIME_MOV_AV_RESPONSE ); SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS );
CycleTimeVariance.Reset(); CycleTimeVariance.Reset();
// init reverberation // init reverberation
AudioReverbL.Init ( SYSTEM_SAMPLE_RATE ); AudioReverbL.Init ( SYSTEM_SAMPLE_RATE_HZ );
AudioReverbR.Init ( SYSTEM_SAMPLE_RATE ); AudioReverbR.Init ( SYSTEM_SAMPLE_RATE_HZ );
// inits for CELT coding // inits for CELT coding
if ( bCeltDoHighQuality ) if ( bCeltDoHighQuality )
@ -931,7 +931,7 @@ void CClient::UpdateSocketBufferSize()
const double dAudioBufferDurationMs = const double dAudioBufferDurationMs =
( GetSndCrdActualMonoBlSize() + ( GetSndCrdActualMonoBlSize() +
GetSndCrdConvBufAdditionalDelayMonoBlSize() ) * GetSndCrdConvBufAdditionalDelayMonoBlSize() ) *
1000 / SYSTEM_SAMPLE_RATE; 1000 / SYSTEM_SAMPLE_RATE_HZ;
// jitter introduced in the server by the timer implementation // jitter introduced in the server by the timer implementation
const double dServerJitterMs = 0.666666; // ms const double dServerJitterMs = 0.666666; // ms
@ -996,12 +996,12 @@ int CClient::EstimatedOverallDelay ( const int iPingTimeMs )
const double dTotalSoundCardDelayMs = const double dTotalSoundCardDelayMs =
( 3 * GetSndCrdActualMonoBlSize() + ( 3 * GetSndCrdActualMonoBlSize() +
GetSndCrdConvBufAdditionalDelayMonoBlSize() ) * GetSndCrdConvBufAdditionalDelayMonoBlSize() ) *
1000 / SYSTEM_SAMPLE_RATE; 1000 / SYSTEM_SAMPLE_RATE_HZ;
// network packets are of the same size as the audio packets per definition // network packets are of the same size as the audio packets per definition
// if no sound card conversion buffer is used // if no sound card conversion buffer is used
const double dDelayToFillNetworkPacketsMs = const double dDelayToFillNetworkPacketsMs =
GetSystemMonoBlSize() * 1000 / SYSTEM_SAMPLE_RATE; GetSystemMonoBlSize() * 1000 / SYSTEM_SAMPLE_RATE_HZ;
// CELT additional delay at small frame sizes is half a frame size // CELT additional delay at small frame sizes is half a frame size
const double dAdditionalAudioCodecDelayMs = const double dAdditionalAudioCodecDelayMs =

View file

@ -236,7 +236,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
#endif #endif
// init delay and other information controls // init delay and other information controls
CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME ); CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME_MS );
CLEDOverallDelay->Reset(); CLEDOverallDelay->Reset();
TextLabelPingTime->setText ( "" ); TextLabelPingTime->setText ( "" );
TextLabelOverallDelay->setText ( "" ); TextLabelOverallDelay->setText ( "" );
@ -394,7 +394,7 @@ QString CClientSettingsDlg::GenSndCrdBufferDelayString ( const int iFrameSize,
// use two times the buffer delay for the entire delay since // use two times the buffer delay for the entire delay since
// we have input and output // we have input and output
return QString().setNum ( (double) iFrameSize * 2 * return QString().setNum ( (double) iFrameSize * 2 *
1000 / SYSTEM_SAMPLE_RATE, 'f', 2 ) + " ms (" + 1000 / SYSTEM_SAMPLE_RATE_HZ, 'f', 2 ) + " ms (" +
QString().setNum ( iFrameSize ) + strAddText + ")"; QString().setNum ( iFrameSize ) + strAddText + ")";
} }

View file

@ -58,7 +58,7 @@ pListViewItem = new QTreeWidgetItem ( ListViewServers );
void CConnectDlg::showEvent ( QShowEvent* ) void CConnectDlg::showEvent ( QShowEvent* )
{ {
// only activate ping timer if window is actually shown // only activate ping timer if window is actually shown
TimerPing.start ( PING_UPDATE_TIME ); TimerPing.start ( PING_UPDATE_TIME_MS );
// UpdateDisplay(); // UpdateDisplay();
} }

View file

@ -62,7 +62,7 @@
#define LLCON_DEFAULT_PORT_NUMBER 22124 #define LLCON_DEFAULT_PORT_NUMBER 22124
// system sample rate (the sound card and audio coder works on this sample rate) // system sample rate (the sound card and audio coder works on this sample rate)
#define SYSTEM_SAMPLE_RATE 48000 #define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz
// System block size, this is the block size on which the audio coder works. // System block size, this is the block size on which the audio coder works.
// All other block sizes must be a multiple of this size // All other block sizes must be a multiple of this size
@ -70,7 +70,7 @@
#define SYSTEM_BLOCK_DURATION_MS_FLOAT \ #define SYSTEM_BLOCK_DURATION_MS_FLOAT \
( static_cast<double> ( SYSTEM_FRAME_SIZE_SAMPLES ) / \ ( static_cast<double> ( SYSTEM_FRAME_SIZE_SAMPLES ) / \
SYSTEM_SAMPLE_RATE * 1000 ) SYSTEM_SAMPLE_RATE_HZ * 1000 )
// define the allowed audio frame size factors (since the // define the allowed audio frame size factors (since the
// "SYSTEM_FRAME_SIZE_SAMPLES" is quite small, it may be that on some // "SYSTEM_FRAME_SIZE_SAMPLES" is quite small, it may be that on some
@ -128,11 +128,24 @@
// without any other changes in the code // without any other changes in the code
#define USED_NUM_CHANNELS 6 // used number channels for server #define USED_NUM_CHANNELS 6 // used number channels for server
// defines the time interval at which the ping time is updated in the GUI // defines the time interval at which the ping time is updated in the GUI
#define PING_UPDATE_TIME 500 // ms #define PING_UPDATE_TIME_MS 500 // ms
// time-out until a registered server is deleted from the server list if no
// new registering was made in minutes
#define SERVLIST_TIME_OUT_MINUTES 60 // minutes
// poll time for server list (to check if entries are time-out)
#define SERVLIST_POLL_TIME_MINUTES 1 // minute
// time until a slave server registers in the server list
#define SERVLIST_REGIST_INTERV_MINUTES 30 // minutes
// length of the moving average buffer for response time measurement // length of the moving average buffer for response time measurement
#define TIME_MOV_AV_RESPONSE 30 // seconds #define TIME_MOV_AV_RESPONSE_SECONDS 30 // seconds
// Maximum length of fader tag and text message strings (Since for chat messages // Maximum length of fader tag and text message strings (Since for chat messages
// some HTML code is added, we also have to define a second length which includes // some HTML code is added, we also have to define a second length which includes

View file

@ -280,9 +280,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
MultiColorLEDBarInputLevelR->setValue ( 0 ); MultiColorLEDBarInputLevelR->setValue ( 0 );
// init status LEDs // init status LEDs
LEDConnection->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME ); LEDConnection->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME_MS );
LEDChat->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME ); LEDChat->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME_MS );
LEDDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME ); LEDDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME_MS );
LEDDelay->Reset(); LEDDelay->Reset();
@ -442,7 +442,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
// Timers ------------------------------------------------------------------ // Timers ------------------------------------------------------------------
// start timer for status bar // start timer for status bar
TimerStatus.start ( LED_BAR_UPDATE_TIME ); TimerStatus.start ( LED_BAR_UPDATE_TIME_MS );
// TEST // TEST
@ -797,8 +797,8 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
PushButtonConnect->setText ( CON_BUT_DISCONNECTTEXT ); PushButtonConnect->setText ( CON_BUT_DISCONNECTTEXT );
// start timer for level meter bar and ping time measurement // start timer for level meter bar and ping time measurement
TimerSigMet.start ( LEVELMETER_UPDATE_TIME ); TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
TimerPing.start ( PING_UPDATE_TIME ); TimerPing.start ( PING_UPDATE_TIME_MS );
} }
} }
else else

View file

@ -57,8 +57,8 @@
#define CON_BUT_DISCONNECTTEXT "D&isconnect" #define CON_BUT_DISCONNECTTEXT "D&isconnect"
// update time for GUI controls // update time for GUI controls
#define LEVELMETER_UPDATE_TIME 100 // ms #define LEVELMETER_UPDATE_TIME_MS 100 // ms
#define LED_BAR_UPDATE_TIME 1000 // ms #define LED_BAR_UPDATE_TIME_MS 1000 // ms
// range for signal level meter // range for signal level meter
#define LOW_BOUND_SIG_METER ( -50.0 ) // dB #define LOW_BOUND_SIG_METER ( -50.0 ) // dB

View file

@ -37,7 +37,7 @@ CHighPrecisionTimer::CHighPrecisionTimer() :
// calculate delay in mach absolute time // calculate delay in mach absolute time
const uint64_t iNsDelay = const uint64_t iNsDelay =
( (uint64_t) SYSTEM_FRAME_SIZE_SAMPLES * 1000000000 ) / ( (uint64_t) SYSTEM_FRAME_SIZE_SAMPLES * 1000000000 ) /
(uint64_t) SYSTEM_SAMPLE_RATE; // in ns (uint64_t) SYSTEM_SAMPLE_RATE_HZ; // in ns
struct mach_timebase_info timeBaseInfo; struct mach_timebase_info timeBaseInfo;
mach_timebase_info ( &timeBaseInfo ); mach_timebase_info ( &timeBaseInfo );
@ -94,7 +94,7 @@ CHighPrecisionTimer::CHighPrecisionTimer()
#if ( SYSTEM_FRAME_SIZE_SAMPLES != 128 ) #if ( SYSTEM_FRAME_SIZE_SAMPLES != 128 )
# error "Only system frame size of 128 samples is supported by this module" # error "Only system frame size of 128 samples is supported by this module"
#endif #endif
#if SYSTEM_SAMPLE_RATE != 48000 #if SYSTEM_SAMPLE_RATE_HZ != 48000
# error "Only a system sample rate of 48 kHz is supported by this module" # error "Only a system sample rate of 48 kHz is supported by this module"
#endif #endif
@ -181,7 +181,7 @@ CServer::CServer ( const QString& strLoggingFileName,
{ {
// init audio endocder/decoder (mono) // init audio endocder/decoder (mono)
CeltModeMono[i] = celt_mode_create ( CeltModeMono[i] = celt_mode_create (
SYSTEM_SAMPLE_RATE, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderMono[i] = celt_encoder_create ( CeltModeMono[i] ); CeltEncoderMono[i] = celt_encoder_create ( CeltModeMono[i] );
CeltDecoderMono[i] = celt_decoder_create ( CeltModeMono[i] ); CeltDecoderMono[i] = celt_decoder_create ( CeltModeMono[i] );
@ -194,7 +194,7 @@ CServer::CServer ( const QString& strLoggingFileName,
// init audio endocder/decoder (stereo) // init audio endocder/decoder (stereo)
CeltModeStereo[i] = celt_mode_create ( CeltModeStereo[i] = celt_mode_create (
SYSTEM_SAMPLE_RATE, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderStereo[i] = celt_encoder_create ( CeltModeStereo[i] ); CeltEncoderStereo[i] = celt_encoder_create ( CeltModeStereo[i] );
CeltDecoderStereo[i] = celt_decoder_create ( CeltModeStereo[i] ); CeltDecoderStereo[i] = celt_decoder_create ( CeltModeStereo[i] );
@ -219,7 +219,7 @@ CServer::CServer ( const QString& strLoggingFileName,
// init moving average buffer for response time evaluation // init moving average buffer for response time evaluation
CycleTimeVariance.Init ( SYSTEM_FRAME_SIZE_SAMPLES, CycleTimeVariance.Init ( SYSTEM_FRAME_SIZE_SAMPLES,
SYSTEM_SAMPLE_RATE, TIME_MOV_AV_RESPONSE ); SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS );
// enable history graph (if requested) // enable history graph (if requested)
if ( !strHistoryFileName.isEmpty() ) if ( !strHistoryFileName.isEmpty() )

View file

@ -27,8 +27,9 @@
#include <qlocale.h> #include <qlocale.h>
#include <qlist.h> #include <qlist.h>
#include <qtimer.h>
#include "global.h" #include "global.h"
#include "util.h"
/* /*
MAIN POINTS: MAIN POINTS:
@ -112,11 +113,35 @@ public:
strCity ( "" ), strCity ( "" ),
iNumClients ( 0 ), iNumClients ( 0 ),
iMaxNumClients ( 0 ), iMaxNumClients ( 0 ),
bPermanentOnline ( false ) {} bPermanentOnline ( false ) { RegisterTime.start(); }
CServerListProperties (
const CHostAddress& NIAddr,
const QString& NsName,
const QString& NsTopic,
const QLocale::Country& NeCountry,
const QString& NsCity,
const int NiNumClients,
const int NiMaxNumClients,
const bool NbPermOnline) :
InetAddr ( NIAddr ),
strName ( NsName ),
strTopic ( NsTopic ),
eCountry ( NeCountry ),
strCity ( NsCity ),
iNumClients ( NiNumClients ),
iMaxNumClients ( NiMaxNumClients ),
bPermanentOnline ( NbPermOnline ) { RegisterTime.start(); }
virtual ~CServerListProperties() {} virtual ~CServerListProperties() {}
protected: public:
// time on which the entry was registered
QTime RegisterTime;
// internet address of the server
CHostAddress InetAddr;
// name of the server // name of the server
QString strName; QString strName;
@ -141,27 +166,20 @@ protected:
}; };
class CServerList : public QList<CServerListProperties>//, public QObject class CServerListManager : public QObject
{ {
// Q_OBJECT Q_OBJECT
public:
CServerList() {}
virtual ~CServerList() {}
protected:
};
class CServerListManager
{
public: public:
CServerListManager() {} CServerListManager() {}
virtual ~CServerListManager() {} virtual ~CServerListManager() {}
protected: protected:
QTimer TimerPollList;
QList<CServerListProperties> ServerList;
public slots:
void OnTimerPollList() { /* TODO */ }
}; };
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */ #endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */

View file

@ -388,24 +388,32 @@ class CHostAddress
{ {
public: public:
CHostAddress() : CHostAddress() :
InetAddr ( (quint32) 0 ), InetAddr ( static_cast<quint32> ( 0 ) ),
iPort ( 0 ) {} iPort ( 0 ) {}
CHostAddress ( const QHostAddress NInetAddr, CHostAddress ( const QHostAddress NInetAddr,
const quint16 iNPort ) : const quint16 iNPort ) :
InetAddr ( NInetAddr ), InetAddr ( NInetAddr ),
iPort ( iNPort ) {} iPort ( iNPort ) {}
CHostAddress ( const CHostAddress& NHAddr ) : CHostAddress ( const CHostAddress& NHAddr ) :
InetAddr ( NHAddr.InetAddr ), InetAddr ( NHAddr.InetAddr ),
iPort ( NHAddr.iPort ) {} iPort ( NHAddr.iPort ) {}
// copy and compare operators // copy operator
CHostAddress& operator= ( const CHostAddress& NHAddr ) CHostAddress& operator= ( const CHostAddress& NHAddr )
{ InetAddr = NHAddr.InetAddr; iPort = NHAddr.iPort; return *this; } {
InetAddr = NHAddr.InetAddr;
iPort = NHAddr.iPort;
return *this;
}
// compare operator
bool operator== ( const CHostAddress& CompAddr ) // compare operator bool operator== ( const CHostAddress& CompAddr ) // compare operator
{ return ( ( CompAddr.InetAddr == InetAddr ) && ( CompAddr.iPort == iPort ) ); } {
return ( ( CompAddr.InetAddr == InetAddr ) &&
( CompAddr.iPort == iPort ) );
}
QString GetIpAddressStringNoLastByte() const QString GetIpAddressStringNoLastByte() const
{ {
@ -425,7 +433,7 @@ public:
iIpAddr ( 0 ), iIpAddr ( 0 ),
strName ( "" ) {} strName ( "" ) {}
CChannelShortInfo ( const int iNID, CChannelShortInfo ( const int iNID,
const quint32 nIP, const quint32 nIP,
const QString nN ) : const QString nN ) :
iChanID ( iNID ), iChanID ( iNID ),
@ -468,13 +476,13 @@ public:
eAudioCodingType ( CT_NONE ), eAudioCodingType ( CT_NONE ),
iAudioCodingArg ( 0 ) {} iAudioCodingArg ( 0 ) {}
CNetworkTransportProps ( const uint32_t iNBNPS, CNetworkTransportProps ( const uint32_t iNBNPS,
const uint16_t iNBSF, const uint16_t iNBSF,
const uint32_t iNNACH, const uint32_t iNNACH,
const uint32_t iNSR, const uint32_t iNSR,
const EAudComprType eNACT, const EAudComprType eNACT,
const uint32_t iNVers, const uint32_t iNVers,
const int32_t iNACA ) : const int32_t iNACA ) :
iBaseNetworkPacketSize ( iNBNPS ), iBaseNetworkPacketSize ( iNBNPS ),
iBlockSizeFact ( iNBSF ), iBlockSizeFact ( iNBSF ),
iNumAudioChannels ( iNNACH ), iNumAudioChannels ( iNNACH ),
@ -581,8 +589,8 @@ public:
dIntervalTime ( 0.0 ), iNewValueBoundFactor ( 0 ) {} dIntervalTime ( 0.0 ), iNewValueBoundFactor ( 0 ) {}
void Init ( const int iNewBlockLengthAtSystemSampleRate, void Init ( const int iNewBlockLengthAtSystemSampleRate,
const int iNewSystemSampleRate, const int iNewSystemSampleRateHz,
const int iHistoryLengthTime, const int iHistoryLengthTimeSec,
const int iNewNewValueBoundFactor = 4 ) const int iNewNewValueBoundFactor = 4 )
{ {
// store block size and new value bound factor // store block size and new value bound factor
@ -591,11 +599,11 @@ public:
// calculate interval time // calculate interval time
dIntervalTime = static_cast<double> ( dIntervalTime = static_cast<double> (
iBlockLengthAtSystemSampleRate ) * 1000 / iNewSystemSampleRate; iBlockLengthAtSystemSampleRate ) * 1000 / iNewSystemSampleRateHz;
// calculate actual moving average length and initialize buffer // calculate actual moving average length and initialize buffer
RespTimeMoAvBuf.Init ( iHistoryLengthTime * RespTimeMoAvBuf.Init ( iHistoryLengthTimeSec *
iNewSystemSampleRate / iNewBlockLengthAtSystemSampleRate ); iNewSystemSampleRateHz / iNewBlockLengthAtSystemSampleRate );
} }
int GetBlockLength() { return iBlockLengthAtSystemSampleRate; } int GetBlockLength() { return iBlockLengthAtSystemSampleRate; }

View file

@ -220,14 +220,14 @@ QString CSound::CheckDeviceCapabilities()
// message is returned. // message is returned.
// check the sample rate // check the sample rate
const ASIOError CanSaRateReturn = ASIOCanSampleRate ( SYSTEM_SAMPLE_RATE ); const ASIOError CanSaRateReturn = ASIOCanSampleRate ( SYSTEM_SAMPLE_RATE_HZ );
if ( ( CanSaRateReturn == ASE_NoClock ) || if ( ( CanSaRateReturn == ASE_NoClock ) ||
( CanSaRateReturn == ASE_NotPresent ) ) ( CanSaRateReturn == ASE_NotPresent ) )
{ {
// return error string // return error string
return tr ( "The audio device does not support the " return tr ( "The audio device does not support the "
"required sample rate. The required sample rate is: " ) + "required sample rate. The required sample rate is: " ) +
QString().setNum ( SYSTEM_SAMPLE_RATE ) + " Hz"; QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + " Hz";
} }
// check the number of available channels // check the number of available channels
@ -467,7 +467,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize )
iASIOBufferSizeStereo = 2 * iASIOBufferSizeMono; iASIOBufferSizeStereo = 2 * iASIOBufferSizeMono;
// set the sample rate // set the sample rate
ASIOSetSampleRate ( SYSTEM_SAMPLE_RATE ); ASIOSetSampleRate ( SYSTEM_SAMPLE_RATE_HZ );
// create memory for intermediate audio buffer // create memory for intermediate audio buffer
vecsTmpAudioSndCrdStereo.Init ( iASIOBufferSizeStereo ); vecsTmpAudioSndCrdStereo.Init ( iASIOBufferSizeStereo );