From f153def94194050b331c7a2674959b9ea1d0008d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 25 Dec 2019 18:39:22 -0800 Subject: Pass a span for the biquad filter input --- alc/effects/distortion.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'alc/effects/distortion.cpp') diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp index 0916b7c6..48fc83ee 100644 --- a/alc/effects/distortion.cpp +++ b/alc/effects/distortion.cpp @@ -20,11 +20,10 @@ #include "config.h" +#include #include #include -#include - #include "al/auxeffectslot.h" #include "alcmain.h" #include "alcontext.h" @@ -114,26 +113,25 @@ void DistortionState::process(const size_t samplesToDo, const al::span float { - ALfloat smp{mBuffer[1][i]}; - - smp = (1.0f + fc) * smp/(1.0f + fc*fabsf(smp)); - smp = (1.0f + fc) * smp/(1.0f + fc*fabsf(smp)) * -1.0f; - smp = (1.0f + fc) * smp/(1.0f + fc*fabsf(smp)); - - mBuffer[0][i] = smp; - } + smp = (1.0f + fc) * smp/(1.0f + fc*std::abs(smp)); + smp = (1.0f + fc) * smp/(1.0f + fc*std::abs(smp)) * -1.0f; + smp = (1.0f + fc) * smp/(1.0f + fc*std::abs(smp)); + return smp; + }; + std::transform(std::begin(mBuffer[1]), std::begin(mBuffer[1])+todo, std::begin(mBuffer[0]), + proc_sample); /* Third step, do bandpass filtering of distorted signal. */ - mBandpass.process(mBuffer[1], mBuffer[0], todo); + mBandpass.process({mBuffer[0], todo}, mBuffer[1]); todo >>= 2; const ALfloat *outgains{mGain}; -- cgit v1.2.3