diff --git a/Makefile b/Makefile index 57518d6..4dd6657 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ LADSPA_FLAGS = VST_FLAGS = -Wno-write-strings -Wno-narrowing VST_FLAGS += -I $(VST_SDK_DIR) -DBUILDING_DLL=1 -OPT_FLAGS = -Ofast -march=native -mfpmath=sse +OPT_FLAGS = -Ofast -march=core2 -mfpmath=sse # any possibly produced files besides intermediates ALL = $(SHOBJ) $(PROGRAM) $(BIN)/vstsdk.o $(EXE) $(DLL) diff --git a/README.md b/README.md index f821312..4d4d703 100644 --- a/README.md +++ b/README.md @@ -53,3 +53,4 @@ other targets: * scrap overly-complex makefile for a shell script * support for CPUs without SSE/NEON * don't mix CamelCase with underscores (only done for legacy reasons) +* compressor plugin diff --git a/crap/delay_test.hpp b/crap/delay_test.hpp index 61d7918..2d6bdb3 100644 --- a/crap/delay_test.hpp +++ b/crap/delay_test.hpp @@ -130,3 +130,8 @@ struct Crap_delay_test c_R = c_L; } }; + +constexpr char Crap_delay_test::label[]; +constexpr char Crap_delay_test::name[]; +constexpr char Crap_delay_test::author[]; +constexpr char Crap_delay_test::copyright[]; diff --git a/include/Buffer2.hpp b/include/Buffer2.hpp index 51ba284..74d2e8f 100644 --- a/include/Buffer2.hpp +++ b/include/Buffer2.hpp @@ -1,5 +1,5 @@ template -struct Buffer2 : public virtual Mixin { +struct Buffer2 : public Mixin { virtual void process2(v2df *buf, ulong rem) = 0; @@ -16,15 +16,15 @@ struct Buffer2 : public virtual Mixin { rem = count - pos; for (ulong i = 0; i < rem; i++) { - buf[i][0] = in_L[i]; - buf[i][1] = in_R[i]; + buf[i].v[0] = in_L[i]; + buf[i].v[1] = in_R[i]; } process2(buf, rem); for (ulong i = 0; i < rem; i++) { - out_L[i] = buf[i][0]; - out_R[i] = buf[i][1]; + out_L[i] = buf[i].v[0]; + out_R[i] = buf[i].v[1]; } in_L += BLOCK_SIZE; diff --git a/include/Buffer2OS2.hpp b/include/Buffer2OS2.hpp index a2f9eb7..b9547b2 100644 --- a/include/Buffer2OS2.hpp +++ b/include/Buffer2OS2.hpp @@ -1,5 +1,5 @@ template -struct Buffer2OS2 : public virtual Mixin { +struct Buffer2OS2 : public Mixin { virtual void process2(v2df *buf, ulong rem) = 0; diff --git a/include/Buffer4.hpp b/include/Buffer4.hpp index 0976ee2..6741128 100644 --- a/include/Buffer4.hpp +++ b/include/Buffer4.hpp @@ -1,5 +1,5 @@ template -struct Buffer4 : public virtual Mixin { +struct Buffer4 : public Mixin { virtual void process2(v4sf *buf_L, v4sf *buf_R, ulong rem) = 0; @@ -19,19 +19,19 @@ struct Buffer4 : public virtual Mixin { rem = count - pos; for (ulong i = 0, j = 0; i < rem; i += 2, j++) { - 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]; + 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]; } process2(buf_L, buf_R, rem); for (ulong i = 0, j = 0; i < rem; i += 2, j++) { - 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]; + 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]; } in_L += BLOCK_SIZE; diff --git a/include/Crap.hpp b/include/Crap.hpp index ddee926..093cc24 100644 --- a/include/Crap.hpp +++ b/include/Crap.hpp @@ -2,14 +2,6 @@ struct Crap { virtual inline ~Crap() {} - ulong id; - char *label; - char *name; - char *author; - char *copyright; - ulong bands; - ulong parameters; - virtual void pause() = 0; @@ -39,7 +31,7 @@ struct Crap { }; template -struct AdjustAll : public virtual Mixin { +struct AdjustAll : public Mixin { ulong fs; virtual void @@ -60,7 +52,7 @@ struct AdjustAll : public virtual Mixin { }; template -struct NoParams : public virtual Mixin { +struct NoParams : public Mixin { // etc //void diff --git a/include/svf.hpp b/include/svf.hpp index 6d19ade..2ce9a18 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[0] = buf[i][0]; - memory[1] = buf[i][1]; + memory.v[0] = buf[i].v[0]; + memory.v[1] = buf[i].v[1]; t1 = mat->a*memory; t2 = mat->b*memory; t3 = mat->c*memory; t4 = mat->d*memory; - 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]; + 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]; } mat->memory = memory; } diff --git a/include/vectors.hpp b/include/vectors.hpp index 4ea63bc..a8e9c13 100644 --- a/include/vectors.hpp +++ b/include/vectors.hpp @@ -73,16 +73,6 @@ 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/template/vst.cpp b/template/vst.cpp index 7f7e87b..5d5e7e2 100644 --- a/template/vst.cpp +++ b/template/vst.cpp @@ -39,18 +39,20 @@ struct plugin : public AudioEffectX Param params[CrapPlug::parameters]; - CrapPlug crap; + Crap *crap; }; AudioEffect * createEffectInstance(audioMasterCallback audioMaster) { + // TODO: return new plugin(audioMaster); return new plugin(audioMaster); } plugin::plugin(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, 1, CrapPlug::parameters) { + crap = new CrapPlug(); setNumInputs(2); setNumOutputs(2); setUniqueID(CrapPlug::id); @@ -62,12 +64,13 @@ plugin::plugin(audioMasterCallback audioMaster) plugin::~plugin() { + delete crap; } void plugin::resume() { - crap.resume(); + crap->resume(); AudioEffectX::resume(); } @@ -75,14 +78,14 @@ void plugin::suspend() { AudioEffectX::suspend(); - crap.pause(); + crap->pause(); } void plugin::processReplacing( float **inputs, float **outputs, VstInt32 count) { - crap.process( + crap->process( inputs[0], inputs[1], outputs[0], outputs[1], count); @@ -92,7 +95,7 @@ void plugin::processDoubleReplacing( double **inputs, double **outputs, VstInt32 count) { - crap.process( + crap->process( inputs[0], inputs[1], outputs[0], outputs[1], count); @@ -108,7 +111,7 @@ void plugin::setSampleRate(float fs) { AudioEffectX::setSampleRate(fs); - crap.adjust(params, (unsigned long) fs); + crap->adjust(params, (unsigned long) fs); #ifdef DELAY setInitialDelay(global_delay); #endif @@ -160,7 +163,7 @@ plugin::setParameter(VstInt32 index, float value) { if (index >= CrapPlug::parameters) return; params[index].set(value); - crap.adjust_one(params, index); + crap->adjust_one(params, index); } float