inline everything; fix types

This commit is contained in:
Connor Olding 2015-04-04 06:48:27 -07:00
parent a394384555
commit 80e60fab1c
10 changed files with 73 additions and 74 deletions

View file

@ -34,7 +34,8 @@ VST_SRC = ${VST_CPP:%=$(VST_CPP_DIR)/%}
VST_OBJ = ${VST_CPP:%.cpp=$(BIN)/%.o} VST_OBJ = ${VST_CPP:%.cpp=$(BIN)/%.o}
VST_DEF = $(VST_SDK_DIR)/public.sdk/samples/vst2.x/win/vstplug.def VST_DEF = $(VST_SDK_DIR)/public.sdk/samples/vst2.x/win/vstplug.def
GENERAL_FLAGS = -Wall -Wno-unused-function -I include INLINE_FLAGS = -Winline -finline-limit=1000
GENERAL_FLAGS = -Wall -Wno-unused-function -I include $(INLINE_FLAGS)
ALL_CFLAGS = $(GENERAL_FLAGS) -std=gnu11 $(CFLAGS) ALL_CFLAGS = $(GENERAL_FLAGS) -std=gnu11 $(CFLAGS)
ALL_CXXFLAGS = $(GENERAL_FLAGS) $(CXXFLAGS) ALL_CXXFLAGS = $(GENERAL_FLAGS) $(CXXFLAGS)
ALL_LDFLAGS = -lm $(LDFLAGS) ALL_LDFLAGS = -lm $(LDFLAGS)

View file

@ -27,7 +27,7 @@ typedef struct {
channel c[2]; channel c[2];
} personal; } personal;
static double INNER double
fir_up(double *x, double s) fir_up(double *x, double s)
{ {
x[0] = s; x[0] = s;
@ -55,7 +55,7 @@ fir_up(double *x, double s)
return s; return s;
} }
static double INNER double
fir_down(double *x, double s) fir_down(double *x, double s)
{ {
x[0] = s; x[0] = s;
@ -69,7 +69,7 @@ fir_down(double *x, double s)
return s; return s;
} }
static double INNER double
process_one(channel *c, double s) process_one(channel *c, double s)
{ {
s = fir_down(c->down, biquad_run(&c->filter, fir_up(c->up, s))); s = fir_down(c->down, biquad_run(&c->filter, fir_up(c->up, s)));
@ -79,7 +79,7 @@ process_one(channel *c, double s)
return s; return s;
} }
static void INNER void
process(personal *data, process(personal *data,
float *in_L, float *in_R, float *in_L, float *in_R,
float *out_L, float *out_R, float *out_L, float *out_R,
@ -91,7 +91,7 @@ process(personal *data,
} }
} }
static void INNER void
process_double(personal *data, process_double(personal *data,
double *in_L, double *in_R, double *in_L, double *in_R,
double *out_L, double *out_R, double *out_L, double *out_R,
@ -103,23 +103,23 @@ process_double(personal *data,
} }
} }
static void INNER void
construct(personal *data) construct(personal *data)
{} {}
static void INNER void
destruct(personal *data) destruct(personal *data)
{} {}
static void INNER void
resume(personal *data) resume(personal *data)
{} {}
static void INNER void
pause(personal *data) pause(personal *data)
{} {}
static void INNER void
adjust(personal *data, ulong fs) adjust(personal *data, ulong fs)
{ {
for (int k = 0; k < 2; k++) { for (int k = 0; k < 2; k++) {

View file

@ -18,7 +18,7 @@ typedef struct {
float fs; float fs;
} personal; } personal;
static double INNER double
process_one(biquad *filters, double samp) process_one(biquad *filters, double samp)
{ {
for (int i = 0; i < BANDS; i++) for (int i = 0; i < BANDS; i++)
@ -26,7 +26,7 @@ process_one(biquad *filters, double samp)
return samp; return samp;
} }
static void INNER void
process(personal *data, process(personal *data,
float *in_L, float *in_R, float *in_L, float *in_R,
float *out_L, float *out_R, float *out_L, float *out_R,
@ -39,7 +39,7 @@ process(personal *data,
} }
} }
static void INNER void
process_double(personal *data, process_double(personal *data,
double *in_L, double *in_R, double *in_L, double *in_R,
double *out_L, double *out_R, double *out_L, double *out_R,
@ -52,7 +52,7 @@ process_double(personal *data,
} }
} }
static void INNER void
resume(personal *data) resume(personal *data)
{ {
biquad *filters = data->filters[0]; biquad *filters = data->filters[0];
@ -61,11 +61,11 @@ resume(personal *data)
memcpy(data->filters[1], filters, BANDS*sizeof(biquad)); memcpy(data->filters[1], filters, BANDS*sizeof(biquad));
} }
static void INNER void
pause(personal *data) pause(personal *data)
{} {}
static void INNER void
construct_params(param *params) construct_params(param *params)
{ {
for (int i = 0; i < BANDS; i++) { for (int i = 0; i < BANDS; i++) {
@ -94,15 +94,15 @@ construct_params(param *params)
} }
} }
static void INNER void
construct(personal *data) construct(personal *data)
{} {}
static void INNER void
destruct(personal *data) destruct(personal *data)
{} {}
static void INNER void
adjust(personal *data, param *params, unsigned long fs) adjust(personal *data, param *params, unsigned long fs)
{ {
data->fs = fs; data->fs = fs;
@ -115,7 +115,7 @@ adjust(personal *data, param *params, unsigned long fs)
resume(data); resume(data);
} }
static void INNER void
adjust_one(personal *data, param *params, unsigned int index) adjust_one(personal *data, param *params, unsigned int index)
{ {
float fs = data->fs; float fs = data->fs;

View file

@ -14,7 +14,7 @@ typedef struct {
biquad filters[2][BANDS]; biquad filters[2][BANDS];
} personal; } personal;
static double INNER double
process_one(biquad *filters, double samp) process_one(biquad *filters, double samp)
{ {
for (int i = 0; i < BANDS; i++) for (int i = 0; i < BANDS; i++)
@ -22,7 +22,7 @@ process_one(biquad *filters, double samp)
return samp; return samp;
} }
static void INNER void
process(personal *data, process(personal *data,
float *in_L, float *in_R, float *in_L, float *in_R,
float *out_L, float *out_R, float *out_L, float *out_R,
@ -35,7 +35,7 @@ process(personal *data,
} }
} }
static void INNER void
process_double(personal *data, process_double(personal *data,
double *in_L, double *in_R, double *in_L, double *in_R,
double *out_L, double *out_R, double *out_L, double *out_R,
@ -48,15 +48,15 @@ process_double(personal *data,
} }
} }
static void INNER void
construct(personal *data) construct(personal *data)
{} {}
static void INNER void
destruct(personal *data) destruct(personal *data)
{} {}
static void INNER void
resume(personal *data) resume(personal *data)
{ {
biquad *filters = data->filters[0]; biquad *filters = data->filters[0];
@ -65,11 +65,11 @@ resume(personal *data)
memcpy(data->filters[1], filters, BANDS*sizeof(biquad)); memcpy(data->filters[1], filters, BANDS*sizeof(biquad));
} }
static void INNER void
pause(personal *data) pause(personal *data)
{} {}
static void INNER void
adjust(personal *data, unsigned long fs) adjust(personal *data, unsigned long fs)
{ {
biquad *filters = data->filters[0]; biquad *filters = data->filters[0];

View file

@ -10,7 +10,7 @@
typedef struct { typedef struct {
} personal; } personal;
static void INNER void
process(personal *data, process(personal *data,
float *in_L, float *in_R, float *in_L, float *in_R,
float *out_L, float *out_R, float *out_L, float *out_R,
@ -23,7 +23,7 @@ process(personal *data,
out_R[pos] = whitenoise(); out_R[pos] = whitenoise();
} }
static void INNER void
process_double(personal *data, process_double(personal *data,
double *in_L, double *in_R, double *in_L, double *in_R,
double *out_L, double *out_R, double *out_L, double *out_R,
@ -35,22 +35,22 @@ process_double(personal *data,
out_R[pos] = whitenoise(); out_R[pos] = whitenoise();
} }
static void INNER void
construct(personal *data) construct(personal *data)
{} {}
static void INNER void
destruct(personal *data) destruct(personal *data)
{} {}
static void INNER void
resume(personal *data) resume(personal *data)
{} {}
static void INNER void
pause(personal *data) pause(personal *data)
{} {}
static void INNER void
adjust(personal *data, unsigned long fs) adjust(personal *data, unsigned long fs)
{} {}

View file

@ -17,8 +17,6 @@
#define BLOCK_SIZE 256 #define BLOCK_SIZE 256
#define FULL_SIZE (BLOCK_SIZE*OVERSAMPLING) #define FULL_SIZE (BLOCK_SIZE*OVERSAMPLING)
#define INNER static inline
typedef unsigned long ulong; typedef unsigned long ulong;
typedef struct { typedef struct {
@ -79,43 +77,43 @@ process_double(personal *data,
if (pos + BLOCK_SIZE > count) if (pos + BLOCK_SIZE > count)
rem = count - pos; rem = count - pos;
for (int i = 0; i < rem*OVERSAMPLING; i++) for (ulong i = 0; i < rem*OVERSAMPLING; i++)
drives[i] = smooth(&data->drive); drives[i] = smooth(&data->drive);
for (int i = 0; i < rem*OVERSAMPLING; i++) for (ulong i = 0; i < rem*OVERSAMPLING; i++)
wets[i] = smooth(&data->wet); wets[i] = smooth(&data->wet);
halfband_t *hb; halfband_t *hb;
// left channel // left channel
hb = &data->hbu_L; hb = &data->hbu_L;
for (int i = 0, j = 0; j < rem; i += OVERSAMPLING, j++) { for (ulong i = 0, j = 0; j < rem; i += OVERSAMPLING, j++) {
in_os[i+0] = interpolate(hb, in_L[j]); in_os[i+0] = interpolate(hb, in_L[j]);
in_os[i+1] = interpolate(hb, in_L[j]); in_os[i+1] = interpolate(hb, in_L[j]);
} }
for (int i = 0; i < rem*OVERSAMPLING; i++) { for (ulong i = 0; i < rem*OVERSAMPLING; i++) {
out_os[i] = process_one(in_os[i], drives[i], wets[i]); out_os[i] = process_one(in_os[i], drives[i], wets[i]);
} }
hb = &data->hbd_L; hb = &data->hbd_L;
for (int i = 0, j = 0; j < rem; i += OVERSAMPLING, j++) { for (ulong i = 0, j = 0; j < rem; i += OVERSAMPLING, j++) {
decimate(hb, out_os[i+0]); decimate(hb, out_os[i+0]);
out_L[j] = decimate(hb, out_os[i+1]); out_L[j] = decimate(hb, out_os[i+1]);
} }
// right channel // right channel
hb = &data->hbu_R; hb = &data->hbu_R;
for (int i = 0, j = 0; j < rem; i += OVERSAMPLING, j++) { for (ulong i = 0, j = 0; j < rem; i += OVERSAMPLING, j++) {
in_os[i+0] = interpolate(hb, in_R[j]); in_os[i+0] = interpolate(hb, in_R[j]);
in_os[i+1] = interpolate(hb, in_R[j]); in_os[i+1] = interpolate(hb, in_R[j]);
} }
for (int i = 0; i < rem*OVERSAMPLING; i++) { for (ulong i = 0; i < rem*OVERSAMPLING; i++) {
out_os[i] = process_one(in_os[i], drives[i], wets[i]); out_os[i] = process_one(in_os[i], drives[i], wets[i]);
} }
hb = &data->hbd_R; hb = &data->hbd_R;
for (int i = 0, j = 0; j < rem; i += OVERSAMPLING, j++) { for (ulong i = 0, j = 0; j < rem; i += OVERSAMPLING, j++) {
decimate(hb, out_os[i+0]); decimate(hb, out_os[i+0]);
out_R[j] = decimate(hb, out_os[i+1]); out_R[j] = decimate(hb, out_os[i+1]);
} }
@ -141,16 +139,16 @@ process(personal *data,
if (pos + BLOCK_SIZE > count) if (pos + BLOCK_SIZE > count)
rem = count - pos; rem = count - pos;
for (int i = 0; i < rem; i++) for (ulong i = 0; i < rem; i++)
in_L2[i] = in_L[i]; in_L2[i] = in_L[i];
for (int i = 0; i < rem; i++) for (ulong i = 0; i < rem; i++)
in_R2[i] = in_R[i]; in_R2[i] = in_R[i];
process_double(data, in_L2, in_R2, out_L2, out_R2, rem); process_double(data, in_L2, in_R2, out_L2, out_R2, rem);
for (int i = 0; i < rem; i++) for (ulong i = 0; i < rem; i++)
out_L[i] = out_L2[i]; out_L[i] = out_L2[i];
for (int i = 0; i < rem; i++) for (ulong i = 0; i < rem; i++)
out_R[i] = out_R2[i]; out_R[i] = out_R2[i];
in_L += BLOCK_SIZE; in_L += BLOCK_SIZE;

View file

@ -16,7 +16,7 @@ typedef struct {
int i; int i;
} halfband_t; } halfband_t;
static void INNER void
halfband_a(double a[8], double ao[8], double x0, double x2) halfband_a(double a[8], double ao[8], double x0, double x2)
{ {
a[0] = x2 + (x0 - ao[0])*0.006185967461045014; a[0] = x2 + (x0 - ao[0])*0.006185967461045014;
@ -29,7 +29,7 @@ halfband_a(double a[8], double ao[8], double x0, double x2)
a[7] = ao[6] + (a[6] - ao[7])*0.862917812650502936; a[7] = ao[6] + (a[6] - ao[7])*0.862917812650502936;
} }
static void INNER void
halfband_b(double b[8], double bo[8], double x1, double x3) halfband_b(double b[8], double bo[8], double x1, double x3)
{ {
b[0] = x3 + (x1 - bo[0])*0.024499027624721819; b[0] = x3 + (x1 - bo[0])*0.024499027624721819;
@ -42,7 +42,7 @@ halfband_b(double b[8], double bo[8], double x1, double x3)
b[7] = bo[6] + (b[6] - bo[7])*0.952428157718303137; b[7] = bo[6] + (b[6] - bo[7])*0.952428157718303137;
} }
static double INNER double
halfband(halfband_t *h, double x0) halfband(halfband_t *h, double x0)
{ {
double a[8], b[8]; double a[8], b[8];
@ -58,7 +58,7 @@ halfband(halfband_t *h, double x0)
return (a[7] + b[7])*0.5; return (a[7] + b[7])*0.5;
} }
static double INNER double
decimate(halfband_t *h, double x0) decimate(halfband_t *h, double x0)
{ {
double c[8]; double c[8];
@ -78,7 +78,7 @@ decimate(halfband_t *h, double x0)
} }
// note: do not zero-stuff! send the input each time. // note: do not zero-stuff! send the input each time.
static double INNER double
interpolate(halfband_t *h, double x0) interpolate(halfband_t *h, double x0)
{ {
double c[8]; double c[8];

View file

@ -4,7 +4,9 @@
#include <xmmintrin.h> #include <xmmintrin.h>
#endif #endif
static void #define INNER static inline
INNER void
disable_denormals(); disable_denormals();
#define LIMIT(v,l,u) ((v)<(l)?(l):((v)>(u)?(u):(v))) #define LIMIT(v,l,u) ((v)<(l)?(l):((v)>(u)?(u):(v)))
@ -22,10 +24,10 @@ typedef struct {
double b0, b1, b2, a0, a1, a2; double b0, b1, b2, a0, a1, a2;
} biquad_interim; } biquad_interim;
static float INNER float
whitenoise(); whitenoise();
static void INNER void
biquad_init(biquad *bq); biquad_init(biquad *bq);
typedef enum { typedef enum {
@ -41,16 +43,16 @@ typedef enum {
FILT_GAIN FILT_GAIN
} filter_t; } filter_t;
static biquad INNER biquad
biquad_gen(filter_t type, double fc, double gain, double bw, double fs); biquad_gen(filter_t type, double fc, double gain, double bw, double fs);
/* s-plane to z-plane */ /* s-plane to z-plane */
static biquad_interim INNER biquad_interim
design(double cw, double sw, design(double cw, double sw,
double num0, double num1, double num2, double num0, double num1, double num2,
double den0, double den1, double den2); double den0, double den1, double den2);
static double INNER double
biquad_run(biquad *bq, double x); biquad_run(biquad *bq, double x);
#include "util_def.h" #include "util_def.h"

View file

@ -2,7 +2,7 @@
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
static void INNER void
disable_denormals() disable_denormals()
{ {
#if __SSE2__ #if __SSE2__
@ -13,7 +13,7 @@ disable_denormals()
/* via http://www.rgba.org/articles/sfrand/sfrand.htm */ /* via http://www.rgba.org/articles/sfrand/sfrand.htm */
static unsigned int mirand = 1; static unsigned int mirand = 1;
static float INNER float
whitenoise() whitenoise()
{ {
union either { union either {
@ -27,13 +27,13 @@ whitenoise()
/* 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 */
static void INNER void
biquad_init(biquad *bq) biquad_init(biquad *bq)
{ {
bq->x1 = bq->x2 = bq->y1 = bq->y2 = 0; bq->x1 = bq->x2 = bq->y1 = bq->y2 = 0;
} }
static biquad_interim INNER biquad_interim
design(double cw, double sw, design(double cw, double sw,
double num0, double num1, double num2, double num0, double num1, double num2,
double den0, double den1, double den2) double den0, double den1, double den2)
@ -48,7 +48,7 @@ design(double cw, double sw,
}; };
} }
static biquad INNER biquad
biquad_gen(filter_t type, double fc, double gain, double bw, double fs) biquad_gen(filter_t type, double fc, double gain, double bw, double fs)
{ {
double w0, cw, sw, A, As, Q; double w0, cw, sw, A, As, Q;
@ -88,7 +88,7 @@ biquad_gen(filter_t type, double fc, double gain, double bw, double fs)
return out; return out;
} }
static double INNER double
biquad_run(biquad *bq, double x) biquad_run(biquad *bq, double x)
{ {
double y; double y;

View file

@ -9,22 +9,20 @@
#include "ladspa.h" #include "ladspa.h"
#include "util.h" #include "util.h"
enum { #define BLOCK_SIZE 2048
BLOCK_SIZE=2048
};
void *plug = NULL; void *plug = NULL;
static float *audio_buffer; static float *audio_buffer;
static int audio_count = 0; static int audio_count = 0;
static void INNER void
cleanup() cleanup()
{ {
dlclose(plug); dlclose(plug);
if (audio_count) free(audio_buffer); if (audio_count) free(audio_buffer);
} }
static const LADSPA_Descriptor* INNER const LADSPA_Descriptor*
load_ladspa(char *path) load_ladspa(char *path)
{ {
plug = dlopen(path, RTLD_NOW); plug = dlopen(path, RTLD_NOW);
@ -40,7 +38,7 @@ load_ladspa(char *path)
return d; return d;
} }
static float INNER float
between(float percent, float min, float max, int logscale) between(float percent, float min, float max, int logscale)
{ {
if (logscale) if (logscale)
@ -49,7 +47,7 @@ between(float percent, float min, float max, int logscale)
return (min - percent)/(min - max); return (min - percent)/(min - max);
} }
static float INNER float
get_default(LADSPA_PortRangeHint hint) get_default(LADSPA_PortRangeHint hint)
{ {
float x = 0; float x = 0;