2015-05-28 12:21:38 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdint.h>
|
2013-05-22 15:56:59 -07:00
|
|
|
|
2014-02-05 23:53:23 -08:00
|
|
|
#ifdef __SSE2__
|
2015-04-07 11:25:26 -07:00
|
|
|
#include <emmintrin.h>
|
2014-02-05 23:53:23 -08:00
|
|
|
#endif
|
|
|
|
|
2015-06-06 16:45:09 -07:00
|
|
|
#define TEMPLATE template<typename T>
|
2015-04-04 06:48:27 -07:00
|
|
|
#define INNER static inline
|
2015-04-07 11:25:26 -07:00
|
|
|
#define PURE __attribute__((pure))
|
|
|
|
#define CONST __attribute__((const))
|
2015-05-28 21:14:13 -07:00
|
|
|
#define RESTRICT __restrict__
|
2015-04-07 13:55:12 -07:00
|
|
|
|
2015-06-06 16:45:09 -07:00
|
|
|
typedef unsigned long ulong; // __attribute((aligned(16)));
|
|
|
|
|
|
|
|
#include "Dumber.hpp"
|
|
|
|
#include "vectors.hpp"
|
2015-05-28 16:45:14 -07:00
|
|
|
|
2015-06-06 10:42:14 -07:00
|
|
|
#ifdef FORCE_SINGLE
|
2015-05-28 16:45:14 -07:00
|
|
|
#define v2df v2sf
|
2015-04-07 13:55:12 -07:00
|
|
|
#endif
|
|
|
|
|
2015-04-04 06:48:27 -07:00
|
|
|
INNER void
|
2015-05-28 12:21:38 -07:00
|
|
|
disable_denormals()
|
|
|
|
{
|
|
|
|
#if __SSE2__
|
|
|
|
_mm_setcsr(_mm_getcsr() | 0x8040);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-05-22 15:56:59 -07:00
|
|
|
#define LIMIT(v,l,u) ((v)<(l)?(l):((v)>(u)?(u):(v)))
|
2013-11-10 13:17:39 -08:00
|
|
|
#define DB2LIN(x) ((x) > -90 ? pow(10, (x) * 0.05) : 0)
|
2013-05-22 15:56:59 -07:00
|
|
|
|
|
|
|
/* frequency to rads/sec (angular frequency) */
|
|
|
|
#define ANGULAR(fc, fs) (2 * M_PI / (fs) * (fc))
|
|
|
|
#define ANGULAR_LIM(fc, fs) (2 * M_PI / (fs) * LIMIT((fc), 1, (fs)/2))
|
|
|
|
|
2015-06-06 16:45:09 -07:00
|
|
|
/* via http://www.rgba.org/articles/sfrand/sfrand.htm */
|
2015-04-04 06:48:27 -07:00
|
|
|
INNER float
|
2015-06-08 11:44:06 -07:00
|
|
|
whitenoise(unsigned int &mirand)
|
2015-05-28 12:21:38 -07:00
|
|
|
{
|
|
|
|
union either {
|
|
|
|
float f;
|
|
|
|
unsigned int i;
|
|
|
|
} white;
|
|
|
|
mirand *= 16807;
|
|
|
|
white.i = (mirand & 0x007FFFFF) | 0x40000000;
|
|
|
|
return white.f - 3;
|
|
|
|
}
|
|
|
|
|
2015-05-28 16:45:14 -07:00
|
|
|
typedef enum {
|
|
|
|
FILT_PEAKING,
|
|
|
|
FILT_LOWSHELF,
|
|
|
|
FILT_HIGHSHELF,
|
|
|
|
FILT_LOWPASS,
|
|
|
|
FILT_HIGHPASS,
|
|
|
|
FILT_ALLPASS,
|
|
|
|
FILT_BANDPASS,
|
|
|
|
FILT_BANDPASS_2,
|
|
|
|
FILT_NOTCH,
|
|
|
|
FILT_GAIN
|
|
|
|
} filter_t;
|