From 39e385f1f97c465f9f4ac4f4ca7704606752f248 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sat, 6 Jun 2015 10:42:14 -0700 Subject: [PATCH] beginning conversion to sepples --- Makefile | 42 ++++++++----------- crap/{delay_test.h => delay_test.hpp} | 2 +- crap/{eq.h => eq.hpp} | 8 ++-- crap/{eq_const.h => eq_const.hpp} | 6 +-- crap/{eq_const_T420.h => eq_const_T420.hpp} | 6 +-- ...const_T420_svf.h => eq_const_T420_svf.hpp} | 6 +-- crap/{mugi4.h => mugi4.hpp} | 10 ++--- crap/{noise.h => noise.hpp} | 2 +- crap/{tube.h => tube.hpp} | 10 ++--- include/{biquad.h => biquad.hpp} | 18 ++++---- include/{ladspa.h => ladspa.hpp} | 0 include/{os2piir.h => os2piir.hpp} | 0 .../{os2piir_stereo.h => os2piir_stereo.hpp} | 0 include/{os6iir.h => os6iir.hpp} | 0 include/{param.h => param.hpp} | 0 include/{process.h => process.hpp} | 0 ...{process_biquads.h => process_biquads.hpp} | 0 .../{process_mugi4.h => process_mugi4.hpp} | 0 ...cess_nonlinear.h => process_nonlinear.hpp} | 0 include/{process_svfs.h => process_svfs.hpp} | 0 include/{svf.h => svf.hpp} | 0 include/{util.h => util.hpp} | 12 ++++-- template/{ladspa.c => ladspa.cpp} | 2 +- util/{bench.c => bench.cpp} | 12 +++--- util/{denorm_test.h => denorm_test.hpp} | 0 util/{design.c => design.cpp} | 2 +- 26 files changed, 69 insertions(+), 69 deletions(-) rename crap/{delay_test.h => delay_test.hpp} (99%) rename crap/{eq.h => eq.hpp} (95%) rename crap/{eq_const.h => eq_const.hpp} (95%) rename crap/{eq_const_T420.h => eq_const_T420.hpp} (96%) rename crap/{eq_const_T420_svf.h => eq_const_T420_svf.hpp} (96%) rename crap/{mugi4.h => mugi4.hpp} (97%) rename crap/{noise.h => noise.hpp} (98%) rename crap/{tube.h => tube.hpp} (94%) rename include/{biquad.h => biquad.hpp} (89%) rename include/{ladspa.h => ladspa.hpp} (100%) rename include/{os2piir.h => os2piir.hpp} (100%) rename include/{os2piir_stereo.h => os2piir_stereo.hpp} (100%) rename include/{os6iir.h => os6iir.hpp} (100%) rename include/{param.h => param.hpp} (100%) rename include/{process.h => process.hpp} (100%) rename include/{process_biquads.h => process_biquads.hpp} (100%) rename include/{process_mugi4.h => process_mugi4.hpp} (100%) rename include/{process_nonlinear.h => process_nonlinear.hpp} (100%) rename include/{process_svfs.h => process_svfs.hpp} (100%) rename include/{svf.h => svf.hpp} (100%) rename include/{util.h => util.hpp} (87%) rename template/{ladspa.c => ladspa.cpp} (99%) rename util/{bench.c => bench.cpp} (90%) rename util/{denorm_test.h => denorm_test.hpp} (100%) rename util/{design.c => design.cpp} (96%) diff --git a/Makefile b/Makefile index 3a12b75..b3cfe85 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/crap/delay_test.h b/crap/delay_test.hpp similarity index 99% rename from crap/delay_test.h rename to crap/delay_test.hpp index d5344e5..74db274 100644 --- a/crap/delay_test.h +++ b/crap/delay_test.hpp @@ -1,4 +1,4 @@ -#include "util.h" +#include "util.hpp" typedef unsigned long ulong; diff --git a/crap/eq.h b/crap/eq.hpp similarity index 95% rename from crap/eq.h rename to crap/eq.hpp index 244063d..1ae08c8 100644 --- a/crap/eq.h +++ b/crap/eq.hpp @@ -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) diff --git a/crap/eq_const.h b/crap/eq_const.hpp similarity index 95% rename from crap/eq_const.h rename to crap/eq_const.hpp index 101ea7c..6f3dff7 100644 --- a/crap/eq_const.h +++ b/crap/eq_const.hpp @@ -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) diff --git a/crap/eq_const_T420.h b/crap/eq_const_T420.hpp similarity index 96% rename from crap/eq_const_T420.h rename to crap/eq_const_T420.hpp index b6b1566..36cc884 100644 --- a/crap/eq_const_T420.h +++ b/crap/eq_const_T420.hpp @@ -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) diff --git a/crap/eq_const_T420_svf.h b/crap/eq_const_T420_svf.hpp similarity index 96% rename from crap/eq_const_T420_svf.h rename to crap/eq_const_T420_svf.hpp index 4f60d18..f963821 100644 --- a/crap/eq_const_T420_svf.h +++ b/crap/eq_const_T420_svf.hpp @@ -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) diff --git a/crap/mugi4.h b/crap/mugi4.hpp similarity index 97% rename from crap/mugi4.h rename to crap/mugi4.hpp index 9b019c9..caf896f 100644 --- a/crap/mugi4.h +++ b/crap/mugi4.hpp @@ -21,9 +21,9 @@ https://aaltodoc.aalto.fi/bitstream/handle/123456789/14420/article6.pdf #include #include -#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) diff --git a/crap/noise.h b/crap/noise.hpp similarity index 98% rename from crap/noise.h rename to crap/noise.hpp index 0116a7d..eb7cdc4 100644 --- a/crap/noise.h +++ b/crap/noise.hpp @@ -1,4 +1,4 @@ -#include "util.h" +#include "util.hpp" #define ID 0xEC57A71C #define LABEL "crap_noise" diff --git a/crap/tube.h b/crap/tube.hpp similarity index 94% rename from crap/tube.h rename to crap/tube.hpp index 7a95e07..6978bf3 100644 --- a/crap/tube.h +++ b/crap/tube.hpp @@ -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) diff --git a/include/biquad.h b/include/biquad.hpp similarity index 89% rename from include/biquad.h rename to include/biquad.hpp index b33fc03..3db87e4 100644 --- a/include/biquad.h +++ b/include/biquad.hpp @@ -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]; diff --git a/include/ladspa.h b/include/ladspa.hpp similarity index 100% rename from include/ladspa.h rename to include/ladspa.hpp diff --git a/include/os2piir.h b/include/os2piir.hpp similarity index 100% rename from include/os2piir.h rename to include/os2piir.hpp diff --git a/include/os2piir_stereo.h b/include/os2piir_stereo.hpp similarity index 100% rename from include/os2piir_stereo.h rename to include/os2piir_stereo.hpp diff --git a/include/os6iir.h b/include/os6iir.hpp similarity index 100% rename from include/os6iir.h rename to include/os6iir.hpp diff --git a/include/param.h b/include/param.hpp similarity index 100% rename from include/param.h rename to include/param.hpp diff --git a/include/process.h b/include/process.hpp similarity index 100% rename from include/process.h rename to include/process.hpp diff --git a/include/process_biquads.h b/include/process_biquads.hpp similarity index 100% rename from include/process_biquads.h rename to include/process_biquads.hpp diff --git a/include/process_mugi4.h b/include/process_mugi4.hpp similarity index 100% rename from include/process_mugi4.h rename to include/process_mugi4.hpp diff --git a/include/process_nonlinear.h b/include/process_nonlinear.hpp similarity index 100% rename from include/process_nonlinear.h rename to include/process_nonlinear.hpp diff --git a/include/process_svfs.h b/include/process_svfs.hpp similarity index 100% rename from include/process_svfs.h rename to include/process_svfs.hpp diff --git a/include/svf.h b/include/svf.hpp similarity index 100% rename from include/svf.h rename to include/svf.hpp diff --git a/include/util.h b/include/util.hpp similarity index 87% rename from include/util.h rename to include/util.hpp index cb1a984..19d8ce6 100644 --- a/include/util.h +++ b/include/util.hpp @@ -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" diff --git a/template/ladspa.c b/template/ladspa.cpp similarity index 99% rename from template/ladspa.c rename to template/ladspa.cpp index b41dc17..7178c50 100644 --- a/template/ladspa.c +++ b/template/ladspa.cpp @@ -1,5 +1,5 @@ #include -#include "ladspa.h" +#include "ladspa.hpp" //#INCLUDE diff --git a/util/bench.c b/util/bench.cpp similarity index 90% rename from util/bench.c rename to util/bench.cpp index 9ce1ad9..f50ee0f 100644 --- a/util/bench.c +++ b/util/bench.cpp @@ -6,8 +6,8 @@ #include #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); } diff --git a/util/denorm_test.h b/util/denorm_test.hpp similarity index 100% rename from util/denorm_test.h rename to util/denorm_test.hpp diff --git a/util/design.c b/util/design.cpp similarity index 96% rename from util/design.c rename to util/design.cpp index e941963..ffed465 100644 --- a/util/design.c +++ b/util/design.cpp @@ -3,7 +3,7 @@ #include #include -#include "util.h" +#include "util.hpp" void usage()