Merge branch 'master' of https://github.com/sthenos/jamulus
This commit is contained in:
commit
4e721f37a9
2 changed files with 22 additions and 12 deletions
|
@ -97,7 +97,9 @@ CNetBufWithStats::CNetBufWithStats() :
|
||||||
dAutoFilt_WightUpNormal ( IIR_WEIGTH_UP_NORMAL ),
|
dAutoFilt_WightUpNormal ( IIR_WEIGTH_UP_NORMAL ),
|
||||||
dAutoFilt_WightDownNormal ( IIR_WEIGTH_DOWN_NORMAL ),
|
dAutoFilt_WightDownNormal ( IIR_WEIGTH_DOWN_NORMAL ),
|
||||||
dAutoFilt_WightUpFast ( IIR_WEIGTH_UP_FAST ),
|
dAutoFilt_WightUpFast ( IIR_WEIGTH_UP_FAST ),
|
||||||
dAutoFilt_WightDownFast ( IIR_WEIGTH_DOWN_FAST )
|
dAutoFilt_WightDownFast ( IIR_WEIGTH_DOWN_FAST ),
|
||||||
|
dErrorRateBound ( ERROR_RATE_BOUND ),
|
||||||
|
dUpMaxErrorBound ( UP_MAX_ERROR_BOUND )
|
||||||
{
|
{
|
||||||
// Define the sizes of the simulation buffers,
|
// Define the sizes of the simulation buffers,
|
||||||
// must be NUM_STAT_SIMULATION_BUFFERS elements!
|
// must be NUM_STAT_SIMULATION_BUFFERS elements!
|
||||||
|
@ -135,8 +137,8 @@ void CNetBufWithStats::GetErrorRates ( CVector<double>& vecErrRates,
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the limits for the decisions
|
// get the limits for the decisions
|
||||||
dLimit = ERROR_RATE_BOUND;
|
dLimit = dErrorRateBound;
|
||||||
dMaxUpLimit = UP_MAX_ERROR_BOUND;
|
dMaxUpLimit = dUpMaxErrorBound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetBufWithStats::Init ( const int iNewBlockSize,
|
void CNetBufWithStats::Init ( const int iNewBlockSize,
|
||||||
|
@ -157,6 +159,8 @@ void CNetBufWithStats::Init ( const int iNewBlockSize,
|
||||||
dAutoFilt_WightUpFast = IIR_WEIGTH_UP_FAST_DOUBLE_FRAME_SIZE;
|
dAutoFilt_WightUpFast = IIR_WEIGTH_UP_FAST_DOUBLE_FRAME_SIZE;
|
||||||
dAutoFilt_WightDownFast = IIR_WEIGTH_DOWN_FAST_DOUBLE_FRAME_SIZE;
|
dAutoFilt_WightDownFast = IIR_WEIGTH_DOWN_FAST_DOUBLE_FRAME_SIZE;
|
||||||
iMaxStatisticCount = MAX_STATISTIC_COUNT_DOUBLE_FRAME_SIZE;
|
iMaxStatisticCount = MAX_STATISTIC_COUNT_DOUBLE_FRAME_SIZE;
|
||||||
|
dErrorRateBound = ERROR_RATE_BOUND_DOUBLE_FRAME_SIZE;
|
||||||
|
dUpMaxErrorBound = UP_MAX_ERROR_BOUND_DOUBLE_FRAME_SIZE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -165,6 +169,8 @@ void CNetBufWithStats::Init ( const int iNewBlockSize,
|
||||||
dAutoFilt_WightUpFast = IIR_WEIGTH_UP_FAST;
|
dAutoFilt_WightUpFast = IIR_WEIGTH_UP_FAST;
|
||||||
dAutoFilt_WightDownFast = IIR_WEIGTH_DOWN_FAST;
|
dAutoFilt_WightDownFast = IIR_WEIGTH_DOWN_FAST;
|
||||||
iMaxStatisticCount = MAX_STATISTIC_COUNT;
|
iMaxStatisticCount = MAX_STATISTIC_COUNT;
|
||||||
|
dErrorRateBound = ERROR_RATE_BOUND;
|
||||||
|
dUpMaxErrorBound = UP_MAX_ERROR_BOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
|
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
|
||||||
|
@ -248,7 +254,7 @@ void CNetBufWithStats::UpdateAutoSetting()
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ )
|
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ )
|
||||||
{
|
{
|
||||||
if ( ( !bDecisionFound ) &&
|
if ( ( !bDecisionFound ) &&
|
||||||
( ErrorRateStatistic[i].GetAverage() <= ERROR_RATE_BOUND ) )
|
( ErrorRateStatistic[i].GetAverage() <= dErrorRateBound ) )
|
||||||
{
|
{
|
||||||
iCurDecision = viBufSizesForSim[i];
|
iCurDecision = viBufSizesForSim[i];
|
||||||
bDecisionFound = true;
|
bDecisionFound = true;
|
||||||
|
@ -272,7 +278,7 @@ void CNetBufWithStats::UpdateAutoSetting()
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ )
|
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ )
|
||||||
{
|
{
|
||||||
if ( ( !bDecisionFound ) &&
|
if ( ( !bDecisionFound ) &&
|
||||||
( ErrorRateStatistic[i].GetAverage() <= UP_MAX_ERROR_BOUND ) )
|
( ErrorRateStatistic[i].GetAverage() <= dUpMaxErrorBound ) )
|
||||||
{
|
{
|
||||||
iCurMaxUpDecision = viBufSizesForSim[i];
|
iCurMaxUpDecision = viBufSizesForSim[i];
|
||||||
bDecisionFound = true;
|
bDecisionFound = true;
|
||||||
|
@ -369,7 +375,7 @@ else
|
||||||
{
|
{
|
||||||
// check error rate of the largest buffer as the indicator
|
// check error rate of the largest buffer as the indicator
|
||||||
if ( ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].
|
if ( ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].
|
||||||
GetAverage() > ERROR_RATE_BOUND )
|
GetAverage() > dErrorRateBound )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
|
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
|
||||||
{
|
{
|
||||||
|
|
16
src/buffer.h
16
src/buffer.h
|
@ -37,17 +37,23 @@
|
||||||
#define FILTER_DECISION_HYSTERESIS 0.1
|
#define FILTER_DECISION_HYSTERESIS 0.1
|
||||||
|
|
||||||
// definition of the upper error bound of the jitter buffers
|
// definition of the upper error bound of the jitter buffers
|
||||||
#define ERROR_RATE_BOUND 0.001
|
#define ERROR_RATE_BOUND_DOUBLE_FRAME_SIZE 0.001
|
||||||
|
#define ERROR_RATE_BOUND ( ERROR_RATE_BOUND_DOUBLE_FRAME_SIZE / 2 )
|
||||||
|
|
||||||
// definition of the upper jitter buffer error bound, if that one is reached we
|
// definition of the upper jitter buffer error bound, if that one is reached we
|
||||||
// have to speed up the filtering to quickly get out of a incorrect buffer
|
// have to speed up the filtering to quickly get out of a incorrect buffer
|
||||||
// size state
|
// size state
|
||||||
#define UP_MAX_ERROR_BOUND 0.01
|
#define UP_MAX_ERROR_BOUND_DOUBLE_FRAME_SIZE 0.01
|
||||||
|
#define UP_MAX_ERROR_BOUND ( UP_MAX_ERROR_BOUND_DOUBLE_FRAME_SIZE / 2 )
|
||||||
|
|
||||||
// each regular buffer access lead to a count for put and get, assuming 2.66 ms
|
// each regular buffer access lead to a count for put and get, assuming 2.66 ms
|
||||||
// blocks we have 15 s / 2.66 ms * 2 = approx. 11000
|
// blocks we have 15 s / 2.66 ms * 2 = approx. 11000
|
||||||
#define MAX_STATISTIC_COUNT_DOUBLE_FRAME_SIZE 11000
|
#define MAX_STATISTIC_COUNT_DOUBLE_FRAME_SIZE 11000
|
||||||
|
|
||||||
|
// each regular buffer access lead to a count for put and get, assuming 1.33 ms
|
||||||
|
// blocks we have 15 s / 1.33 ms * 2 = approx. 22500
|
||||||
|
#define MAX_STATISTIC_COUNT 22500
|
||||||
|
|
||||||
// Note that the following definitions of the weigh constants assume a block
|
// Note that the following definitions of the weigh constants assume a block
|
||||||
// size of 128 samples at a sampling rate of 48 kHz.
|
// size of 128 samples at a sampling rate of 48 kHz.
|
||||||
#define IIR_WEIGTH_UP_NORMAL_DOUBLE_FRAME_SIZE 0.999995
|
#define IIR_WEIGTH_UP_NORMAL_DOUBLE_FRAME_SIZE 0.999995
|
||||||
|
@ -55,10 +61,6 @@
|
||||||
#define IIR_WEIGTH_UP_FAST_DOUBLE_FRAME_SIZE 0.9995
|
#define IIR_WEIGTH_UP_FAST_DOUBLE_FRAME_SIZE 0.9995
|
||||||
#define IIR_WEIGTH_DOWN_FAST_DOUBLE_FRAME_SIZE 0.999
|
#define IIR_WEIGTH_DOWN_FAST_DOUBLE_FRAME_SIZE 0.999
|
||||||
|
|
||||||
// each regular buffer access lead to a count for put and get, assuming 1.33 ms
|
|
||||||
// blocks we have 15 s / 1.33 ms * 2 = approx. 22500
|
|
||||||
#define MAX_STATISTIC_COUNT 22500
|
|
||||||
|
|
||||||
// convert numbers from 128 samples case using http://www.tsdconseil.fr/tutos/tuto-iir1-en.pdf
|
// convert numbers from 128 samples case using http://www.tsdconseil.fr/tutos/tuto-iir1-en.pdf
|
||||||
// and https://octave-online.net:
|
// and https://octave-online.net:
|
||||||
// gamma = exp(-Ts/tau), after some calculations we get: x=0.999995;exp(64/128*log(x))
|
// gamma = exp(-Ts/tau), after some calculations we get: x=0.999995;exp(64/128*log(x))
|
||||||
|
@ -459,6 +461,8 @@ protected:
|
||||||
double dAutoFilt_WightDownNormal;
|
double dAutoFilt_WightDownNormal;
|
||||||
double dAutoFilt_WightUpFast;
|
double dAutoFilt_WightUpFast;
|
||||||
double dAutoFilt_WightDownFast;
|
double dAutoFilt_WightDownFast;
|
||||||
|
double dErrorRateBound;
|
||||||
|
double dUpMaxErrorBound;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue