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

View file

@ -29,7 +29,7 @@
/* Input level meter implementation ------------------------------------------ */
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 ();
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 */
/* decrease max with time */
if ( dCurLevel >= METER_FLY_BACK )
dCurLevel -= METER_FLY_BACK;
{
dCurLevel *= 0.9999;
}
else
{
if ((dCurLevel <= METER_FLY_BACK) && (dCurLevel > 1.0))
dCurLevel -= 2.0;
dCurLevel = 0;
}
/* search for max */
if ( dCurSig > dCurLevel )
{
dCurLevel = dCurSig;
}
}
}
double CSignalLevelMeter::MicLevel ()
{
@ -59,10 +62,14 @@ double CSignalLevelMeter::MicLevel()
/* logarithmic measure */
if ( dNormMicLevel > 0 )
{
return 20.0 * log10 ( dNormMicLevel );
}
else
{
return -100000.0; /* large negative value */
}
}
/* Global functions implementation ********************************************/