inline everything; fix types
This commit is contained in:
parent
a394384555
commit
80e60fab1c
10 changed files with 73 additions and 74 deletions
3
Makefile
3
Makefile
|
@ -34,7 +34,8 @@ VST_SRC = ${VST_CPP:%=$(VST_CPP_DIR)/%}
|
|||
VST_OBJ = ${VST_CPP:%.cpp=$(BIN)/%.o}
|
||||
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_CXXFLAGS = $(GENERAL_FLAGS) $(CXXFLAGS)
|
||||
ALL_LDFLAGS = -lm $(LDFLAGS)
|
||||
|
|
|
@ -27,7 +27,7 @@ typedef struct {
|
|||
channel c[2];
|
||||
} personal;
|
||||
|
||||
static double
|
||||
INNER double
|
||||
fir_up(double *x, double s)
|
||||
{
|
||||
x[0] = s;
|
||||
|
@ -55,7 +55,7 @@ fir_up(double *x, double s)
|
|||
return s;
|
||||
}
|
||||
|
||||
static double
|
||||
INNER double
|
||||
fir_down(double *x, double s)
|
||||
{
|
||||
x[0] = s;
|
||||
|
@ -69,7 +69,7 @@ fir_down(double *x, double s)
|
|||
return s;
|
||||
}
|
||||
|
||||
static double
|
||||
INNER double
|
||||
process_one(channel *c, double 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;
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
process(personal *data,
|
||||
float *in_L, float *in_R,
|
||||
float *out_L, float *out_R,
|
||||
|
@ -91,7 +91,7 @@ process(personal *data,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
process_double(personal *data,
|
||||
double *in_L, double *in_R,
|
||||
double *out_L, double *out_R,
|
||||
|
@ -103,23 +103,23 @@ process_double(personal *data,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
construct(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
destruct(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
resume(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
pause(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
adjust(personal *data, ulong fs)
|
||||
{
|
||||
for (int k = 0; k < 2; k++) {
|
||||
|
|
20
crap/eq.h
20
crap/eq.h
|
@ -18,7 +18,7 @@ typedef struct {
|
|||
float fs;
|
||||
} personal;
|
||||
|
||||
static double
|
||||
INNER double
|
||||
process_one(biquad *filters, double samp)
|
||||
{
|
||||
for (int i = 0; i < BANDS; i++)
|
||||
|
@ -26,7 +26,7 @@ process_one(biquad *filters, double samp)
|
|||
return samp;
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
process(personal *data,
|
||||
float *in_L, float *in_R,
|
||||
float *out_L, float *out_R,
|
||||
|
@ -39,7 +39,7 @@ process(personal *data,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
process_double(personal *data,
|
||||
double *in_L, double *in_R,
|
||||
double *out_L, double *out_R,
|
||||
|
@ -52,7 +52,7 @@ process_double(personal *data,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
resume(personal *data)
|
||||
{
|
||||
biquad *filters = data->filters[0];
|
||||
|
@ -61,11 +61,11 @@ resume(personal *data)
|
|||
memcpy(data->filters[1], filters, BANDS*sizeof(biquad));
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
pause(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
construct_params(param *params)
|
||||
{
|
||||
for (int i = 0; i < BANDS; i++) {
|
||||
|
@ -94,15 +94,15 @@ construct_params(param *params)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
construct(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
destruct(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
adjust(personal *data, param *params, unsigned long fs)
|
||||
{
|
||||
data->fs = fs;
|
||||
|
@ -115,7 +115,7 @@ adjust(personal *data, param *params, unsigned long fs)
|
|||
resume(data);
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
adjust_one(personal *data, param *params, unsigned int index)
|
||||
{
|
||||
float fs = data->fs;
|
||||
|
|
|
@ -14,7 +14,7 @@ typedef struct {
|
|||
biquad filters[2][BANDS];
|
||||
} personal;
|
||||
|
||||
static double
|
||||
INNER double
|
||||
process_one(biquad *filters, double samp)
|
||||
{
|
||||
for (int i = 0; i < BANDS; i++)
|
||||
|
@ -22,7 +22,7 @@ process_one(biquad *filters, double samp)
|
|||
return samp;
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
process(personal *data,
|
||||
float *in_L, float *in_R,
|
||||
float *out_L, float *out_R,
|
||||
|
@ -35,7 +35,7 @@ process(personal *data,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
process_double(personal *data,
|
||||
double *in_L, double *in_R,
|
||||
double *out_L, double *out_R,
|
||||
|
@ -48,15 +48,15 @@ process_double(personal *data,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
construct(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
destruct(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
resume(personal *data)
|
||||
{
|
||||
biquad *filters = data->filters[0];
|
||||
|
@ -65,11 +65,11 @@ resume(personal *data)
|
|||
memcpy(data->filters[1], filters, BANDS*sizeof(biquad));
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
pause(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
adjust(personal *data, unsigned long fs)
|
||||
{
|
||||
biquad *filters = data->filters[0];
|
||||
|
|
14
crap/noise.h
14
crap/noise.h
|
@ -10,7 +10,7 @@
|
|||
typedef struct {
|
||||
} personal;
|
||||
|
||||
static void
|
||||
INNER void
|
||||
process(personal *data,
|
||||
float *in_L, float *in_R,
|
||||
float *out_L, float *out_R,
|
||||
|
@ -23,7 +23,7 @@ process(personal *data,
|
|||
out_R[pos] = whitenoise();
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
process_double(personal *data,
|
||||
double *in_L, double *in_R,
|
||||
double *out_L, double *out_R,
|
||||
|
@ -35,22 +35,22 @@ process_double(personal *data,
|
|||
out_R[pos] = whitenoise();
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
construct(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
destruct(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
resume(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
pause(personal *data)
|
||||
{}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
adjust(personal *data, unsigned long fs)
|
||||
{}
|
||||
|
|
26
crap/tube.h
26
crap/tube.h
|
@ -17,8 +17,6 @@
|
|||
#define BLOCK_SIZE 256
|
||||
#define FULL_SIZE (BLOCK_SIZE*OVERSAMPLING)
|
||||
|
||||
#define INNER static inline
|
||||
|
||||
typedef unsigned long ulong;
|
||||
|
||||
typedef struct {
|
||||
|
@ -79,43 +77,43 @@ process_double(personal *data,
|
|||
if (pos + BLOCK_SIZE > count)
|
||||
rem = count - pos;
|
||||
|
||||
for (int i = 0; i < rem*OVERSAMPLING; i++)
|
||||
for (ulong i = 0; i < rem*OVERSAMPLING; i++)
|
||||
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);
|
||||
|
||||
halfband_t *hb;
|
||||
|
||||
// left channel
|
||||
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+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]);
|
||||
}
|
||||
|
||||
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]);
|
||||
out_L[j] = decimate(hb, out_os[i+1]);
|
||||
}
|
||||
|
||||
// right channel
|
||||
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+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]);
|
||||
}
|
||||
|
||||
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]);
|
||||
out_R[j] = decimate(hb, out_os[i+1]);
|
||||
}
|
||||
|
@ -141,16 +139,16 @@ process(personal *data,
|
|||
if (pos + BLOCK_SIZE > count)
|
||||
rem = count - pos;
|
||||
|
||||
for (int i = 0; i < rem; i++)
|
||||
for (ulong i = 0; i < rem; 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];
|
||||
|
||||
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];
|
||||
for (int i = 0; i < rem; i++)
|
||||
for (ulong i = 0; i < rem; i++)
|
||||
out_R[i] = out_R2[i];
|
||||
|
||||
in_L += BLOCK_SIZE;
|
||||
|
|
|
@ -16,7 +16,7 @@ typedef struct {
|
|||
int i;
|
||||
} halfband_t;
|
||||
|
||||
static void
|
||||
INNER void
|
||||
halfband_a(double a[8], double ao[8], double x0, double x2)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
INNER void
|
||||
halfband_b(double b[8], double bo[8], double x1, double x3)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static double
|
||||
INNER double
|
||||
halfband(halfband_t *h, double x0)
|
||||
{
|
||||
double a[8], b[8];
|
||||
|
@ -58,7 +58,7 @@ halfband(halfband_t *h, double x0)
|
|||
return (a[7] + b[7])*0.5;
|
||||
}
|
||||
|
||||
static double
|
||||
INNER double
|
||||
decimate(halfband_t *h, double x0)
|
||||
{
|
||||
double c[8];
|
||||
|
@ -78,7 +78,7 @@ decimate(halfband_t *h, double x0)
|
|||
}
|
||||
|
||||
// note: do not zero-stuff! send the input each time.
|
||||
static double
|
||||
INNER double
|
||||
interpolate(halfband_t *h, double x0)
|
||||
{
|
||||
double c[8];
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include <xmmintrin.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
#define INNER static inline
|
||||
|
||||
INNER void
|
||||
disable_denormals();
|
||||
|
||||
#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;
|
||||
} biquad_interim;
|
||||
|
||||
static float
|
||||
INNER float
|
||||
whitenoise();
|
||||
|
||||
static void
|
||||
INNER void
|
||||
biquad_init(biquad *bq);
|
||||
|
||||
typedef enum {
|
||||
|
@ -41,16 +43,16 @@ typedef enum {
|
|||
FILT_GAIN
|
||||
} filter_t;
|
||||
|
||||
static biquad
|
||||
INNER biquad
|
||||
biquad_gen(filter_t type, double fc, double gain, double bw, double fs);
|
||||
|
||||
/* s-plane to z-plane */
|
||||
static biquad_interim
|
||||
INNER biquad_interim
|
||||
design(double cw, double sw,
|
||||
double num0, double num1, double num2,
|
||||
double den0, double den1, double den2);
|
||||
|
||||
static double
|
||||
INNER double
|
||||
biquad_run(biquad *bq, double x);
|
||||
|
||||
#include "util_def.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static void
|
||||
INNER void
|
||||
disable_denormals()
|
||||
{
|
||||
#if __SSE2__
|
||||
|
@ -13,7 +13,7 @@ disable_denormals()
|
|||
/* via http://www.rgba.org/articles/sfrand/sfrand.htm */
|
||||
static unsigned int mirand = 1;
|
||||
|
||||
static float
|
||||
INNER float
|
||||
whitenoise()
|
||||
{
|
||||
union either {
|
||||
|
@ -27,13 +27,13 @@ whitenoise()
|
|||
|
||||
/* used to resemble https://github.com/swh/ladspa/blob/master/util/biquad.h */
|
||||
|
||||
static void
|
||||
INNER void
|
||||
biquad_init(biquad *bq)
|
||||
{
|
||||
bq->x1 = bq->x2 = bq->y1 = bq->y2 = 0;
|
||||
}
|
||||
|
||||
static biquad_interim
|
||||
INNER biquad_interim
|
||||
design(double cw, double sw,
|
||||
double num0, double num1, double num2,
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static double
|
||||
INNER double
|
||||
biquad_run(biquad *bq, double x)
|
||||
{
|
||||
double y;
|
||||
|
|
12
util/bench.c
12
util/bench.c
|
@ -9,22 +9,20 @@
|
|||
#include "ladspa.h"
|
||||
#include "util.h"
|
||||
|
||||
enum {
|
||||
BLOCK_SIZE=2048
|
||||
};
|
||||
#define BLOCK_SIZE 2048
|
||||
|
||||
void *plug = NULL;
|
||||
static float *audio_buffer;
|
||||
static int audio_count = 0;
|
||||
|
||||
static void
|
||||
INNER void
|
||||
cleanup()
|
||||
{
|
||||
dlclose(plug);
|
||||
if (audio_count) free(audio_buffer);
|
||||
}
|
||||
|
||||
static const LADSPA_Descriptor*
|
||||
INNER const LADSPA_Descriptor*
|
||||
load_ladspa(char *path)
|
||||
{
|
||||
plug = dlopen(path, RTLD_NOW);
|
||||
|
@ -40,7 +38,7 @@ load_ladspa(char *path)
|
|||
return d;
|
||||
}
|
||||
|
||||
static float
|
||||
INNER float
|
||||
between(float percent, float min, float max, int logscale)
|
||||
{
|
||||
if (logscale)
|
||||
|
@ -49,7 +47,7 @@ between(float percent, float min, float max, int logscale)
|
|||
return (min - percent)/(min - max);
|
||||
}
|
||||
|
||||
static float
|
||||
INNER float
|
||||
get_default(LADSPA_PortRangeHint hint)
|
||||
{
|
||||
float x = 0;
|
||||
|
|
Loading…
Reference in a new issue