From aa77c87c288eeba75b4893263f744dd03a0de0a0 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 10 Jun 2015 23:53:13 -0700 Subject: [PATCH] further tomfoolery --- Makefile | 4 ++-- crap/eq.hpp | 2 -- crap/eq_const.hpp | 2 -- crap/eq_const_T420.hpp | 2 -- crap/eq_const_T420_svf.hpp | 2 -- crap/mugi4.hpp | 7 +++---- crap/tube.hpp | 7 +++---- include/Buffer2.hpp | 8 ++++---- include/Buffer4.hpp | 16 ++++++++-------- include/Dumber.hpp | 1 - include/svf.hpp | 16 ++++++++-------- include/util.hpp | 4 ++++ include/vectors.hpp | 10 ++++++++++ util/bench.cpp | 10 +++++----- 14 files changed, 47 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index 76e9c89..d752f3c 100644 --- a/Makefile +++ b/Makefile @@ -94,11 +94,11 @@ $(UTILS): %: $(BIN)/% $(BIN)/%.exe: $(BIN)/% @echo ' OBJCOPY '$@ - @$(OBJCOPY) $< $@ + @$(OBJCOPY) -S $< $@ $(BIN)/%.dll: $(BIN)/%.so @echo ' OBJCOPY '$@ - @$(OBJCOPY) $< $@ + @$(OBJCOPY) -S $< $@ $(BIN)/ladspa/%.so: $(BIN)/ladspa/%.o @echo ' CXXLD '$@ diff --git a/crap/eq.hpp b/crap/eq.hpp index caa504b..89f3438 100644 --- a/crap/eq.hpp +++ b/crap/eq.hpp @@ -1,5 +1,3 @@ -#define BLOCK_SIZE 256 - #include #include diff --git a/crap/eq_const.hpp b/crap/eq_const.hpp index 86e9df2..9ae41e9 100644 --- a/crap/eq_const.hpp +++ b/crap/eq_const.hpp @@ -1,5 +1,3 @@ -#define BLOCK_SIZE 256 - #include #include "util.hpp" diff --git a/crap/eq_const_T420.hpp b/crap/eq_const_T420.hpp index 4659848..690ba75 100644 --- a/crap/eq_const_T420.hpp +++ b/crap/eq_const_T420.hpp @@ -1,5 +1,3 @@ -#define BLOCK_SIZE 256 - #include #include "util.hpp" diff --git a/crap/eq_const_T420_svf.hpp b/crap/eq_const_T420_svf.hpp index 56cefe2..8a31d10 100644 --- a/crap/eq_const_T420_svf.hpp +++ b/crap/eq_const_T420_svf.hpp @@ -1,5 +1,3 @@ -#define BLOCK_SIZE 256 - #include #include #include diff --git a/crap/mugi4.hpp b/crap/mugi4.hpp index 59890d4..3aa3e4a 100644 --- a/crap/mugi4.hpp +++ b/crap/mugi4.hpp @@ -1,7 +1,3 @@ -#define BLOCK_SIZE 256 -#define OVERSAMPLING 2 -#define FULL_SIZE (BLOCK_SIZE*OVERSAMPLING) - /* an implementation of: S. D Angelo and V. Välimäki. Generalized Moog Ladder Filter: Part II @@ -18,6 +14,9 @@ https://aaltodoc.aalto.fi/bitstream/handle/123456789/14420/article6.pdf #include "Param.hpp" #include "Crap.hpp" #include "os2piir.hpp" + +#define OVERSAMPLING 2 +#define FULL_SIZE (BLOCK_SIZE*OVERSAMPLING) #include "Buffer2OS2.hpp" #define VT 0.026 diff --git a/crap/tube.hpp b/crap/tube.hpp index fc24b61..524d61e 100644 --- a/crap/tube.hpp +++ b/crap/tube.hpp @@ -1,7 +1,3 @@ -#define OVERSAMPLING 2 -#define BLOCK_SIZE 256 -#define FULL_SIZE (BLOCK_SIZE*OVERSAMPLING) - #include #include @@ -9,6 +5,9 @@ #include "Param.hpp" #include "Crap.hpp" #include "os2piir.hpp" + +#define OVERSAMPLING 2 +#define FULL_SIZE (BLOCK_SIZE*OVERSAMPLING) #include "Buffer2OS2.hpp" typedef struct { diff --git a/include/Buffer2.hpp b/include/Buffer2.hpp index 74d2e8f..4dbbcbd 100644 --- a/include/Buffer2.hpp +++ b/include/Buffer2.hpp @@ -16,15 +16,15 @@ struct Buffer2 : public Mixin { rem = count - pos; for (ulong i = 0; i < rem; i++) { - buf[i].v[0] = in_L[i]; - buf[i].v[1] = in_R[i]; + buf[i][0] = in_L[i]; + buf[i][1] = in_R[i]; } process2(buf, rem); for (ulong i = 0; i < rem; i++) { - out_L[i] = buf[i].v[0]; - out_R[i] = buf[i].v[1]; + out_L[i] = buf[i][0]; + out_R[i] = buf[i][1]; } in_L += BLOCK_SIZE; diff --git a/include/Buffer4.hpp b/include/Buffer4.hpp index 6741128..f7f5d42 100644 --- a/include/Buffer4.hpp +++ b/include/Buffer4.hpp @@ -19,19 +19,19 @@ struct Buffer4 : public Mixin { rem = count - pos; for (ulong i = 0, j = 0; i < rem; i += 2, j++) { - buf_L[j].v[0] = in_L[i+0]; - buf_L[j].v[1] = in_L[i+1]; - buf_R[j].v[0] = in_R[i+0]; - buf_R[j].v[1] = in_R[i+1]; + buf_L[j][0] = in_L[i+0]; + buf_L[j][1] = in_L[i+1]; + buf_R[j][0] = in_R[i+0]; + buf_R[j][1] = in_R[i+1]; } process2(buf_L, buf_R, rem); for (ulong i = 0, j = 0; i < rem; i += 2, j++) { - out_L[i+0] = buf_L[j].v[0]; - out_L[i+1] = buf_L[j].v[1]; - out_R[i+0] = buf_R[j].v[0]; - out_R[i+1] = buf_R[j].v[1]; + out_L[i+0] = buf_L[j][0]; + out_L[i+1] = buf_L[j][1]; + out_R[i+0] = buf_R[j][0]; + out_R[i+1] = buf_R[j][1]; } in_L += BLOCK_SIZE; diff --git a/include/Dumber.hpp b/include/Dumber.hpp index ed78cea..c70c996 100644 --- a/include/Dumber.hpp +++ b/include/Dumber.hpp @@ -83,4 +83,3 @@ struct Dumber : public DumberBase { Dumber(DumberBase v2) : DumberBase(v2) {} }; - diff --git a/include/svf.hpp b/include/svf.hpp index 2ce9a18..6d19ade 100644 --- a/include/svf.hpp +++ b/include/svf.hpp @@ -123,18 +123,18 @@ svf_run_block_mat(svf_matrix *RESTRICT mat, T *RESTRICT buf, ulong count) T t1, t2, t3, t4; T memory = mat->memory; for (ulong i = 0; i < count/2; i++) { - memory.v[0] = buf[i].v[0]; - memory.v[1] = buf[i].v[1]; + memory[0] = buf[i][0]; + memory[1] = buf[i][1]; t1 = mat->a*memory; t2 = mat->b*memory; t3 = mat->c*memory; t4 = mat->d*memory; - memory.v[0] = t1.v[0] + t1.v[1] + t1.v[2] + t1.v[3]; - memory.v[1] = t2.v[0] + t2.v[1] + t2.v[2] + t2.v[3]; - memory.v[2] = t3.v[0] + t3.v[1] + t3.v[2] + t3.v[3]; - memory.v[3] = t4.v[0] + t4.v[1] + t4.v[2] + t4.v[3]; - buf[i].v[0] = memory.v[0]; - buf[i].v[1] = memory.v[1]; + memory[0] = t1[0] + t1[1] + t1[2] + t1[3]; + memory[1] = t2[0] + t2[1] + t2[2] + t2[3]; + memory[2] = t3[0] + t3[1] + t3[2] + t3[3]; + memory[3] = t4[0] + t4[1] + t4[2] + t4[3]; + buf[i][0] = memory[0]; + buf[i][1] = memory[1]; } mat->memory = memory; } diff --git a/include/util.hpp b/include/util.hpp index b9330d8..ded76cb 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -14,6 +14,10 @@ typedef unsigned long ulong; // __attribute((aligned(16))); +#ifndef BLOCK_SIZE +#define BLOCK_SIZE 256 +#endif + #include "Dumber.hpp" #include "vectors.hpp" diff --git a/include/vectors.hpp b/include/vectors.hpp index a8e9c13..4ea63bc 100644 --- a/include/vectors.hpp +++ b/include/vectors.hpp @@ -73,6 +73,16 @@ struct Dumber<_v4sf> : public DumberBase<_v4sf> { TEMPLATE inline Dumber(T x) { v = (_v4sf){float(x), float(x), float(x), float(x)}; } + + inline float & + operator[](int index) { + return ((float *)&v)[index]; + } + + inline const float & + operator[](int index) const { + return ((float *)&v)[index]; + } }; typedef Dumber<_v2df> v2df; diff --git a/util/bench.cpp b/util/bench.cpp index 3728ea3..423a737 100644 --- a/util/bench.cpp +++ b/util/bench.cpp @@ -9,7 +9,7 @@ #include "ladspa.hpp" #include "util.hpp" -#define BLOCK_SIZE 2048 +#define BENCH_BLOCK 2048 void *plug = NULL; static float *audio_buffer; @@ -109,12 +109,12 @@ main(int argc, char **argv) if (LADSPA_IS_PORT_AUDIO(d->PortDescriptors[i])) audio_count++; - audio_buffer = (decltype(audio_buffer)) calloc(audio_count*BLOCK_SIZE, sizeof(float)); + audio_buffer = (decltype(audio_buffer)) calloc(audio_count*BENCH_BLOCK, 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); + d->connect_port(h, i, audio_buffer + a++*BENCH_BLOCK); } else { float *x; x = (decltype(x)) alloca(sizeof(float)); @@ -124,12 +124,12 @@ main(int argc, char **argv) } unsigned int mirand = time(NULL); - for (int i = 0; i < audio_count*BLOCK_SIZE; i++) + for (int i = 0; i < audio_count*BENCH_BLOCK; i++) audio_buffer[i] = whitenoise(mirand); if (d->activate) d->activate(h); for (int i = 0; i < 64*64*8; i++) - d->run(h, BLOCK_SIZE); + d->run(h, BENCH_BLOCK); if (d->deactivate) d->deactivate(h); d->cleanup(h);