"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/core/MixHelpers.cpp" between
lmms-1.2.0-rc7.tar.gz and lmms-1.2.0-rc8.tar.gz

About: LMMS (Linux MultiMedia Studio) is a sound generation system (creation of melodies and beats, synthesis and mixing of sounds, arranging of samples; full MIDI support). Release candidate.

MixHelpers.cpp  (lmms-1.2.0-rc7):MixHelpers.cpp  (lmms-1.2.0-rc8)
skipping to change at line 29 skipping to change at line 29
* License along with this program (see COPYING); if not, write to the * License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA. * Boston, MA 02110-1301 USA.
* *
*/ */
#include "MixHelpers.h" #include "MixHelpers.h"
#include "lmms_math.h" #include "lmms_math.h"
#include "ValueBuffer.h" #include "ValueBuffer.h"
static bool s_NaNHandler;
namespace MixHelpers namespace MixHelpers
{ {
/*! \brief Function for applying MIXOP on all sample frames */ /*! \brief Function for applying MIXOP on all sample frames */
template<typename MIXOP> template<typename MIXOP>
static inline void run( sampleFrame* dst, const sampleFrame* src, int frames, co nst MIXOP& OP ) static inline void run( sampleFrame* dst, const sampleFrame* src, int frames, co nst MIXOP& OP )
{ {
for( int i = 0; i < frames; ++i ) for( int i = 0; i < frames; ++i )
{ {
OP( dst[i], src[i] ); OP( dst[i], src[i] );
skipping to change at line 68 skipping to change at line 70
{ {
if( fabsf( src[i][0] ) >= silenceThreshold || fabsf( src[i][1] ) >= silenceThreshold ) if( fabsf( src[i][0] ) >= silenceThreshold || fabsf( src[i][1] ) >= silenceThreshold )
{ {
return false; return false;
} }
} }
return true; return true;
} }
bool useNaNHandler()
{
return s_NaNHandler;
}
void setNaNHandler( bool use )
{
s_NaNHandler = use;
}
/*! \brief Function for sanitizing a buffer of infs/nans - returns true if those are found */ /*! \brief Function for sanitizing a buffer of infs/nans - returns true if those are found */
bool sanitize( sampleFrame * src, int frames ) bool sanitize( sampleFrame * src, int frames )
{ {
if( !useNaNHandler() )
{
return false;
}
bool found = false; bool found = false;
for( int f = 0; f < frames; ++f ) for( int f = 0; f < frames; ++f )
{ {
for( int c = 0; c < 2; ++c ) for( int c = 0; c < 2; ++c )
{ {
if( isinff( src[f][c] ) || isnanf( src[f][c] ) ) if( isinff( src[f][c] ) || isnanf( src[f][c] ) )
{ {
src[f][c] = 0.0f; #ifdef LMMS_DEBUG
printf("Bad data, clearing buffer. frame:
");
printf("%d: value %f\n", f, src[f][c]);
#endif
for( int f = 0; f < frames; ++f )
{
for( int c = 0; c < 2; ++c )
{
src[f][c] = 0.0f;
}
}
found = true; found = true;
return found;
} }
else else
{ {
src[f][c] = qBound( -4.0f, src[f][c], 4.0f ); src[f][c] = qBound( -1000.0f, src[f][c], 1000.0f );
} }
} }
} }
return found; return found;
} }
struct AddOp struct AddOp
{ {
void operator()( sampleFrame& dst, const sampleFrame& src ) const void operator()( sampleFrame& dst, const sampleFrame& src ) const
{ {
skipping to change at line 161 skipping to change at line 189
for( int f = 0; f < frames; ++f ) for( int f = 0; f < frames; ++f )
{ {
dst[f][0] += src[f][0] * coeffSrcBuf1->values()[f] * coeffSrcBuf2 ->values()[f]; dst[f][0] += src[f][0] * coeffSrcBuf1->values()[f] * coeffSrcBuf2 ->values()[f];
dst[f][1] += src[f][1] * coeffSrcBuf1->values()[f] * coeffSrcBuf2 ->values()[f]; dst[f][1] += src[f][1] * coeffSrcBuf1->values()[f] * coeffSrcBuf2 ->values()[f];
} }
} }
void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, f loat coeffSrc, ValueBuffer * coeffSrcBuf, int frames ) void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, f loat coeffSrc, ValueBuffer * coeffSrcBuf, int frames )
{ {
if ( !useNaNHandler() )
{
addMultipliedByBuffer( dst, src, coeffSrc, coeffSrcBuf,
frames );
return;
}
for( int f = 0; f < frames; ++f ) for( int f = 0; f < frames; ++f )
{ {
dst[f][0] += ( isinff( src[f][0] ) || isnanf( src[f][0] ) ) ? 0.0 f : src[f][0] * coeffSrc * coeffSrcBuf->values()[f]; dst[f][0] += ( isinff( src[f][0] ) || isnanf( src[f][0] ) ) ? 0.0 f : src[f][0] * coeffSrc * coeffSrcBuf->values()[f];
dst[f][1] += ( isinff( src[f][1] ) || isnanf( src[f][1] ) ) ? 0.0 f : src[f][1] * coeffSrc * coeffSrcBuf->values()[f]; dst[f][1] += ( isinff( src[f][1] ) || isnanf( src[f][1] ) ) ? 0.0 f : src[f][1] * coeffSrc * coeffSrcBuf->values()[f];
} }
} }
void addSanitizedMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames ) void addSanitizedMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames )
{ {
if ( !useNaNHandler() )
{
addMultipliedByBuffers( dst, src, coeffSrcBuf1, coeffSrcBuf2,
frames );
return;
}
for( int f = 0; f < frames; ++f ) for( int f = 0; f < frames; ++f )
{ {
dst[f][0] += ( isinff( src[f][0] ) || isnanf( src[f][0] ) ) dst[f][0] += ( isinff( src[f][0] ) || isnanf( src[f][0] ) )
? 0.0f ? 0.0f
: src[f][0] * coeffSrcBuf1->values()[f] * coeffSrcBuf2->v alues()[f]; : src[f][0] * coeffSrcBuf1->values()[f] * coeffSrcBuf2->v alues()[f];
dst[f][1] += ( isinff( src[f][1] ) || isnanf( src[f][1] ) ) dst[f][1] += ( isinff( src[f][1] ) || isnanf( src[f][1] ) )
? 0.0f ? 0.0f
: src[f][1] * coeffSrcBuf1->values()[f] * coeffSrcBuf2->v alues()[f]; : src[f][1] * coeffSrcBuf1->values()[f] * coeffSrcBuf2->v alues()[f];
} }
skipping to change at line 197 skipping to change at line 239
{ {
dst[0] += ( isinff( src[0] ) || isnanf( src[0] ) ) ? 0.0f : src[0 ] * m_coeff; dst[0] += ( isinff( src[0] ) || isnanf( src[0] ) ) ? 0.0f : src[0 ] * m_coeff;
dst[1] += ( isinff( src[1] ) || isnanf( src[1] ) ) ? 0.0f : src[1 ] * m_coeff; dst[1] += ( isinff( src[1] ) || isnanf( src[1] ) ) ? 0.0f : src[1 ] * m_coeff;
} }
const float m_coeff; const float m_coeff;
}; };
void addSanitizedMultiplied( sampleFrame* dst, const sampleFrame* src, float coe ffSrc, int frames ) void addSanitizedMultiplied( sampleFrame* dst, const sampleFrame* src, float coe ffSrc, int frames )
{ {
if ( !useNaNHandler() )
{
addMultiplied( dst, src, coeffSrc, frames );
return;
}
run<>( dst, src, frames, AddSanitizedMultipliedOp(coeffSrc) ); run<>( dst, src, frames, AddSanitizedMultipliedOp(coeffSrc) );
} }
struct AddMultipliedStereoOp struct AddMultipliedStereoOp
{ {
AddMultipliedStereoOp( float coeffLeft, float coeffRight ) AddMultipliedStereoOp( float coeffLeft, float coeffRight )
{ {
m_coeffs[0] = coeffLeft; m_coeffs[0] = coeffLeft;
m_coeffs[1] = coeffRight; m_coeffs[1] = coeffRight;
} }
 End of changes. 9 change blocks. 
2 lines changed or deleted 51 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)