mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-19 04:06:17 -04:00
Sanitize output of all effects when exporting
This commit is contained in:
@@ -33,6 +33,8 @@ namespace MixHelpers
|
||||
|
||||
bool isSilent( const sampleFrame* src, int frames );
|
||||
|
||||
bool sanitize( sampleFrame * src, int frames );
|
||||
|
||||
/*! \brief Add samples from src to dst */
|
||||
void add( sampleFrame* dst, const sampleFrame* src, int frames );
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
#include "engine.h"
|
||||
#include "debug.h"
|
||||
#include "DummyEffect.h"
|
||||
|
||||
#include "MixHelpers.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
EffectChain::EffectChain( Model * _parent ) :
|
||||
@@ -194,6 +195,11 @@ 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 );
|
||||
}
|
||||
|
||||
bool moreEffects = false;
|
||||
for( EffectList::Iterator it = m_effects.begin(); it != m_effects.end(); ++it )
|
||||
@@ -201,6 +207,10 @@ 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 );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LMMS_DEBUG
|
||||
|
||||
@@ -69,6 +69,25 @@ bool isSilent( const sampleFrame* src, int frames )
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Function for sanitizing a buffer of infs/nans - returns true if those are found */
|
||||
bool sanitize( sampleFrame * src, int frames )
|
||||
{
|
||||
bool found = false;
|
||||
for( int f = 0; f < frames; ++f )
|
||||
{
|
||||
for( int c = 0; c < 2; ++c )
|
||||
{
|
||||
if( isinff( src[f][c] ) || isnanf( src[f][c] ) )
|
||||
{
|
||||
src[f][c] = 0.0f;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
struct AddOp
|
||||
{
|
||||
void operator()( sampleFrame& dst, const sampleFrame& src ) const
|
||||
|
||||
Reference in New Issue
Block a user