Allways remove infs/nans (#3706)
When exporting a project lmms performs extra tests for bad data. The tests are for infs and nans. Switching these tests on for all occasions as the extra performance hit would be in the order of only ~2% and the problems, when it hits the end user, are hard to debug and/or work around. After testing for inf/nan we clamp the sound to +/-4.0f as sometimes you will get large transients passing through (an issue that is currently only present when exporting). Fixes: #1048
This commit is contained in:
@@ -202,11 +202,8 @@ bool EffectChain::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames, b
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const bool exporting = Engine::getSong()->isExporting();
|
||||
if( exporting ) // strip infs/nans if exporting
|
||||
{
|
||||
MixHelpers::sanitize( _buf, _frames );
|
||||
}
|
||||
|
||||
MixHelpers::sanitize( _buf, _frames );
|
||||
|
||||
bool moreEffects = false;
|
||||
for( EffectList::Iterator it = m_effects.begin(); it != m_effects.end(); ++it )
|
||||
@@ -214,10 +211,7 @@ bool EffectChain::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames, b
|
||||
if( hasInputNoise || ( *it )->isRunning() )
|
||||
{
|
||||
moreEffects |= ( *it )->processAudioBuffer( _buf, _frames );
|
||||
if( exporting ) // strip infs/nans if exporting
|
||||
{
|
||||
MixHelpers::sanitize( _buf, _frames );
|
||||
}
|
||||
MixHelpers::sanitize( _buf, _frames );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,6 @@ void FxChannel::unmuteForSolo()
|
||||
void FxChannel::doProcessing()
|
||||
{
|
||||
const fpp_t fpp = Engine::mixer()->framesPerPeriod();
|
||||
const bool exporting = Engine::getSong()->isExporting();
|
||||
|
||||
if( m_muted == false )
|
||||
{
|
||||
@@ -140,25 +139,21 @@ void FxChannel::doProcessing()
|
||||
if( ! volBuf && ! sendBuf ) // neither volume nor send has sample-exact data...
|
||||
{
|
||||
const float v = sender->m_volumeModel.value() * sendModel->value();
|
||||
if( exporting ) { MixHelpers::addSanitizedMultiplied( m_buffer, ch_buf, v, fpp ); }
|
||||
else { MixHelpers::addMultiplied( m_buffer, ch_buf, v, fpp ); }
|
||||
MixHelpers::addSanitizedMultiplied( m_buffer, ch_buf, v, fpp );
|
||||
}
|
||||
else if( volBuf && sendBuf ) // both volume and send have sample-exact data
|
||||
{
|
||||
if( exporting ) { MixHelpers::addSanitizedMultipliedByBuffers( m_buffer, ch_buf, volBuf, sendBuf, fpp ); }
|
||||
else { MixHelpers::addMultipliedByBuffers( m_buffer, ch_buf, volBuf, sendBuf, fpp ); }
|
||||
MixHelpers::addSanitizedMultipliedByBuffers( m_buffer, ch_buf, volBuf, sendBuf, fpp );
|
||||
}
|
||||
else if( volBuf ) // volume has sample-exact data but send does not
|
||||
{
|
||||
const float v = sendModel->value();
|
||||
if( exporting ) { MixHelpers::addSanitizedMultipliedByBuffer( m_buffer, ch_buf, v, volBuf, fpp ); }
|
||||
else { MixHelpers::addMultipliedByBuffer( m_buffer, ch_buf, v, volBuf, fpp ); }
|
||||
MixHelpers::addSanitizedMultipliedByBuffer( m_buffer, ch_buf, v, volBuf, fpp );
|
||||
}
|
||||
else // vice versa
|
||||
{
|
||||
const float v = sender->m_volumeModel.value();
|
||||
if( exporting ) { MixHelpers::addSanitizedMultipliedByBuffer( m_buffer, ch_buf, v, sendBuf, fpp ); }
|
||||
else { MixHelpers::addMultipliedByBuffer( m_buffer, ch_buf, v, sendBuf, fpp ); }
|
||||
MixHelpers::addSanitizedMultipliedByBuffer( m_buffer, ch_buf, v, sendBuf, fpp );
|
||||
}
|
||||
m_hasInput = true;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,10 @@ bool sanitize( sampleFrame * src, int frames )
|
||||
src[f][c] = 0.0f;
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
src[f][c] = qBound( -4.0f, src[f][c], 4.0f );
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
|
||||
Reference in New Issue
Block a user