bug fix for level meter

This commit is contained in:
Volker Fischer 2006-02-18 17:03:24 +00:00
parent cfc9255ef8
commit 824bc8ab5d
2 changed files with 53 additions and 29 deletions

View file

@ -255,10 +255,23 @@ void CLlconClientDlg::OnTimerSigMet()
dCurSigLevelL -= LOW_BOUND_SIG_METER; dCurSigLevelL -= LOW_BOUND_SIG_METER;
dCurSigLevelL *= NUM_STEPS_INP_LEV_METER / dCurSigLevelL *= NUM_STEPS_INP_LEV_METER /
( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
// lower bound the signal
if ( dCurSigLevelL < 0 )
{
dCurSigLevelL = 0;
}
dCurSigLevelR -= LOW_BOUND_SIG_METER; dCurSigLevelR -= LOW_BOUND_SIG_METER;
dCurSigLevelR *= NUM_STEPS_INP_LEV_METER / dCurSigLevelR *= NUM_STEPS_INP_LEV_METER /
( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER );
// lower bound the signal
if ( dCurSigLevelR < 0 )
{
dCurSigLevelR = 0;
}
/* show current level */ /* show current level */
ProgressBarInputLevelL->setProgress ( (int) ceil ( dCurSigLevelL ) ); ProgressBarInputLevelL->setProgress ( (int) ceil ( dCurSigLevelL ) );
ProgressBarInputLevelR->setProgress ( (int) ceil ( dCurSigLevelR ) ); ProgressBarInputLevelR->setProgress ( (int) ceil ( dCurSigLevelR ) );
@ -268,9 +281,13 @@ void CLlconClientDlg::OnTimerStatus()
{ {
/* show connection status in status bar */ /* show connection status in status bar */
if ( pClient->IsConnected () && pClient->IsRunning () ) if ( pClient->IsConnected () && pClient->IsRunning () )
{
TextLabelStatus->setText ( tr ( "connected" ) ); TextLabelStatus->setText ( tr ( "connected" ) );
}
else else
{
TextLabelStatus->setText ( tr ( "disconnected" ) ); TextLabelStatus->setText ( tr ( "disconnected" ) );
}
/* update sample rate offset label */ /* update sample rate offset label */
QString strSamRaOffs; QString strSamRaOffs;

View file

@ -29,7 +29,7 @@
/* Input level meter implementation ------------------------------------------ */ /* Input level meter implementation ------------------------------------------ */
void CSignalLevelMeter::Update ( CVector<double>& vecdAudio ) void CSignalLevelMeter::Update ( CVector<double>& vecdAudio )
{ {
/* Do the update for entire vector, convert to floating-point */ /* Do the update for entire vector */
const int iVecSize = vecdAudio.Size (); const int iVecSize = vecdAudio.Size ();
for ( int i = 0; i < iVecSize; i++ ) for ( int i = 0; i < iVecSize; i++ )
@ -40,18 +40,21 @@ void CSignalLevelMeter::Update(CVector<double>& vecdAudio)
/* search for maximum. Decrease this max with time */ /* search for maximum. Decrease this max with time */
/* decrease max with time */ /* decrease max with time */
if ( dCurLevel >= METER_FLY_BACK ) if ( dCurLevel >= METER_FLY_BACK )
dCurLevel -= METER_FLY_BACK; {
dCurLevel *= 0.9999;
}
else else
{ {
if ((dCurLevel <= METER_FLY_BACK) && (dCurLevel > 1.0)) dCurLevel = 0;
dCurLevel -= 2.0;
} }
/* search for max */ /* search for max */
if ( dCurSig > dCurLevel ) if ( dCurSig > dCurLevel )
{
dCurLevel = dCurSig; dCurLevel = dCurSig;
} }
} }
}
double CSignalLevelMeter::MicLevel () double CSignalLevelMeter::MicLevel ()
{ {
@ -59,10 +62,14 @@ double CSignalLevelMeter::MicLevel()
/* logarithmic measure */ /* logarithmic measure */
if ( dNormMicLevel > 0 ) if ( dNormMicLevel > 0 )
{
return 20.0 * log10 ( dNormMicLevel ); return 20.0 * log10 ( dNormMicLevel );
}
else else
{
return -100000.0; /* large negative value */ return -100000.0; /* large negative value */
} }
}
/* Global functions implementation ********************************************/ /* Global functions implementation ********************************************/