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

@ -244,33 +244,50 @@ void CLlconClientDlg::OnSliderNetBuf(int value)
TextNetBuf->setText("Size: " + QString().setNum(value));
}
void CLlconClientDlg::OnTimerSigMet()
void CLlconClientDlg::OnTimerSigMet ()
{
/* get current input levels */
double dCurSigLevelL = pClient->MicLevelL();
double dCurSigLevelR = pClient->MicLevelR();
double dCurSigLevelL = pClient->MicLevelL ();
double dCurSigLevelR = pClient->MicLevelR ();
/* linear transformation of the input level range to the progress-bar
range */
dCurSigLevelL -= LOW_BOUND_SIG_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 *= 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 */
ProgressBarInputLevelL->setProgress((int) ceil(dCurSigLevelL));
ProgressBarInputLevelR->setProgress((int) ceil(dCurSigLevelR));
ProgressBarInputLevelL->setProgress ( (int) ceil ( dCurSigLevelL ) );
ProgressBarInputLevelR->setProgress ( (int) ceil ( dCurSigLevelR ) );
}
void CLlconClientDlg::OnTimerStatus()
void CLlconClientDlg::OnTimerStatus ()
{
/* show connection status in status bar */
if (pClient->IsConnected() && pClient->IsRunning())
TextLabelStatus->setText(tr("connected"));
else
TextLabelStatus->setText(tr("disconnected"));
if ( pClient->IsConnected () && pClient->IsRunning () )
{
TextLabelStatus->setText ( tr ( "connected" ) );
}
else
{
TextLabelStatus->setText ( tr ( "disconnected" ) );
}
/* update sample rate offset label */
QString strSamRaOffs;

View File

@ -27,41 +27,48 @@
/* 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 */
const int iVecSize = vecdAudio.Size();
/* Do the update for entire vector */
const int iVecSize = vecdAudio.Size ();
for (int i = 0; i < iVecSize; i++)
for ( int i = 0; i < iVecSize; i++ )
{
/* norm of current audio sample */
const double dCurSig = fabs(vecdAudio[i]);
const double dCurSig = fabs ( vecdAudio[i] );
/* search for maximum. Decrease this max with time */
/* decrease max with time */
if (dCurLevel >= METER_FLY_BACK)
dCurLevel -= METER_FLY_BACK;
else
if ( dCurLevel >= METER_FLY_BACK )
{
if ((dCurLevel <= METER_FLY_BACK) && (dCurLevel > 1.0))
dCurLevel -= 2.0;
dCurLevel *= 0.9999;
}
else
{
dCurLevel = 0;
}
/* search for max */
if (dCurSig > dCurLevel)
dCurLevel = dCurSig;
if ( dCurSig > dCurLevel )
{
dCurLevel = dCurSig;
}
}
}
double CSignalLevelMeter::MicLevel()
double CSignalLevelMeter::MicLevel ()
{
const double dNormMicLevel = dCurLevel / _MAXSHORT;
/* logarithmic measure */
if (dNormMicLevel > 0)
return 20.0 * log10(dNormMicLevel);
else
return -100000.0; /* large negative value */
if ( dNormMicLevel > 0 )
{
return 20.0 * log10 ( dNormMicLevel );
}
else
{
return -100000.0; /* large negative value */
}
}