From de3b344edd4ebb7021b589869e8eaff69a8840d1 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Sun, 26 Mar 2017 12:32:12 +0200 Subject: [PATCH] lmms_math: C++11 updates --- include/lmms_math.h | 27 ++++--------------- plugins/MultitapEcho/MultitapEchoControls.cpp | 2 +- plugins/monstro/Monstro.cpp | 4 +-- src/core/MixHelpers.cpp | 14 +++++----- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/include/lmms_math.h b/include/lmms_math.h index b1b01be277..422cbd69d5 100644 --- a/include/lmms_math.h +++ b/include/lmms_math.h @@ -26,7 +26,7 @@ #ifndef LMMS_MATH_H #define LMMS_MATH_H -#include +#include #include "lmms_constants.h" #include "lmmsconfig.h" #include @@ -34,25 +34,8 @@ #include using namespace std; -#if defined (LMMS_BUILD_WIN32) || defined (LMMS_BUILD_APPLE) || defined(LMMS_BUILD_HAIKU) || defined (__FreeBSD__) || defined(__OpenBSD__) -#ifndef isnanf -#define isnanf(x) isnan(x) -#endif -#ifndef isinff -#define isinff(x) isinf(x) -#endif -#ifndef _isnanf -#define _isnanf(x) isnan(x) -#endif -#ifndef _isinff -#define _isinff(x) isinf(x) -#endif #ifndef exp10 -#define exp10(x) pow( 10.0, x ) -#endif -#ifndef exp10f -#define exp10f(x) powf( 10.0f, x ) -#endif +#define exp10(x) std::pow( 10.0, x ) #endif #ifdef __INTEL_COMPILER @@ -259,9 +242,9 @@ static inline float safeAmpToDbfs( float amp ) //! @return Linear amplitude static inline float safeDbfsToAmp( float dbfs ) { - return isinff( dbfs ) + return isinf( dbfs ) ? 0.0f - : exp10f( dbfs * 0.05f ); + : exp10( dbfs * 0.05f ); } @@ -279,7 +262,7 @@ static inline float ampToDbfs( float amp ) //! @return Linear amplitude static inline float dbfsToAmp( float dbfs ) { - return exp10f( dbfs * 0.05f ); + return exp10( dbfs * 0.05f ); } diff --git a/plugins/MultitapEcho/MultitapEchoControls.cpp b/plugins/MultitapEcho/MultitapEchoControls.cpp index 0c09f917ba..09c45228d7 100644 --- a/plugins/MultitapEcho/MultitapEchoControls.cpp +++ b/plugins/MultitapEcho/MultitapEchoControls.cpp @@ -148,7 +148,7 @@ void MultitapEchoControls::lpSamplesChanged( int begin, int end ) const float * samples = m_lpGraph.samples(); for( int i = begin; i <= end; ++i ) { - m_effect->m_lpFreq[i] = 20.0f * exp10f( samples[i] ); + m_effect->m_lpFreq[i] = 20.0f * exp10( samples[i] ); } m_effect->updateFilters( begin, end ); } diff --git a/plugins/monstro/Monstro.cpp b/plugins/monstro/Monstro.cpp index 99a3be95b5..75825c1d6a 100644 --- a/plugins/monstro/Monstro.cpp +++ b/plugins/monstro/Monstro.cpp @@ -1433,14 +1433,14 @@ void MonstroInstrument::updateSamplerate() void MonstroInstrument::updateSlope1() { const float slope = m_env1Slope.value(); - m_slope[0] = exp10f( slope * -1.0f ); + m_slope[0] = exp10( slope * -1.0f ); } void MonstroInstrument::updateSlope2() { const float slope = m_env2Slope.value(); - m_slope[1] = exp10f( slope * -1.0f ); + m_slope[1] = exp10( slope * -1.0f ); } diff --git a/src/core/MixHelpers.cpp b/src/core/MixHelpers.cpp index 001aa05cca..fac61649c7 100644 --- a/src/core/MixHelpers.cpp +++ b/src/core/MixHelpers.cpp @@ -77,7 +77,7 @@ bool sanitize( sampleFrame * src, int frames ) { for( int c = 0; c < 2; ++c ) { - if( isinff( src[f][c] ) || isnanf( src[f][c] ) ) + if( isinf( src[f][c] ) || isnan( src[f][c] ) ) { src[f][c] = 0.0f; found = true; @@ -166,8 +166,8 @@ void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, f { for( int f = 0; f < frames; ++f ) { - dst[f][0] += ( isinff( src[f][0] ) || isnanf( src[f][0] ) ) ? 0.0f : src[f][0] * coeffSrc * coeffSrcBuf->values()[f]; - dst[f][1] += ( isinff( src[f][1] ) || isnanf( src[f][1] ) ) ? 0.0f : src[f][1] * coeffSrc * coeffSrcBuf->values()[f]; + dst[f][0] += ( isinf( src[f][0] ) || isnan( src[f][0] ) ) ? 0.0f : src[f][0] * coeffSrc * coeffSrcBuf->values()[f]; + dst[f][1] += ( isinf( src[f][1] ) || isnan( src[f][1] ) ) ? 0.0f : src[f][1] * coeffSrc * coeffSrcBuf->values()[f]; } } @@ -175,10 +175,10 @@ void addSanitizedMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, { for( int f = 0; f < frames; ++f ) { - dst[f][0] += ( isinff( src[f][0] ) || isnanf( src[f][0] ) ) + dst[f][0] += ( isinf( src[f][0] ) || isnan( src[f][0] ) ) ? 0.0f : src[f][0] * coeffSrcBuf1->values()[f] * coeffSrcBuf2->values()[f]; - dst[f][1] += ( isinff( src[f][1] ) || isnanf( src[f][1] ) ) + dst[f][1] += ( isinf( src[f][1] ) || isnan( src[f][1] ) ) ? 0.0f : src[f][1] * coeffSrcBuf1->values()[f] * coeffSrcBuf2->values()[f]; } @@ -192,8 +192,8 @@ struct AddSanitizedMultipliedOp void operator()( sampleFrame& dst, const sampleFrame& src ) const { - 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[0] += ( isinf( src[0] ) || isnan( src[0] ) ) ? 0.0f : src[0] * m_coeff; + dst[1] += ( isinf( src[1] ) || isnan( src[1] ) ) ? 0.0f : src[1] * m_coeff; } const float m_coeff;