21#define PI_F 3.1415927410125732421875f
22#define TWOPI_F (2.0f * PI_F)
23#define HALFPI_F (PI_F * 0.5f)
24#define DSY_MIN(in, mn) (in < mn ? in : mn)
25#define DSY_MAX(in, mx) (in > mx ? in : mx)
26#define DSY_CLAMP(in, mn, mx) (DSY_MIN(DSY_MAX(in, mn), mx))
27#define DSY_COUNTOF(_arr) (sizeof(_arr) / sizeof(_arr[0]))
32static constexpr float kRandFrac = 1.f / (float)RAND_MAX;
35static constexpr float kOneTwelfth = 1.f / 12.f;
40inline float fmax(
float a,
float b)
44 asm(
"vmaxnm.f32 %[d], %[n], %[m]" : [d]
"=t"(r) : [n]
"t"(a), [m]
"t"(b) :);
51inline float fmin(
float a,
float b)
55 asm(
"vminnm.f32 %[d], %[n], %[m]" : [d]
"=t"(r) : [n]
"t"(a), [m]
"t"(b) :);
64inline float fclamp(
float in,
float min,
float max)
66 return fmin(
fmax(in, min), max);
85inline float fastroot(
float f,
int n)
102 return x -
static_cast<int>(x);
110 return expf(2.302585092994046f * f);
116inline float fastlog2f(
float f)
120 frac = frexpf(fabsf(f), &exp);
121 f = 1.23149591368684f;
123 f += -4.11852516267426f;
125 f += 6.02197014179219f;
127 f += -3.13396450166353f;
132inline float fastlog10f(
float f)
134 return fastlog2f(f) * 0.3010299956639812f;
141 return powf(2, (m - 69.0f) / 12.0f) * 440.0f;
151inline void fonepole(
float &out,
float in,
float coeff)
153 out += coeff * (in - out);
177fmap(
float in,
float min,
float max,
Mapping curve = Mapping::LINEAR)
182 return fclamp(min + (in * in) * (max - min), min, max);
185 const float a = 1.f / log10f(max / min);
186 return fclamp(min * powf(10, in / a), min, max);
188 case Mapping::LINEAR:
189 default:
return fclamp(min + in * (max - min), min, max);
199 return (b < a) ? (b < c) ? (c < a) ? c : a : b
200 : (a < c) ? (c < b) ? c : b : a;
215 return -0.5f * t * t;
222 const float t1 = 0.5f * t;
223 const float t2 = t1 * t1;
224 const float t4 = t2 * t2;
225 return 0.1875f - t1 + 1.5f * t2 - t4;
238 return x * (27.f + x * x) / (27.f + 9.f * x * x);
260 if(!std::isnormal(x) && x != 0)
262#if defined(__arm__) && defined(DEBUG)
289 val = flip ? -in : in;
296 out = (thresh + 1.0f) / 2.0f;
300 else if(val > thresh)
303 temp = (val - thresh) / (1 - thresh);
304 out = thresh + (val - thresh) / (1.0f + (temp * temp));
319constexpr bool is_power2(uint32_t x)
321 return ((x - 1) & x) == 0;
329#if __cplusplus <= 201103L
343 assert(is_power2(x));
351#include "custom_dsp.h"
FIR Filter implementation, generic and ARM CMSIS DSP based.
Definition adenv.h:16
uint32_t get_next_power2(uint32_t x)
Definition dsp.h:330
float fastpower(float f, int n)
Definition dsp.h:73
Mapping
Definition dsp.h:158
float mtof(float m)
Definition dsp.h:139
float ThisBlepSample(float t)
Definition dsp.h:205
float fastmod1f(float x)
Definition dsp.h:100
float pow10f(float f)
Definition dsp.h:108
T median(T a, T b, T c)
Definition dsp.h:197
float fclamp(float in, float min, float max)
Definition dsp.h:64
float NextIntegratedBlepSample(float t)
Definition dsp.h:220
float soft_saturate(float in, float thresh)
Definition dsp.h:282
float fmax(float a, float b)
Definition dsp.h:40
float SoftLimit(float x)
Definition dsp.h:236
float NextBlepSample(float t)
Definition dsp.h:212
float fmap(float in, float min, float max, Mapping curve=Mapping::LINEAR)
Definition dsp.h:177
void TestFloat(float &x, float y=0.f)
Definition dsp.h:258
float ThisIntegratedBlepSample(float t)
Definition dsp.h:230
float SoftClip(float x)
Definition dsp.h:242
void fonepole(float &out, float in, float coeff)
Definition dsp.h:151