FxMixer, FxMixerView: cache maximum peak until next display update

We lost short peaks because the display update rate usually is much lower
than the number of audio buffers processed per second which lead to lost
peaks. We mitigate this issue by caching the maximum peak value until the
next display update where it is reset.
This commit is contained in:
Tobias Doerffel
2014-01-17 19:35:14 +01:00
parent dc1f9c6050
commit 4b5b0fa4fa
2 changed files with 16 additions and 8 deletions

View File

@@ -123,10 +123,17 @@ void FxMixer::processChannel( fx_ch_t _ch, sampleFrame * _buf )
{
m_fxChannels[_ch]->m_fxChain.startRunning();
m_fxChannels[_ch]->m_stillRunning = m_fxChannels[_ch]->m_fxChain.processAudioBuffer( _buf, f );
m_fxChannels[_ch]->m_peakLeft = engine::mixer()->peakValueLeft( _buf, f ) *
m_fxChannels[_ch]->m_volumeModel.value();
m_fxChannels[_ch]->m_peakRight = engine::mixer()->peakValueRight( _buf, f ) *
m_fxChannels[_ch]->m_volumeModel.value();
float peakLeft = engine::mixer()->peakValueLeft( _buf, f ) * m_fxChannels[_ch]->m_volumeModel.value();
float peakRight = engine::mixer()->peakValueRight( _buf, f ) * m_fxChannels[_ch]->m_volumeModel.value();
if( peakLeft > m_fxChannels[_ch]->m_peakLeft )
{
m_fxChannels[_ch]->m_peakLeft = peakLeft;
}
if( peakRight > m_fxChannels[_ch]->m_peakRight )
{
m_fxChannels[_ch]->m_peakRight = peakRight;
}
}
m_fxChannels[_ch]->m_used = true;
}

View File

@@ -340,17 +340,18 @@ void FxMixerView::updateFaders()
const float fall_off = 1.2;
if( m->m_fxChannels[i]->m_peakLeft > opl )
{
m_fxChannelViews[i].m_fader->setPeak_L(
m->m_fxChannels[i]->m_peakLeft );
m_fxChannelViews[i].m_fader->setPeak_L( m->m_fxChannels[i]->m_peakLeft );
m->m_fxChannels[i]->m_peakLeft = 0;
}
else
{
m_fxChannelViews[i].m_fader->setPeak_L( opl/fall_off );
}
if( m->m_fxChannels[i]->m_peakRight > opr )
{
m_fxChannelViews[i].m_fader->setPeak_R(
m->m_fxChannels[i]->m_peakRight );
m_fxChannelViews[i].m_fader->setPeak_R( m->m_fxChannels[i]->m_peakRight );
m->m_fxChannels[i]->m_peakRight = 0;
}
else
{