Remove typeInfo struct from lmms_basics.h (#7380)
* remove typeInfo struct from lmms_basics.h * Code review Co-authored-by: saker <sakertooth@gmail.com> * converted epsilon to a constant * renamed to approximatelyEqual and moved to top --------- Co-authored-by: saker <sakertooth@gmail.com>
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
#ifndef LMMS_INSTRUMENT_TRACK_H
|
||||
#define LMMS_INSTRUMENT_TRACK_H
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "AudioPort.h"
|
||||
#include "InstrumentFunctions.h"
|
||||
#include "InstrumentSoundShaping.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#define LMMS_TYPES_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
|
||||
#include "lmmsconfig.h"
|
||||
|
||||
@@ -55,57 +54,6 @@ using mix_ch_t = uint16_t; // Mixer-channel (0 to MAX_CHANNEL)
|
||||
|
||||
using jo_id_t = uint32_t; // (unique) ID of a journalling object
|
||||
|
||||
// windows headers define "min" and "max" macros, breaking the methods bwloe
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
template<typename T>
|
||||
struct typeInfo
|
||||
{
|
||||
static inline T min()
|
||||
{
|
||||
return std::numeric_limits<T>::min();
|
||||
}
|
||||
|
||||
static inline T max()
|
||||
{
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
|
||||
static inline T minEps()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline bool isEqual( T x, T y )
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
||||
static inline T absVal( T t )
|
||||
{
|
||||
return t >= 0 ? t : -t;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
template<>
|
||||
inline float typeInfo<float>::minEps()
|
||||
{
|
||||
return 1.0e-10f;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool typeInfo<float>::isEqual( float x, float y )
|
||||
{
|
||||
if( x == y )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return absVal( x - y ) < minEps();
|
||||
}
|
||||
|
||||
|
||||
|
||||
constexpr ch_cnt_t DEFAULT_CHANNELS = 2;
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ constexpr float F_E = (float) LD_E;
|
||||
constexpr float F_E_R = (float) LD_E_R;
|
||||
constexpr float F_SQRT_2 = (float) LD_SQRT_2;
|
||||
|
||||
constexpr float F_EPSILON = 1.0e-10f; // 10^-10
|
||||
|
||||
// Microtuner
|
||||
constexpr unsigned int MaxScaleCount = 10; //!< number of scales per project
|
||||
constexpr unsigned int MaxKeymapCount = 10; //!< number of keyboard mappings per project
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
namespace lmms
|
||||
{
|
||||
|
||||
static inline bool approximatelyEqual(float x, float y)
|
||||
{
|
||||
return x == y ? true : std::abs(x - y) < F_EPSILON;
|
||||
}
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
|
||||
static inline float absFraction( const float _x )
|
||||
|
||||
Reference in New Issue
Block a user