From 8730fb13ef531fca96a165f7f7cf133068683f2d Mon Sep 17 00:00:00 2001 From: luismrguimaraes Date: Thu, 12 Sep 2024 15:51:28 +0100 Subject: [PATCH] add proc interpolation --- .../sst/voice-effects/utilities/GainMatrix.h | 25 ++++++++++--- .../sst/voice-effects/utilities/StereoTool.h | 37 +++++++++++++++---- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/include/sst/voice-effects/utilities/GainMatrix.h b/include/sst/voice-effects/utilities/GainMatrix.h index a471454..ecf9cad 100644 --- a/include/sst/voice-effects/utilities/GainMatrix.h +++ b/include/sst/voice-effects/utilities/GainMatrix.h @@ -79,20 +79,35 @@ template struct GainMatrix : core::VoiceEffectTemplateBase< void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR, float pitch) { + + llLerp.set_target(this->getFloatParam(fpLeftToLeft)); + float ll alignas(16)[VFXConfig::blockSize]; + llLerp.store_block(ll); + + rlLerp.set_target(this->getFloatParam(fpRightToLeft)); + float rl alignas(16)[VFXConfig::blockSize]; + rlLerp.store_block(rl); + + rrLerp.set_target(this->getFloatParam(fpRightToRight)); + float rr alignas(16)[VFXConfig::blockSize]; + rrLerp.store_block(rr); + + lrLerp.set_target(this->getFloatParam(fpLeftToRight)); + float lr alignas(16)[VFXConfig::blockSize]; + lrLerp.store_block(lr); + for (int i = 0; i < VFXConfig::blockSize; i++) { auto sL = datainL[i]; auto sR = datainR[i]; - dataoutL[i] = - sL * this->getFloatParam(fpLeftToLeft) + sR * this->getFloatParam(fpRightToLeft); - dataoutR[i] = - sR * this->getFloatParam(fpRightToRight) + sL * this->getFloatParam(fpLeftToRight); + dataoutL[i] = sL * ll[i] + sR * rl[i]; + dataoutR[i] = sR * rr[i] + sL * lr[i]; } } protected: - sst::basic_blocks::dsp::lipol_sse volLerp, leftLerp, rightLerp; + sst::basic_blocks::dsp::lipol_sse llLerp, rlLerp, rrLerp, lrLerp; }; } // namespace sst::voice_effects::utilities #endif // SCXT_GAINMATRIX_H diff --git a/include/sst/voice-effects/utilities/StereoTool.h b/include/sst/voice-effects/utilities/StereoTool.h index 925290f..7680feb 100644 --- a/include/sst/voice-effects/utilities/StereoTool.h +++ b/include/sst/voice-effects/utilities/StereoTool.h @@ -79,17 +79,34 @@ template struct StereoTool : core::VoiceEffectTemplateBase< void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR, float pitch) { - auto rotRadians = this->getFloatParam(fpRotation) * 0.017453292; // degrees * PI/180 - auto width = this->getFloatParam(fpWidth) / 2.f; - auto side = std::min(this->getFloatParam(fpMidSide) + 1, 1.f); - auto center = 1 - this->getFloatParam(fpMidSide); - auto left = -std::min(this->getFloatParam(fpLeftRight), 0.f); - auto left1 = -std::max(this->getFloatParam(fpLeftRight) - 1, -1.f); - auto right = std::max(this->getFloatParam(fpLeftRight), 0.f); - auto right1 = std::min(1 + this->getFloatParam(fpLeftRight), 1.f); + + rotLerp.set_target(this->getFloatParam(fpRotation)); + float rot alignas(16)[VFXConfig::blockSize]; + rotLerp.store_block(rot); + + widthLerp.set_target(this->getFloatParam(fpWidth)); + float w alignas(16)[VFXConfig::blockSize]; + widthLerp.store_block(w); + + msLerp.set_target(this->getFloatParam(fpMidSide)); + float ms alignas(16)[VFXConfig::blockSize]; + msLerp.store_block(ms); + + lrLerp.set_target(this->getFloatParam(fpLeftRight)); + float lr alignas(16)[VFXConfig::blockSize]; + lrLerp.store_block(lr); for (int i = 0; i < VFXConfig::blockSize; i++) { + auto rotRadians = rot[i] * 0.017453292; // degrees * PI/180 + auto width = w[i] / 2.f; + auto side = std::min(ms[i] + 1, 1.f); + auto center = 1 - ms[i]; + auto left = -std::min(lr[i], 0.f); + auto left1 = -std::max(lr[i] - 1, -1.f); + auto right = std::max(lr[i], 0.f); + auto right1 = std::min(1 + lr[i], 1.f); + auto sL = datainL[i]; auto sR = datainR[i]; @@ -131,6 +148,10 @@ template struct StereoTool : core::VoiceEffectTemplateBase< dataoutR[i] = sR; } } + + protected: + sst::basic_blocks::dsp::lipol_sse rotLerp, widthLerp, msLerp, + lrLerp; }; } // namespace sst::voice_effects::utilities #endif // SCXT_STEREOTOOL_H