some cleanup with the level meter signal processing
This commit is contained in:
parent
286465cb53
commit
d60b538ce6
5 changed files with 25 additions and 45 deletions
|
@ -117,8 +117,8 @@ public:
|
||||||
bool IsRunning() { return Sound.IsRunning(); }
|
bool IsRunning() { return Sound.IsRunning(); }
|
||||||
bool SetServerAddr ( QString strNAddr );
|
bool SetServerAddr ( QString strNAddr );
|
||||||
|
|
||||||
double MicLeveldB_L() { return SignalLevelMeter.MicLeveldBLeft(); }
|
double GetLevelForMeterdBLeft() { return SignalLevelMeter.GetLevelForMeterdBLeft(); }
|
||||||
double MicLeveldB_R() { return SignalLevelMeter.MicLeveldBRight(); }
|
double GetLevelForMeterdBRight() { return SignalLevelMeter.GetLevelForMeterdBRight(); }
|
||||||
|
|
||||||
bool GetAndResetbJitterBufferOKFlag();
|
bool GetAndResetbJitterBufferOKFlag();
|
||||||
|
|
||||||
|
|
|
@ -965,29 +965,9 @@ void CClientDlg::OnLocalMuteStateChanged ( int value )
|
||||||
|
|
||||||
void CClientDlg::OnTimerSigMet()
|
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
|
// show current level
|
||||||
lbrInputLevelL->SetValue ( dCurSigLeveldB_L );
|
lbrInputLevelL->SetValue ( pClient->GetLevelForMeterdBLeft() );
|
||||||
lbrInputLevelR->SetValue ( dCurSigLeveldB_R );
|
lbrInputLevelR->SetValue ( pClient->GetLevelForMeterdBRight() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientDlg::OnTimerBuffersLED()
|
void CClientDlg::OnTimerBuffersLED()
|
||||||
|
|
|
@ -1711,18 +1711,9 @@ bool CServer::CreateLevelsForAllConChannels ( const int i
|
||||||
vecChannels[iChId].SetPrevLevel ( dCurLevel );
|
vecChannels[iChId].SetPrevLevel ( dCurLevel );
|
||||||
|
|
||||||
// logarithmic measure
|
// logarithmic measure
|
||||||
double dCurSigLevel = CStereoSignalLevelMeter::CalcLogResult ( dCurLevel );
|
double dCurSigLevelForMeterdB = CStereoSignalLevelMeter::CalcLogResultForMeter ( dCurLevel );
|
||||||
|
|
||||||
// map to signal level meter
|
vecLevelsOut[j] = static_cast<uint16_t> ( ceil ( dCurSigLevelForMeterdB ) );
|
||||||
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 ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
src/util.cpp
23
src/util.cpp
|
@ -43,7 +43,6 @@ void CStereoSignalLevelMeter::Update ( const CVector<short>& vecsAudio )
|
||||||
// With these speed optimizations we might loose some information in
|
// With these speed optimizations we might loose some information in
|
||||||
// special cases but for the average music signals the following code
|
// special cases but for the average music signals the following code
|
||||||
// should give good results.
|
// should give good results.
|
||||||
//
|
|
||||||
short sMaxL = 0;
|
short sMaxL = 0;
|
||||||
short sMaxR = 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
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -715,9 +715,9 @@ public:
|
||||||
CStereoSignalLevelMeter() { Reset(); }
|
CStereoSignalLevelMeter() { Reset(); }
|
||||||
|
|
||||||
void Update ( const CVector<short>& vecsAudio );
|
void Update ( const CVector<short>& vecsAudio );
|
||||||
double MicLeveldBLeft() { return CalcLogResult ( dCurLevelL ); }
|
double GetLevelForMeterdBLeft() { return CalcLogResultForMeter ( dCurLevelL ); }
|
||||||
double MicLeveldBRight() { return CalcLogResult ( dCurLevelR ); }
|
double GetLevelForMeterdBRight() { return CalcLogResultForMeter ( dCurLevelR ); }
|
||||||
static double CalcLogResult ( const double& dLinearLevel );
|
static double CalcLogResultForMeter ( const double& dLinearLevel );
|
||||||
|
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue