some cleanup with the level meter signal processing

This commit is contained in:
Volker Fischer 2020-06-24 17:54:35 +02:00
parent 286465cb53
commit d60b538ce6
5 changed files with 25 additions and 45 deletions

View file

@ -117,8 +117,8 @@ public:
bool IsRunning() { return Sound.IsRunning(); }
bool SetServerAddr ( QString strNAddr );
double MicLeveldB_L() { return SignalLevelMeter.MicLeveldBLeft(); }
double MicLeveldB_R() { return SignalLevelMeter.MicLeveldBRight(); }
double GetLevelForMeterdBLeft() { return SignalLevelMeter.GetLevelForMeterdBLeft(); }
double GetLevelForMeterdBRight() { return SignalLevelMeter.GetLevelForMeterdBRight(); }
bool GetAndResetbJitterBufferOKFlag();

View file

@ -965,29 +965,9 @@ void CClientDlg::OnLocalMuteStateChanged ( int value )
void CClientDlg::OnTimerSigMet()
{
// get current input levels
double dCurSigLeveldB_L = pClient->MicLeveldB_L();
double dCurSigLeveldB_R = pClient->MicLeveldB_R();
// linear transformation of the input level range to the progress-bar range
dCurSigLeveldB_L -= LOW_BOUND_SIG_METER;
dCurSigLeveldB_L *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
dCurSigLeveldB_R -= LOW_BOUND_SIG_METER;
dCurSigLeveldB_R *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
// lower bound the signal
if ( dCurSigLeveldB_L < 0 )
{
dCurSigLeveldB_L = 0;
}
if ( dCurSigLeveldB_R < 0 )
{
dCurSigLeveldB_R = 0;
}
// show current level
lbrInputLevelL->SetValue ( dCurSigLeveldB_L );
lbrInputLevelR->SetValue ( dCurSigLeveldB_R );
lbrInputLevelL->SetValue ( pClient->GetLevelForMeterdBLeft() );
lbrInputLevelR->SetValue ( pClient->GetLevelForMeterdBRight() );
}
void CClientDlg::OnTimerBuffersLED()

View file

@ -1711,18 +1711,9 @@ bool CServer::CreateLevelsForAllConChannels ( const int i
vecChannels[iChId].SetPrevLevel ( dCurLevel );
// logarithmic measure
double dCurSigLevel = CStereoSignalLevelMeter::CalcLogResult ( dCurLevel );
double dCurSigLevelForMeterdB = CStereoSignalLevelMeter::CalcLogResultForMeter ( dCurLevel );
// map to signal level meter
dCurSigLevel -= LOW_BOUND_SIG_METER;
dCurSigLevel *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
if ( dCurSigLevel < 0 )
{
dCurSigLevel = 0;
}
vecLevelsOut[j] = static_cast<uint16_t> ( ceil ( dCurSigLevel ) );
vecLevelsOut[j] = static_cast<uint16_t> ( ceil ( dCurSigLevelForMeterdB ) );
}
}

View file

@ -43,7 +43,6 @@ void CStereoSignalLevelMeter::Update ( const CVector<short>& vecsAudio )
// With these speed optimizations we might loose some information in
// special cases but for the average music signals the following code
// should give good results.
//
short sMaxL = 0;
short sMaxR = 0;
@ -87,19 +86,29 @@ double CStereoSignalLevelMeter::UpdateCurLevel ( double dCurLevel,
}
}
double CStereoSignalLevelMeter::CalcLogResult ( const double& dLinearLevel )
double CStereoSignalLevelMeter::CalcLogResultForMeter ( const double& dLinearLevel )
{
const double dNormMicLevel = dLinearLevel / _MAXSHORT;
const double dNormLevel = dLinearLevel / _MAXSHORT;
// logarithmic measure
if ( dNormMicLevel > 0 )
double dLevelForMeterdB = -100000.0; // large negative value
if ( dNormLevel > 0 )
{
return 20.0 * log10 ( dNormMicLevel );
dLevelForMeterdB = 20.0 * log10 ( dNormLevel );
}
else
// map to signal level meter (linear transformation of the input
// level range to the level meter range)
dLevelForMeterdB -= LOW_BOUND_SIG_METER;
dLevelForMeterdB *= NUM_STEPS_LED_BAR / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
if ( dLevelForMeterdB < 0 )
{
return -100000.0; // large negative value
dLevelForMeterdB = 0;
}
return dLevelForMeterdB;
}

View file

@ -715,9 +715,9 @@ public:
CStereoSignalLevelMeter() { Reset(); }
void Update ( const CVector<short>& vecsAudio );
double MicLeveldBLeft() { return CalcLogResult ( dCurLevelL ); }
double MicLeveldBRight() { return CalcLogResult ( dCurLevelR ); }
static double CalcLogResult ( const double& dLinearLevel );
double GetLevelForMeterdBLeft() { return CalcLogResultForMeter ( dCurLevelL ); }
double GetLevelForMeterdBRight() { return CalcLogResultForMeter ( dCurLevelR ); }
static double CalcLogResultForMeter ( const double& dLinearLevel );
void Reset()
{