shuffle around definitions

This commit is contained in:
Connor Olding 2015-05-28 12:21:38 -07:00
parent e2f8a22f95
commit 9f58751a04
3 changed files with 45 additions and 68 deletions

View file

@ -10,7 +10,7 @@ LADSPA = $(BOTH)
VST = $(BOTH) delay_test VST = $(BOTH) delay_test
UTILS = design bench UTILS = design bench
INCLUDES = util util_def param os6iir os2piir INCLUDES = util biquad param os6iir os2piir
BENCH_AGAINST = eq_const BENCH_AGAINST = eq_const

View file

@ -1,32 +1,26 @@
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
INNER void
disable_denormals()
{
#if __SSE2__
_mm_setcsr(_mm_getcsr() | 0x8040);
#endif
}
/* via http://www.rgba.org/articles/sfrand/sfrand.htm */
static unsigned int mirand = 1;
INNER float
whitenoise()
{
union either {
float f;
unsigned int i;
} white;
mirand *= 16807;
white.i = (mirand & 0x007FFFFF) | 0x40000000;
return white.f - 3;
}
/* used to resemble https://github.com/swh/ladspa/blob/master/util/biquad.h */ /* used to resemble https://github.com/swh/ladspa/blob/master/util/biquad.h */
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;
typedef struct {
double a1, a2, b0, b1, b2, x1, x2, y1, y2;
} biquad;
typedef struct {
double b0, b1, b2, a0, a1, a2;
} biquad_interim;
INNER void INNER void
biquad_init(biquad *bq) biquad_init(biquad *bq)
{ {

View file

@ -1,4 +1,6 @@
#include "math.h" #include <stdlib.h>
#include <math.h>
#include <stdint.h>
#ifdef __SSE2__ #ifdef __SSE2__
#include <emmintrin.h> #include <emmintrin.h>
@ -20,7 +22,15 @@ typedef unsigned long ulong; // __attribute((aligned(16)));
#define V(x) (v2df){(x), (x)} #define V(x) (v2df){(x), (x)}
INNER void INNER void
disable_denormals(); disable_denormals()
{
#if __SSE2__
_mm_setcsr(_mm_getcsr() | 0x8040);
#endif
}
/* via http://www.rgba.org/articles/sfrand/sfrand.htm */
static unsigned int mirand = 1;
#define LIMIT(v,l,u) ((v)<(l)?(l):((v)>(u)?(u):(v))) #define LIMIT(v,l,u) ((v)<(l)?(l):((v)>(u)?(u):(v)))
#define DB2LIN(x) ((x) > -90 ? pow(10, (x) * 0.05) : 0) #define DB2LIN(x) ((x) > -90 ? pow(10, (x) * 0.05) : 0)
@ -29,43 +39,16 @@ disable_denormals();
#define ANGULAR(fc, fs) (2 * M_PI / (fs) * (fc)) #define ANGULAR(fc, fs) (2 * M_PI / (fs) * (fc))
#define ANGULAR_LIM(fc, fs) (2 * M_PI / (fs) * LIMIT((fc), 1, (fs)/2)) #define ANGULAR_LIM(fc, fs) (2 * M_PI / (fs) * LIMIT((fc), 1, (fs)/2))
typedef struct {
double a1, a2, b0, b1, b2, x1, x2, y1, y2;
} biquad;
typedef struct {
double b0, b1, b2, a0, a1, a2;
} biquad_interim;
INNER float INNER float
whitenoise(); whitenoise()
{
union either {
float f;
unsigned int i;
} white;
mirand *= 16807;
white.i = (mirand & 0x007FFFFF) | 0x40000000;
return white.f - 3;
}
INNER void #include "biquad.h"
biquad_init(biquad *bq);
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;
INNER biquad
biquad_gen(filter_t type, double fc, double gain, double bw, double fs);
/* s-plane to z-plane */
static biquad_interim
design(double cw, double sw,
double num0, double num1, double num2,
double den0, double den1, double den2);
INNER double
biquad_run(biquad *bq, double x);
#include "util_def.h"