2#ifndef __ASE_MATHUTILS_HH__
3#define __ASE_MATHUTILS_HH__
10constexpr const double DOUBLE_EPSILON = 1.1102230246251565404236316680908203125e-16;
14extern inline ASE_CONST
int irintf (
float f) {
return __builtin_rintf (f); }
17extern inline double force_double (
double d) {
volatile double v = d;
return v; }
20extern inline float force_float (
float f) {
volatile float v = f;
return v; }
35#if __BYTE_ORDER == __LITTLE_ENDIAN
36 uint mantissa : 23, biased_exponent : 8, sign : 1;
37#elif __BYTE_ORDER == __BIG_ENDIAN
38 uint sign : 1, biased_exponent : 8, mantissa : 23;
42 static constexpr const float EPSILON = 5.9604644775390625e-08;
43 static constexpr const int BIAS = 127;
44 static constexpr const float FMAX = 3.40282347e+38;
45 static constexpr const float FMIN = 1.17549435e-38;
46 static constexpr const float SMAX = 1.17549421e-38;
47 static constexpr const float SMIN = 1.40129846e-45;
57extern inline float fast_exp2 (
float x) ASE_CONST;
66extern inline float fast_log2 (
float x) ASE_CONST;
69extern inline float value2hz (
float x) ASE_CONST;
72extern inline float hz2value (
float x) ASE_CONST;
81extern inline ASE_CONST
float
87 fp.mpn.biased_exponent = fp.
BIAS + i;
88 const float x = ex - i;
91 r = x * 0.0013276471992255f;
92 r = x * (0.0096755413344448f + r);
93 r = x * (0.0555071327349880f + r);
94 r = x * (0.2402211972384019f + r);
95 r = x * (0.6931469670647601f + r);
96 r = fp.v_float * (1.0f + r);
100extern inline ASE_CONST
float
107 float r, x = u.v_float - 1.0f;
112 r = x * -0.0259366993544709205147977455165000143561553284592936f;
113 r = x * (+0.122047857676447181074792747820717519424533931189428f + r);
114 r = x * (-0.27814297685064327713977752916286528359628147166014f + r);
115 r = x * (+0.45764712300320092992105460899527194244236573556309f + r);
116 r = x * (-0.71816105664624015087225994551041120290062342459945f + r);
117 r = x * (+1.44254540258782520489769598315182363877204824648687f + r);
The Anklang C++ API namespace.
float value2hz(float x)
Convert synthesizer value (Voltage) to Hertz.
const float *const cent_table
Finetune factor table with 201 entries for -100…0…+100 cent.
const float *const semitone_tables_265[17]
Musical Tuning Tables, to be indexed by MusicalTuning
float force_float(float f)
Force number into single precision floating point format, even with -ffast-math.
double force_double(double d)
Force number into double precision floating point format, even with -ffast-math.
uint32_t uint
Provide 'uint' as convenience type.
constexpr const double DOUBLE_EPSILON
Double round-off error at 1.0, equals 2^-53.
float hz2value(float x)
Convert Hertz to synthesizer value (Voltage).
static constexpr const float SMIN
0x00000001 Minimum Subnormal
static constexpr const int BIAS
Exponent bias.
static constexpr const float FMIN
0x00800000 Minimum Normal
static constexpr const float SMAX
0x007fffff Maximum Subnormal
static constexpr const float EPSILON
2^-24, round-off error at 1.0
static constexpr const float FMAX
0x7f7fffff, 2^128 * (1 - epsilon)