beginning conversion to sepples

This commit is contained in:
Connor Olding 2015-06-06 10:42:14 -07:00
parent 42c23a95d5
commit 39e385f1f9
26 changed files with 69 additions and 69 deletions

View file

@ -17,7 +17,7 @@ BENCH_AGAINST = eq_const
###
PROGRAM = ${UTILS:%=$(BIN)/%}
HEADERS = ${INCLUDES:%=include/%.h}
HEADERS = ${INCLUDES:%=include/%.hpp}
LADSPA_SHOBJ = ${LADSPA:%=$(BIN)/$(DISTNAME)_%-ladspa.so}
VST_SHOBJ = ${VST:%=$(BIN)/$(DISTNAME)_%-vst.so}
@ -36,8 +36,7 @@ VST_DEF = $(VST_SDK_DIR)/public.sdk/samples/vst2.x/win/vstplug.def
INLINE_FLAGS = -Winline
GENERAL_FLAGS = -Wall -Wno-unused-function -Wno-sign-compare -I include $(INLINE_FLAGS)
ALL_CFLAGS = $(GENERAL_FLAGS) -std=gnu11 $(CFLAGS)
ALL_CXXFLAGS = $(GENERAL_FLAGS) $(CXXFLAGS)
ALL_CXXFLAGS = $(GENERAL_FLAGS) -std=gnu++11 $(CXXFLAGS)
ALL_LDFLAGS = -lm $(LDFLAGS)
LADSPA_FLAGS =
@ -61,26 +60,21 @@ exe: $(EXE)
dll: $(DLL)
windows: ALL_CFLAGS += $(OPT_FLAGS)
windows: ALL_CXXFLAGS += $(OPT_FLAGS)
windows: dll
linux: ALL_CFLAGS += $(OPT_FLAGS) -fpic
linux: ALL_CXXFLAGS += $(OPT_FLAGS) -fpic
linux: VST_FLAGS += -D__cdecl=
linux: all
linux-arm: ALL_CFLAGS += -Ofast -march=native -DFORCE_SINGLE -fpic
linux-arm: ALL_CXXFLAGS += -Ofast -march=native -DFORCE_SINGLE -fpic
linux-arm: VST_FLAGS += -D__cdecl=
linux-arm: all
options:
@echo "CPPFLAGS = $(CPPFLAGS)"
@echo "ALL_CFLAGS = $(ALL_CFLAGS)"
@echo "ALL_CXXFLAGS = $(ALL_CXXFLAGS)"
@echo "ALL_LDFLAGS = $(ALL_LDFLAGS)"
@echo "CC = $(CC)"
@echo "CXX = $(CXX)"
@echo "LD = $(LD)"
@echo
@ -89,8 +83,8 @@ ladspa: $(LADSPA_SHOBJ)
vst: $(VST_SHOBJ)
pretest: util/denorm_test.h
@$(CC) -E $(ALL_CFLAGS) $^ -o /dev/null
pretest: util/denorm_test.hpp
@$(CXX) -E $(ALL_CXXFLAGS) $^ -o /dev/null
benchmark: $(BIN)/bench $(AGAINST)
util/benchtime $(BIN)/bench $(AGAINST)
@ -106,26 +100,26 @@ $(BIN)/%.dll: $(BIN)/%.so
@$(OBJCOPY) -S $< $@
$(BIN)/%-ladspa.so: $(BIN)/%-ladspa.o
@echo ' CCLD '$@
@$(CC) $(ALL_CFLAGS) $(LADSPA_FLAGS) -shared $^ -o $@ $(ALL_LDFLAGS)
@echo ' CXXLD '$@
@$(CXX) $(ALL_CXXFLAGS) $(LADSPA_FLAGS) -shared $^ -o $@ $(ALL_LDFLAGS)
$(BIN)/%-vst.so: $(BIN)/%-vst.o $(BIN)/vstsdk.o
@echo ' CXXLD '$@
@$(CXX) $(ALL_CXXFLAGS) $(VST_FLAGS) -shared $^ -o $@ $(ALL_LDFLAGS)
$(BIN)/$(DISTNAME)_%-ladspa.o: crap/%-ladspa.c $(HEADERS) include/ladspa.h
@echo ' CC '$@
@$(CC) -c $(ALL_CFLAGS) $(LADSPA_FLAG) $(CPPFLAGS) $< -o $@
$(BIN)/$(DISTNAME)_%-ladspa.o: crap/%-ladspa.cpp $(HEADERS) include/ladspa.hpp
@echo ' CXX '$@
@$(CXX) -c $(ALL_CXXFLAGS) $(LADSPA_FLAG) $(CPPFLAGS) $< -o $@
$(BIN)/$(DISTNAME)_%-vst.o: crap/%-vst.cpp $(HEADERS)
@echo ' CXX '$@
@$(CXX) -c $(ALL_CXXFLAGS) $(VST_FLAGS) $(CPPFLAGS) $< -o $@
crap/%-ladspa.c: crap/%.h template/ladspa.c util/generate
crap/%-ladspa.cpp: crap/%.hpp template/ladspa.cpp util/generate
@echo ' GEN '$@
@util/generate $(notdir $<) $@ template/ladspa.c
@util/generate $(notdir $<) $@ template/ladspa.cpp
crap/%-vst.cpp: crap/%.h template/vst.cpp util/generate
crap/%-vst.cpp: crap/%.hpp template/vst.cpp util/generate
@echo ' GEN '$@
@util/generate $(notdir $<) $@ template/vst.cpp
@ -138,13 +132,13 @@ $(VST_OBJ): $(BIN)/%.o: $(VST_CPP_DIR)/%.cpp
@echo ' CXX '$@
@$(CXX) -c $(ALL_CXXFLAGS) $(VST_FLAGS) $(CPPFLAGS) $< -o $@
$(BIN)/bench: util/bench.c
@echo ' CCLD '$@
@$(CC) $(ALL_CFLAGS) $(LADSPA_FLAGS) $< -o $@ $(ALL_LDFLAGS) -rdynamic -ldl
$(BIN)/bench: util/bench.cpp
@echo ' CXXLD '$@
@$(CXX) $(ALL_CXXFLAGS) $(LADSPA_FLAGS) $< -o $@ $(ALL_LDFLAGS) -rdynamic -ldl
$(BIN)/design: util/design.c
@echo ' CCLD '$@
@$(CC) $(ALL_CFLAGS) $< -o $@ $(ALL_LDFLAGS)
$(BIN)/design: util/design.cpp
@echo ' CXXLD '$@
@$(CXX) $(ALL_CXXFLAGS) $< -o $@ $(ALL_LDFLAGS)
clean:
rm -f $(ALL)

View file

@ -1,4 +1,4 @@
#include "util.h"
#include "util.hpp"
typedef unsigned long ulong;

View file

@ -12,8 +12,8 @@
#define BLOCK_SIZE 256
#include "util.h"
#include "param.h"
#include "util.hpp"
#include "param.hpp"
typedef struct {
biquad filters[2][BANDS];
@ -25,14 +25,14 @@ process_double(personal *data,
double *in_L, double *in_R,
double *out_L, double *out_R,
unsigned long count)
#include "process_biquads.h"
#include "process_biquads.hpp"
static void
process(personal *data,
float *in_L, float *in_R,
float *out_L, float *out_R,
ulong count)
#include "process_biquads.h"
#include "process_biquads.hpp"
INNER void
resume(personal *data)

View file

@ -9,7 +9,7 @@
#define BLOCK_SIZE 256
#include "util.h"
#include "util.hpp"
#define BANDS 12
typedef struct {
@ -21,14 +21,14 @@ process_double(personal *data,
double *in_L, double *in_R,
double *out_L, double *out_R,
unsigned long count)
#include "process_biquads.h"
#include "process_biquads.hpp"
static void
process(personal *data,
float *in_L, float *in_R,
float *out_L, float *out_R,
ulong count)
#include "process_biquads.h"
#include "process_biquads.hpp"
INNER void
construct(personal *data)

View file

@ -9,7 +9,7 @@
#define BLOCK_SIZE 256
#include "util.h"
#include "util.hpp"
#define BANDS 16
typedef struct {
@ -21,14 +21,14 @@ process_double(personal *data,
double *in_L, double *in_R,
double *out_L, double *out_R,
unsigned long count)
#include "process_biquads.h"
#include "process_biquads.hpp"
static void
process(personal *data,
float *in_L, float *in_R,
float *out_L, float *out_R,
ulong count)
#include "process_biquads.h"
#include "process_biquads.hpp"
INNER void
construct(personal *data)

View file

@ -11,7 +11,7 @@
#define BLOCK_SIZE 256
#include "util.h"
#include "util.hpp"
#define BANDS 16
typedef struct {
@ -23,14 +23,14 @@ process_double(personal *data,
double *in_L, double *in_R,
double *out_L, double *out_R,
unsigned long count)
#include "process_svfs.h"
#include "process_svfs.hpp"
static void
process(personal *data,
float *in_L, float *in_R,
float *out_L, float *out_R,
ulong count)
#include "process_svfs.h"
#include "process_svfs.hpp"
INNER void
construct(personal *data)

View file

@ -21,9 +21,9 @@ https://aaltodoc.aalto.fi/bitstream/handle/123456789/14420/article6.pdf
#include <stdio.h>
#include <string.h>
#include "util.h"
#include "param.h"
#include "os2piir_stereo.h"
#include "util.hpp"
#include "param.hpp"
#include "os2piir_stereo.hpp"
#define VT 0.026
#define N 4
@ -102,14 +102,14 @@ process_double(personal *data,
double *in_L, double *in_R,
double *out_L, double *out_R,
unsigned long count)
#include "process_mugi4.h"
#include "process_mugi4.hpp"
static void
process(personal *data,
float *in_L, float *in_R,
float *out_L, float *out_R,
ulong count)
#include "process_mugi4.h"
#include "process_mugi4.hpp"
INNER void
construct(personal *data)

View file

@ -1,4 +1,4 @@
#include "util.h"
#include "util.hpp"
#define ID 0xEC57A71C
#define LABEL "crap_noise"

View file

@ -12,9 +12,9 @@
#define BLOCK_SIZE 256
#define FULL_SIZE (BLOCK_SIZE*OVERSAMPLING)
#include "util.h"
#include "param.h"
#include "os2piir_stereo.h"
#include "util.hpp"
#include "param.hpp"
#include "os2piir_stereo.hpp"
typedef struct {
double desired, actual, speed;
@ -63,14 +63,14 @@ process_double(personal *data,
double *in_L, double *in_R,
double *out_L, double *out_R,
ulong count)
#include "process_nonlinear.h"
#include "process_nonlinear.hpp"
static void
process(personal *data,
float *in_L, float *in_R,
float *out_L, float *out_R,
ulong count)
#include "process_nonlinear.h"
#include "process_nonlinear.hpp"
INNER void
resume(personal *data)

View file

@ -90,16 +90,16 @@ biquad_run_block_stereo(biquad *bq_L, biquad *bq_R,
{
v2df b0, b1, b2, a1, a2, x1, x2, y1, y2;
b0 = (v2df){bq_L->b0, bq_L->b0};
b1 = (v2df){bq_L->b1, bq_L->b1};
b2 = (v2df){bq_L->b2, bq_L->b2};
a1 = (v2df){bq_L->a1, bq_L->a1};
a2 = (v2df){bq_L->a2, bq_L->a2};
b0 = V(bq_L->b0);
b1 = V(bq_L->b1);
b2 = V(bq_L->b2);
a1 = V(bq_L->a1);
a2 = V(bq_L->a2);
x1 = (v2df){bq_L->x1, bq_R->x1};
x2 = (v2df){bq_L->x2, bq_R->x2};
y1 = (v2df){bq_L->y1, bq_R->y1};
y2 = (v2df){bq_L->y2, bq_R->y2};
x1 = V2(bq_L->x1, bq_R->x1);
x2 = V2(bq_L->x2, bq_R->x2);
y1 = V2(bq_L->y1, bq_R->y1);
y2 = V2(bq_L->y2, bq_R->y2);
for (ulong i = 0; i < count; i++) {
v2df x = buf[i];

View file

@ -15,14 +15,18 @@ typedef double v2df __attribute__((vector_size(16), aligned(16)));
typedef float v2sf __attribute__((vector_size(8), aligned(8)));
typedef float v4sf __attribute__((vector_size(16), aligned(16)));
#ifndef FORCE_SINGLE
#ifdef FORCE_SINGLE
#define v2dt float
#define v2df v2sf
#else
#define v2dt double
#endif
typedef float v4sf __attribute__((vector_size(16), aligned(16)));
typedef unsigned long ulong; // __attribute((aligned(16)));
#define V(x) (v2df){(x), (x)}
#define V(x) (v2df){(v2dt) (x), (v2dt) (x)}
#define V2(x, y) (v2df){(v2dt) (x), (v2dt) (y)}
INNER void
disable_denormals()
@ -67,5 +71,5 @@ typedef enum {
FILT_GAIN
} filter_t;
#include "biquad.h"
#include "svf.h"
#include "biquad.hpp"
#include "svf.hpp"

View file

@ -1,5 +1,5 @@
#include <stdlib.h>
#include "ladspa.h"
#include "ladspa.hpp"
//#INCLUDE

View file

@ -6,8 +6,8 @@
#include <math.h>
#include "dlfcn.h"
#include "ladspa.h"
#include "util.h"
#include "ladspa.hpp"
#include "util.hpp"
#define BLOCK_SIZE 2048
@ -29,7 +29,8 @@ load_ladspa(char *path)
assert(plug);
atexit(cleanup);
LADSPA_Descriptor_Function df = dlsym(plug, "ladspa_descriptor");
LADSPA_Descriptor_Function df;
df = (typeof(df)) dlsym(plug, "ladspa_descriptor");
assert(df);
const LADSPA_Descriptor *d = df(0);
@ -99,14 +100,15 @@ main(int argc, char **argv)
if (LADSPA_IS_PORT_AUDIO(d->PortDescriptors[i]))
audio_count++;
audio_buffer = calloc(audio_count*BLOCK_SIZE, sizeof(float));
audio_buffer = (typeof(audio_buffer)) calloc(audio_count*BLOCK_SIZE, sizeof(float));
int a = 0;
for (int i = 0; i < d->PortCount; i++) {
if (LADSPA_IS_PORT_AUDIO(d->PortDescriptors[i])) {
d->connect_port(h, i, audio_buffer + a++*BLOCK_SIZE);
} else {
float *x = alloca(sizeof(float));
float *x;
x = (typeof(x)) alloca(sizeof(float));
*x = get_default(d->PortRangeHints[i]);
d->connect_port(h, i, x);
}

View file

@ -3,7 +3,7 @@
#include <math.h>
#include <errno.h>
#include "util.h"
#include "util.hpp"
void
usage()