MixHelpers: added isSilent()
A simple function for testing whether a given sample buffer is silent. Maybe we have to adjust/lower the threshold.
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
namespace MixHelpers
|
||||
{
|
||||
|
||||
bool isSilent( const sampleFrame* src, int frames );
|
||||
|
||||
/*! \brief Add samples from src to dst */
|
||||
void add( sampleFrame* dst, const sampleFrame* src, int frames );
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "MixHelpers.h"
|
||||
|
||||
|
||||
@@ -51,6 +53,22 @@ static inline void run( sampleFrame* dst, const sample_t* srcLeft, const sample_
|
||||
|
||||
|
||||
|
||||
bool isSilent( const sampleFrame* src, int frames )
|
||||
{
|
||||
const float silenceThreshold = 0.0000001f;
|
||||
|
||||
for( int i = 0; i < frames; ++i )
|
||||
{
|
||||
if( fabsf( src[i][0] ) >= silenceThreshold || fabsf( src[i][1] ) >= silenceThreshold )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
struct AddOp
|
||||
{
|
||||
void operator()( sampleFrame& dst, const sampleFrame& src ) const
|
||||
|
||||
Reference in New Issue
Block a user