2013-11-10 13:17:39 -08:00
|
|
|
#include "math.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-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-04-07 13:55:12 -07:00
|
|
|
|
|
|
|
#ifndef FORCE_SINGLE
|
2015-04-06 11:26:47 -07:00
|
|
|
typedef double v2df __attribute__((vector_size(16), aligned(16)));
|
2015-04-07 13:55:12 -07:00
|
|
|
#else
|
|
|
|
typedef float v2df __attribute__((vector_size(8), aligned(8)));
|
|
|
|
#endif
|
|
|
|
|
2015-04-07 11:25:26 -07:00
|
|
|
typedef float v4sf __attribute__((vector_size(16), aligned(16)));
|
|
|
|
typedef unsigned long ulong; // __attribute((aligned(16)));
|
|
|
|
|
|
|
|
#define V(x) (v2df){(x), (x)}
|
2015-04-04 06:48:27 -07:00
|
|
|
|
|
|
|
INNER void
|
2014-02-05 23:53:23 -08:00
|
|
|
disable_denormals();
|
|
|
|
|
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))
|
|
|
|
|
|
|
|
typedef struct {
|
2014-02-05 23:32:24 -08:00
|
|
|
double a1, a2, b0, b1, b2, x1, x2, y1, y2;
|
2013-05-22 15:56:59 -07:00
|
|
|
} biquad;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double b0, b1, b2, a0, a1, a2;
|
|
|
|
} biquad_interim;
|
|
|
|
|
2015-04-04 06:48:27 -07:00
|
|
|
INNER float
|
2013-11-11 07:59:19 -08:00
|
|
|
whitenoise();
|
|
|
|
|
2015-04-04 06:48:27 -07:00
|
|
|
INNER void
|
2013-05-22 15:56:59 -07:00
|
|
|
biquad_init(biquad *bq);
|
|
|
|
|
2014-02-03 15:02:24 -08: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;
|
|
|
|
|
2015-04-04 06:48:27 -07:00
|
|
|
INNER biquad
|
2014-02-03 15:02:24 -08:00
|
|
|
biquad_gen(filter_t type, double fc, double gain, double bw, double fs);
|
2013-05-22 15:56:59 -07:00
|
|
|
|
2013-09-10 02:54:14 -07:00
|
|
|
/* s-plane to z-plane */
|
2015-04-06 11:26:47 -07:00
|
|
|
static biquad_interim
|
2013-09-10 02:54:14 -07:00
|
|
|
design(double cw, double sw,
|
|
|
|
double num0, double num1, double num2,
|
|
|
|
double den0, double den1, double den2);
|
|
|
|
|
2015-04-04 06:48:27 -07:00
|
|
|
INNER double
|
2014-02-05 23:32:24 -08:00
|
|
|
biquad_run(biquad *bq, double x);
|
2013-05-22 15:56:59 -07:00
|
|
|
|
2014-02-06 02:31:46 -08:00
|
|
|
#include "util_def.h"
|