mirror of
https://github.com/LMMS/lmms.git
synced 2026-01-27 07:48:18 -05:00
lmms_math: C++11 updates
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#ifndef LMMS_MATH_H
|
||||
#define LMMS_MATH_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include "lmms_constants.h"
|
||||
#include "lmmsconfig.h"
|
||||
#include <QtCore/QtGlobal>
|
||||
@@ -34,25 +34,8 @@
|
||||
#include <cmath>
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user