From 6e0b494191107f1e5b3afa6981825d314f800a50 Mon Sep 17 00:00:00 2001 From: Manuel Virgilio Date: Tue, 14 Nov 2023 22:42:28 +0100 Subject: [PATCH] added cpu optimization detection and avx optimization --- Makefile | 1 + common/optimization/avx.cpp | 72 ++++++++++++++++++++ common/optimization/avx.hpp | 13 ++++ common/optimization/default.cpp | 26 +++++++ common/optimization/default.hpp | 14 ++++ common/optimization/optimization.cpp | 65 ++++++++++++++++++ common/optimization/optimization.hpp | 13 ++++ plugins/dragonfly-early-reflections/DSP.cpp | 16 ++--- plugins/dragonfly-early-reflections/DSP.hpp | 3 + plugins/dragonfly-early-reflections/Makefile | 7 +- plugins/dragonfly-hall-reverb/DSP.cpp | 34 ++++----- plugins/dragonfly-hall-reverb/DSP.hpp | 3 + plugins/dragonfly-hall-reverb/Makefile | 7 +- plugins/dragonfly-plate-reverb/DSP.cpp | 16 ++--- plugins/dragonfly-plate-reverb/DSP.hpp | 3 + plugins/dragonfly-plate-reverb/Makefile | 7 +- plugins/dragonfly-room-reverb/DSP.cpp | 34 ++++----- plugins/dragonfly-room-reverb/DSP.hpp | 3 + plugins/dragonfly-room-reverb/Makefile | 7 +- 19 files changed, 286 insertions(+), 58 deletions(-) create mode 100644 common/optimization/avx.cpp create mode 100644 common/optimization/avx.hpp create mode 100644 common/optimization/default.cpp create mode 100644 common/optimization/default.hpp create mode 100644 common/optimization/optimization.cpp create mode 100644 common/optimization/optimization.hpp diff --git a/Makefile b/Makefile index 8694093..272c253 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ clean: rm -f common/*.d common/*.o rm -f common/freeverb/*.d common/freeverb/*.o rm -f common/kiss_fft/*.d common/kiss_fft/*.o + rm -f common/optimization/*.d common/optimization/*.o rm -f dpf/utils/lv2_ttl_generator.d # -------------------------------------------------------------- diff --git a/common/optimization/avx.cpp b/common/optimization/avx.cpp new file mode 100644 index 0000000..539097d --- /dev/null +++ b/common/optimization/avx.cpp @@ -0,0 +1,72 @@ +#include "avx.hpp" + +#include + +void VSUM32FLOAT_avx(const float* op1, const float* op2, float* result, int32_t length) +{ + float extracted[8]; + int32_t processed = 0; + + while ( processed < length ) + { + int processing = ((length - processed) % 8) + 1; + + const __m256 mm_op1 = _mm256_loadu_ps(op1 + processed); + const __m256 mm_op2 = _mm256_loadu_ps(op2 + processed ); + __m256 mm_res = _mm256_add_ps(mm_op1, mm_op2); + + _mm256_storeu_ps(extracted, mm_res); + for ( int i = 0 ; i < processing ; i++ ) + { + result[processed + i] = extracted[i]; + } + + processed += processing; + } +} + +void VMUL32FLOAT_avx(const float* op1, const float* op2, float* result, int32_t length) +{ + float extracted[8]; + int32_t processed = 0; + + while ( processed < length ) + { + int processing = ((length - processed) % 8) + 1; + const __m256 mm_op1 = _mm256_loadu_ps(op1 + processed); + const __m256 mm_op2 = _mm256_loadu_ps(op2 + processed); + __m256 mm_res = _mm256_mul_ps(mm_op1, mm_op2); + + _mm256_storeu_ps(extracted, mm_res); + for ( int i = 0 ; i < processing ; i++ ) + { + result[processed + i] = extracted[i]; + } + + processed += processing; + } +} + +void VMUL32FLOAT_V_avx(const float value, const float* vec, float* result, int32_t length) +{ + float extracted[8]; + const __m256 mm_op1 = _mm256_set1_ps(value); + + int processed = 0; + while ( processed < length ) + { + int processing = ((length - processed) % 8) + 1; + + const __m256 mm_op2 = _mm256_loadu_ps(vec + processed); + __m256 mm_res = _mm256_mul_ps(mm_op1, mm_op2); + + _mm256_storeu_ps(extracted, mm_res); + for ( int i = 0 ; i < processing ; i++ ) + { + result[processed + i] = extracted[i]; + } + + processed += processing; + } +} + diff --git a/common/optimization/avx.hpp b/common/optimization/avx.hpp new file mode 100644 index 0000000..6b0d1e3 --- /dev/null +++ b/common/optimization/avx.hpp @@ -0,0 +1,13 @@ + +#ifndef OPTIMIZATION_AVX_H_INCLUDED +#define OPTIMIZATION_AVX_H_INCLUDED + +#include + +void VSUM32FLOAT_avx(const float* op1, const float* op2, float* result, int32_t length); + +void VMUL32FLOAT_avx(const float* op1, const float* op2, float* result, int32_t length); + +void VMUL32FLOAT_V_avx(const float value, const float* vec, float* result, int32_t length); + +#endif \ No newline at end of file diff --git a/common/optimization/default.cpp b/common/optimization/default.cpp new file mode 100644 index 0000000..b12033f --- /dev/null +++ b/common/optimization/default.cpp @@ -0,0 +1,26 @@ +#include "default.hpp" + +void VSUM32FLOAT_default(const float* op1, const float* op2, float* result, int32_t length) +{ + for ( int32_t i = 0 ; i < length ; i++ ) + { + result[i] = op1[i] + op2[i]; + } +} + +void VMUL32FLOAT_default(const float* op1, const float* op2, float* result, int32_t length) +{ + for ( int32_t i = 0 ; i < length ; i++ ) + { + result[i] = op1[i] * op2[i]; + } +} + +void VMUL32FLOAT_V_default(const float value, const float* vec, float* result, int32_t length) +{ + for ( int32_t i = 0 ; i < length ; i++ ) + { + result[i] = value * vec[i]; + } +} + diff --git a/common/optimization/default.hpp b/common/optimization/default.hpp new file mode 100644 index 0000000..ebdd7a8 --- /dev/null +++ b/common/optimization/default.hpp @@ -0,0 +1,14 @@ + +#ifndef OPTIMIZATION_DEFAULT_H_INCLUDED +#define OPTIMIZATION_DEFAULT_H_INCLUDED + +#include + +void VSUM32FLOAT_default(const float* op1, const float* op2, float* result, int32_t length); + +void VMUL32FLOAT_default(const float* op1, const float* op2, float* result, int32_t length); + +void VMUL32FLOAT_V_default(const float value, const float* vec, float* result, int32_t length); + + +#endif \ No newline at end of file diff --git a/common/optimization/optimization.cpp b/common/optimization/optimization.cpp new file mode 100644 index 0000000..b6066f9 --- /dev/null +++ b/common/optimization/optimization.cpp @@ -0,0 +1,65 @@ + +#include "optimization.hpp" +#include + +#include "default.hpp" +#include "avx.hpp" + +typedef struct +{ + void (*VSUM32FLOAT)(const float* op1, const float* op2, float* result, int32_t length); + void (*VMUL32FLOAT)(const float* op1, const float* op2, float* result, int32_t length); + void (*VMUL32FLOAT_V)(const float value, const float* vec, float* result, int32_t length); +} _CpuOptimization; + +int8_t OptimizationInitialized = 0; +_CpuOptimization CpuOptimization; + +void SetupOptimization() +{ + __builtin_cpu_init(); + if ( __builtin_cpu_supports("avx") ) + { + CpuOptimization.VSUM32FLOAT = VSUM32FLOAT_avx; + CpuOptimization.VMUL32FLOAT = VMUL32FLOAT_avx; + CpuOptimization.VMUL32FLOAT_V = VMUL32FLOAT_V_avx; + } + else + { + CpuOptimization.VSUM32FLOAT = VSUM32FLOAT_default; + CpuOptimization.VMUL32FLOAT = VMUL32FLOAT_default; + CpuOptimization.VMUL32FLOAT_V = VMUL32FLOAT_V_default; + } + OptimizationInitialized = 1; +} + + +void VSUM32FLOAT(const float* op1, const float* op2, float* result, int32_t length) +{ + if (!OptimizationInitialized) + { + SetupOptimization(); + } + + CpuOptimization.VSUM32FLOAT(op1,op2,result,length); +} + +void VMUL32FLOAT(const float* op1, const float* op2, float* result, int32_t length) +{ + if (!OptimizationInitialized) + { + SetupOptimization(); + } + + CpuOptimization.VMUL32FLOAT(op1,op2,result,length); +} + +void VMUL32FLOAT_V(const float value, const float* vec, float* result, int32_t length) +{ + if (!OptimizationInitialized) + { + SetupOptimization(); + } + + CpuOptimization.VMUL32FLOAT_V(value,vec,result,length); +} \ No newline at end of file diff --git a/common/optimization/optimization.hpp b/common/optimization/optimization.hpp new file mode 100644 index 0000000..a3f1a89 --- /dev/null +++ b/common/optimization/optimization.hpp @@ -0,0 +1,13 @@ + +#ifndef OPTIMIZATION_H_INCLUDED +#define OPTIMIZATION_H_INCLUDED + +#include + +void VSUM32FLOAT(const float* op1, const float* op2, float* result, int32_t length); + +void VMUL32FLOAT(const float* op1, const float* op2, float* result, int32_t length); + +void VMUL32FLOAT_V(const float value, const float* vec, float* result, int32_t length); + +#endif \ No newline at end of file diff --git a/plugins/dragonfly-early-reflections/DSP.cpp b/plugins/dragonfly-early-reflections/DSP.cpp index d1f3439..858caa4 100644 --- a/plugins/dragonfly-early-reflections/DSP.cpp +++ b/plugins/dragonfly-early-reflections/DSP.cpp @@ -19,6 +19,7 @@ #include "DistrhoPlugin.hpp" #include "DistrhoPluginInfo.h" #include "extra/ScopedDenormalDisable.hpp" +#include "optimization/optimization.hpp" #include "DSP.hpp" @@ -91,16 +92,13 @@ void DragonflyReverbDSP::run(const float** inputs, float** outputs, uint32_t fra buffer_frames ); - for (uint32_t i = 0; i < buffer_frames; i++) { - outputs[0][offset + i] = - dryLevel * inputs[0][offset + i] + - wetLevel * output_buffer[0][i]; - - outputs[1][offset + i] = - dryLevel * inputs[1][offset + i] + - wetLevel * output_buffer[1][i]; - } + VMUL32FLOAT_V( dryLevel, &inputs[0][offset], dry_buffer, buffer_frames ); + VMUL32FLOAT_V( wetLevel, output_buffer[0], wet_buffer, buffer_frames ); + VSUM32FLOAT(dry_buffer, wet_buffer, &outputs[0][offset], buffer_frames ); + VMUL32FLOAT_V( dryLevel, &inputs[1][offset], dry_buffer, buffer_frames ); + VMUL32FLOAT_V( wetLevel, output_buffer[1], wet_buffer, buffer_frames ); + VSUM32FLOAT(dry_buffer, wet_buffer, &outputs[1][offset], buffer_frames ); } } diff --git a/plugins/dragonfly-early-reflections/DSP.hpp b/plugins/dragonfly-early-reflections/DSP.hpp index 6b43d74..447cf72 100644 --- a/plugins/dragonfly-early-reflections/DSP.hpp +++ b/plugins/dragonfly-early-reflections/DSP.hpp @@ -46,6 +46,9 @@ class DragonflyReverbDSP : public AbstractDSP { float input_buffer[2][BUFFER_SIZE]; float output_buffer[2][BUFFER_SIZE]; + float dry_buffer[BUFFER_SIZE]; + float wet_buffer[BUFFER_SIZE]; + void setInputLPF(float freq); void setInputHPF(float freq); }; diff --git a/plugins/dragonfly-early-reflections/Makefile b/plugins/dragonfly-early-reflections/Makefile index 5b28096..f0c1af3 100644 --- a/plugins/dragonfly-early-reflections/Makefile +++ b/plugins/dragonfly-early-reflections/Makefile @@ -14,7 +14,10 @@ NAME = DragonflyEarlyReflections FILES_COMMON = DSP.cpp \ ../../common/kiss_fft/kiss_fft.c \ - ../../common/kiss_fft/kiss_fftr.c + ../../common/kiss_fft/kiss_fftr.c \ + ../../common/optimization/optimization.cpp \ + ../../common/optimization/default.cpp \ + ../../common/optimization/avx.cpp ifneq ($(SYSTEM_FREEVERB3),true) FILES_COMMON += \ @@ -58,7 +61,7 @@ include ../../dpf/Makefile.plugins.mk # -------------------------------------------------------------- # Build dependencies -BUILD_CXX_FLAGS += -I../../common -DLIBFV3_FLOAT +BUILD_CXX_FLAGS += -I../../common -DLIBFV3_FLOAT -mavx ifeq ($(SYSTEM_FREEVERB3),true) BUILD_CXX_FLAGS += -DLIBSRATE1 BUILD_CXX_FLAGS += $(shell $(PKG_CONFIG) --cflags freeverb3-3) diff --git a/plugins/dragonfly-hall-reverb/DSP.cpp b/plugins/dragonfly-hall-reverb/DSP.cpp index 3878b12..dcad8c1 100644 --- a/plugins/dragonfly-hall-reverb/DSP.cpp +++ b/plugins/dragonfly-hall-reverb/DSP.cpp @@ -18,6 +18,7 @@ #include "DistrhoPlugin.hpp" #include "DistrhoPluginInfo.h" #include "extra/ScopedDenormalDisable.hpp" +#include "optimization/optimization.hpp" #include "DSP.hpp" @@ -116,10 +117,11 @@ void DragonflyReverbDSP::run(const float** inputs, float** outputs, uint32_t fra early_out_buffer[1], buffer_frames); - for (uint32_t i = 0; i < buffer_frames; i++) { - late_in_buffer[0][i] = early_send * early_out_buffer[0][i] + inputs[0][offset + i]; - late_in_buffer[1][i] = early_send * early_out_buffer[1][i] + inputs[1][offset + i]; - } + VMUL32FLOAT_V(early_send, early_out_buffer[0], early_buffer, buffer_frames); + VSUM32FLOAT(early_buffer, &inputs[0][offset], late_in_buffer[0], buffer_frames ); + + VMUL32FLOAT_V(early_send, early_out_buffer[1], early_buffer, buffer_frames); + VSUM32FLOAT(early_buffer, &inputs[1][offset], late_in_buffer[1], buffer_frames ); late.processreplace( const_cast(late_in_buffer[0]), @@ -128,23 +130,23 @@ void DragonflyReverbDSP::run(const float** inputs, float** outputs, uint32_t fra late_out_buffer[1], buffer_frames); - for (uint32_t i = 0; i < buffer_frames; i++) { - outputs[0][offset + i] = dryLevel * inputs[0][offset + i]; - outputs[1][offset + i] = dryLevel * inputs[1][offset + i]; - } + VMUL32FLOAT_V(dryLevel, &inputs[0][offset], &outputs[0][offset], buffer_frames); + VMUL32FLOAT_V(dryLevel, &inputs[1][offset], &outputs[1][offset], buffer_frames); if( earlyLevel > 0.0 ){ - for (uint32_t i = 0; i < buffer_frames; i++) { - outputs[0][offset + i] += earlyLevel * early_out_buffer[0][i]; - outputs[1][offset + i] += earlyLevel * early_out_buffer[1][i]; - } + VMUL32FLOAT_V(earlyLevel, early_out_buffer[0], early_buffer, buffer_frames); + VSUM32FLOAT(&outputs[0][offset], early_buffer, &outputs[0][offset], buffer_frames); + + VMUL32FLOAT_V(earlyLevel, early_out_buffer[1], early_buffer, buffer_frames); + VSUM32FLOAT(&outputs[1][offset], early_buffer, &outputs[1][offset], buffer_frames); } if( lateLevel > 0.0 ){ - for (uint32_t i = 0; i < buffer_frames; i++) { - outputs[0][offset + i] += lateLevel * late_out_buffer[0][i]; - outputs[1][offset + i] += lateLevel * late_out_buffer[1][i]; - } + VMUL32FLOAT_V(lateLevel, late_out_buffer[0], late_buffer, buffer_frames); + VSUM32FLOAT(&outputs[0][offset], late_buffer, &outputs[0][offset], buffer_frames); + + VMUL32FLOAT_V(lateLevel, late_out_buffer[1], late_buffer, buffer_frames); + VSUM32FLOAT(&outputs[1][offset], late_buffer, &outputs[1][offset], buffer_frames); } } } diff --git a/plugins/dragonfly-hall-reverb/DSP.hpp b/plugins/dragonfly-hall-reverb/DSP.hpp index 1271c6e..72102ab 100644 --- a/plugins/dragonfly-hall-reverb/DSP.hpp +++ b/plugins/dragonfly-hall-reverb/DSP.hpp @@ -47,6 +47,9 @@ class DragonflyReverbDSP : public AbstractDSP { float early_out_buffer[2][BUFFER_SIZE]; float late_in_buffer[2][BUFFER_SIZE]; float late_out_buffer[2][BUFFER_SIZE]; + + float early_buffer[BUFFER_SIZE]; + float late_buffer[BUFFER_SIZE]; }; #endif diff --git a/plugins/dragonfly-hall-reverb/Makefile b/plugins/dragonfly-hall-reverb/Makefile index 8c5c246..9170538 100644 --- a/plugins/dragonfly-hall-reverb/Makefile +++ b/plugins/dragonfly-hall-reverb/Makefile @@ -14,7 +14,10 @@ NAME = DragonflyHallReverb FILES_COMMON = DSP.cpp \ ../../common/kiss_fft/kiss_fft.c \ - ../../common/kiss_fft/kiss_fftr.c + ../../common/kiss_fft/kiss_fftr.c \ + ../../common/optimization/optimization.cpp \ + ../../common/optimization/default.cpp \ + ../../common/optimization/avx.cpp ifneq ($(SYSTEM_FREEVERB3),true) FILES_COMMON += \ @@ -59,7 +62,7 @@ include ../../dpf/Makefile.plugins.mk # -------------------------------------------------------------- # Build dependencies -BUILD_CXX_FLAGS += -I../../common -DLIBFV3_FLOAT +BUILD_CXX_FLAGS += -I../../common -DLIBFV3_FLOAT -mavx ifeq ($(SYSTEM_FREEVERB3),true) BUILD_CXX_FLAGS += -DLIBSRATE1 BUILD_CXX_FLAGS += $(shell $(PKG_CONFIG) --cflags freeverb3-3) diff --git a/plugins/dragonfly-plate-reverb/DSP.cpp b/plugins/dragonfly-plate-reverb/DSP.cpp index 375cd39..3a32418 100644 --- a/plugins/dragonfly-plate-reverb/DSP.cpp +++ b/plugins/dragonfly-plate-reverb/DSP.cpp @@ -19,6 +19,7 @@ #include "DistrhoPlugin.hpp" #include "DistrhoPluginInfo.h" #include "extra/ScopedDenormalDisable.hpp" +#include "optimization/optimization.hpp" #include "DSP.hpp" @@ -245,16 +246,13 @@ void DragonflyReverbDSP::run(const float** inputs, float** outputs, uint32_t fra buffer_frames ); - for (uint32_t i = 0; i < buffer_frames; i++) { - outputs[0][offset + i] = - dryLevel * inputs[0][offset + i] + - wetLevel * output_buffer[0][i]; - - outputs[1][offset + i] = - dryLevel * inputs[1][offset + i] + - wetLevel * output_buffer[1][i]; - } + VMUL32FLOAT_V( dryLevel, &inputs[0][offset], dry_buffer, buffer_frames); + VMUL32FLOAT_V( wetLevel, output_buffer[0], wet_buffer, buffer_frames); + VSUM32FLOAT(dry_buffer, wet_buffer, &outputs[0][offset], buffer_frames); + VMUL32FLOAT_V( dryLevel, &inputs[1][offset], dry_buffer, buffer_frames); + VMUL32FLOAT_V( wetLevel, output_buffer[1], wet_buffer, buffer_frames); + VSUM32FLOAT(dry_buffer, wet_buffer, &outputs[1][offset], buffer_frames); } } diff --git a/plugins/dragonfly-plate-reverb/DSP.hpp b/plugins/dragonfly-plate-reverb/DSP.hpp index 8907af0..da40d82 100644 --- a/plugins/dragonfly-plate-reverb/DSP.hpp +++ b/plugins/dragonfly-plate-reverb/DSP.hpp @@ -79,6 +79,9 @@ class DragonflyReverbDSP : public AbstractDSP { float filtered_input_buffer[2][BUFFER_SIZE]; float output_buffer[2][BUFFER_SIZE]; + float dry_buffer[BUFFER_SIZE]; + float wet_buffer[BUFFER_SIZE]; + void setInputLPF(float freq); void setInputHPF(float freq); }; diff --git a/plugins/dragonfly-plate-reverb/Makefile b/plugins/dragonfly-plate-reverb/Makefile index 9b12f9c..bddfe0e 100644 --- a/plugins/dragonfly-plate-reverb/Makefile +++ b/plugins/dragonfly-plate-reverb/Makefile @@ -14,7 +14,10 @@ NAME = DragonflyPlateReverb FILES_COMMON = DSP.cpp \ ../../common/kiss_fft/kiss_fft.c \ - ../../common/kiss_fft/kiss_fftr.c + ../../common/kiss_fft/kiss_fftr.c \ + ../../common/optimization/optimization.cpp \ + ../../common/optimization/default.cpp \ + ../../common/optimization/avx.cpp ifneq ($(SYSTEM_FREEVERB3),true) FILES_COMMON += \ @@ -59,7 +62,7 @@ include ../../dpf/Makefile.plugins.mk # -------------------------------------------------------------- # Build dependencies -BUILD_CXX_FLAGS += -I../../common -DLIBFV3_FLOAT +BUILD_CXX_FLAGS += -I../../common -DLIBFV3_FLOAT -mavx ifeq ($(SYSTEM_FREEVERB3),true) BUILD_CXX_FLAGS += -DLIBSRATE1 BUILD_CXX_FLAGS += $(shell $(PKG_CONFIG) --cflags freeverb3-3) diff --git a/plugins/dragonfly-room-reverb/DSP.cpp b/plugins/dragonfly-room-reverb/DSP.cpp index c99e0b6..8c39e5e 100644 --- a/plugins/dragonfly-room-reverb/DSP.cpp +++ b/plugins/dragonfly-room-reverb/DSP.cpp @@ -19,6 +19,7 @@ #include "DistrhoPlugin.hpp" #include "DistrhoPluginInfo.h" #include "extra/ScopedDenormalDisable.hpp" +#include "optimization/optimization.hpp" #include "DSP.hpp" @@ -130,10 +131,11 @@ void DragonflyReverbDSP::run(const float** inputs, float** outputs, uint32_t fra early_out_buffer[1], buffer_frames); - for (uint32_t i = 0; i < buffer_frames; i++) { - late_in_buffer[0][i] = early_send * early_out_buffer[0][i] + filtered_input_buffer[0][i]; - late_in_buffer[1][i] = early_send * early_out_buffer[1][i] + filtered_input_buffer[1][i]; - } + VMUL32FLOAT_V(early_send, early_out_buffer[0], late_buffer, buffer_frames); + VSUM32FLOAT(late_buffer, filtered_input_buffer[0], late_in_buffer[0], buffer_frames); + + VMUL32FLOAT_V(early_send, early_out_buffer[1], late_buffer, buffer_frames); + VSUM32FLOAT(late_buffer, filtered_input_buffer[1], late_in_buffer[1], buffer_frames); late.processreplace( const_cast(late_in_buffer[0]), @@ -142,23 +144,23 @@ void DragonflyReverbDSP::run(const float** inputs, float** outputs, uint32_t fra late_out_buffer[1], buffer_frames); - for (uint32_t i = 0; i < buffer_frames; i++) { - outputs[0][offset + i] = dryLevel * inputs[0][offset + i]; - outputs[1][offset + i] = dryLevel * inputs[1][offset + i]; - } + VMUL32FLOAT_V(dryLevel, &inputs[0][offset], &outputs[0][offset], buffer_frames); + VMUL32FLOAT_V(dryLevel, &inputs[1][offset], &outputs[1][offset], buffer_frames); if( earlyLevel > 0.0 ){ - for (uint32_t i = 0; i < buffer_frames; i++) { - outputs[0][offset + i] += earlyLevel * early_out_buffer[0][i]; - outputs[1][offset + i] += earlyLevel * early_out_buffer[1][i]; - } + VMUL32FLOAT_V(earlyLevel, early_out_buffer[0], early_buffer, buffer_frames); + VSUM32FLOAT(early_buffer, &outputs[0][offset], &outputs[0][offset], buffer_frames); + + VMUL32FLOAT_V(earlyLevel, early_out_buffer[1], early_buffer, buffer_frames); + VSUM32FLOAT(early_buffer, &outputs[1][offset], &outputs[1][offset], buffer_frames); } if( lateLevel > 0.0 ){ - for (uint32_t i = 0; i < buffer_frames; i++) { - outputs[0][offset + i] += lateLevel * late_out_buffer[0][i]; - outputs[1][offset + i] += lateLevel * late_out_buffer[1][i]; - } + VMUL32FLOAT_V(lateLevel, late_out_buffer[0], late_buffer, buffer_frames); + VSUM32FLOAT(late_buffer, &outputs[0][offset], &outputs[0][offset], buffer_frames); + + VMUL32FLOAT_V(lateLevel, late_out_buffer[1], late_buffer, buffer_frames); + VSUM32FLOAT(late_buffer, &outputs[1][offset], &outputs[1][offset], buffer_frames); } } } diff --git a/plugins/dragonfly-room-reverb/DSP.hpp b/plugins/dragonfly-room-reverb/DSP.hpp index b1a7aff..92fe2e2 100644 --- a/plugins/dragonfly-room-reverb/DSP.hpp +++ b/plugins/dragonfly-room-reverb/DSP.hpp @@ -52,6 +52,9 @@ class DragonflyReverbDSP : public AbstractDSP { float late_in_buffer[2][BUFFER_SIZE]; float late_out_buffer[2][BUFFER_SIZE]; + float early_buffer[BUFFER_SIZE]; + float late_buffer[BUFFER_SIZE]; + void setInputLPF(float freq); void setInputHPF(float freq); }; diff --git a/plugins/dragonfly-room-reverb/Makefile b/plugins/dragonfly-room-reverb/Makefile index 0fd6537..24f0631 100644 --- a/plugins/dragonfly-room-reverb/Makefile +++ b/plugins/dragonfly-room-reverb/Makefile @@ -14,7 +14,10 @@ NAME = DragonflyRoomReverb FILES_COMMON = DSP.cpp \ ../../common/kiss_fft/kiss_fft.c \ - ../../common/kiss_fft/kiss_fftr.c + ../../common/kiss_fft/kiss_fftr.c \ + ../../common/optimization/optimization.cpp \ + ../../common/optimization/default.cpp \ + ../../common/optimization/avx.cpp ifneq ($(SYSTEM_FREEVERB3),true) FILES_COMMON += \ @@ -59,7 +62,7 @@ include ../../dpf/Makefile.plugins.mk # -------------------------------------------------------------- # Build dependencies -BUILD_CXX_FLAGS += -I../../common -DLIBFV3_FLOAT +BUILD_CXX_FLAGS += -I../../common -DLIBFV3_FLOAT -mavx ifeq ($(SYSTEM_FREEVERB3),true) BUILD_CXX_FLAGS += -DLIBSRATE1 BUILD_CXX_FLAGS += $(shell $(PKG_CONFIG) --cflags freeverb3-3)