aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-08-28 22:18:36 -0700
committerChris Robinson <[email protected]>2023-08-28 22:18:36 -0700
commit098acdef7b3089801fa1a37411b512227e4fe335 (patch)
tree16ff529ecddfdcee0579ae8301aa831fec089e78
parent5ae0413c37b2d8535e95ff861d4f8c8538c78f7c (diff)
Avoid some large stack buffers
-rw-r--r--alc/effects/modulator.cpp45
1 files changed, 18 insertions, 27 deletions
diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp
index 14ee5004..cf0e16a6 100644
--- a/alc/effects/modulator.cpp
+++ b/alc/effects/modulator.cpp
@@ -45,8 +45,6 @@ namespace {
using uint = unsigned int;
-#define MAX_UPDATE_SAMPLES 128
-
#define WAVEFORM_FRACBITS 24
#define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
@@ -83,6 +81,9 @@ struct ModulatorState final : public EffectState {
uint mIndex{0};
uint mStep{1};
+ alignas(16) FloatBufferLine mModSamples{};
+ alignas(16) FloatBufferLine mBuffer{};
+
struct {
uint mTargetChannel{InvalidChannelIndex};
@@ -147,34 +148,24 @@ void ModulatorState::update(const ContextBase *context, const EffectSlot *slot,
void ModulatorState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
{
- for(size_t base{0u};base < samplesToDo;)
- {
- alignas(16) float modsamples[MAX_UPDATE_SAMPLES];
- const size_t td{minz(MAX_UPDATE_SAMPLES, samplesToDo-base)};
-
- mGetSamples(modsamples, mIndex, mStep, td);
- mIndex += static_cast<uint>(mStep * td);
- mIndex &= WAVEFORM_FRACMASK;
+ mGetSamples(mModSamples.data(), mIndex, mStep, samplesToDo);
+ mIndex += static_cast<uint>(mStep * samplesToDo);
+ mIndex &= WAVEFORM_FRACMASK;
- auto chandata = std::begin(mChans);
- for(const auto &input : samplesIn)
+ auto chandata = std::begin(mChans);
+ for(const auto &input : samplesIn)
+ {
+ const size_t outidx{chandata->mTargetChannel};
+ if(outidx != InvalidChannelIndex)
{
- const size_t outidx{chandata->mTargetChannel};
- if(outidx != InvalidChannelIndex)
- {
- alignas(16) float temps[MAX_UPDATE_SAMPLES];
-
- chandata->mFilter.process({&input[base], td}, temps);
- for(size_t i{0u};i < td;i++)
- temps[i] *= modsamples[i];
-
- MixSamples({temps, td}, samplesOut[outidx].data()+base, chandata->mCurrentGain,
- chandata->mTargetGain, samplesToDo-base);
- }
- ++chandata;
- }
+ chandata->mFilter.process({input.data(), samplesToDo}, mBuffer.data());
+ for(size_t i{0u};i < samplesToDo;++i)
+ mBuffer[i] *= mModSamples[i];
- base += td;
+ MixSamples({mBuffer.data(), samplesToDo}, samplesOut[outidx].data(),
+ chandata->mCurrentGain, chandata->mTargetGain, minz(samplesToDo, 64));
+ }
+ ++chandata;
}
}