From bc9810980d06f620617aad3d7de07b584f0df68a Mon Sep 17 00:00:00 2001 From: Peter Sobot Date: Sun, 23 Jan 2022 00:52:14 -0500 Subject: [PATCH] Fix Delay plugin when delay time is 0.0 seconds. --- pedalboard/plugins/Delay.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pedalboard/plugins/Delay.h b/pedalboard/plugins/Delay.h index e965cf7d..b04dbc38 100644 --- a/pedalboard/plugins/Delay.h +++ b/pedalboard/plugins/Delay.h @@ -54,7 +54,7 @@ class Delay : public JucePluginlastSpec = spec; } - this->getDSP().setDelay((int)(getDelaySeconds() * spec.sampleRate)); + this->getDSP().setDelay((int)(delaySeconds * spec.sampleRate)); } virtual void reset() override { this->getDSP().reset(); } @@ -65,7 +65,13 @@ class Delay : public JucePlugingetDSP().setDelay((int)(getDelaySeconds() * this->lastSpec.sampleRate)); + if (delaySeconds == 0.0f) { + // Special case where DelayLine doesn't do anything for us. + // Regardless of the mix or feedback parameters, the input will sound identical. + return context.getInputBlock().getNumSamples(); + } + + this->getDSP().setDelay((int)(delaySeconds * this->lastSpec.sampleRate)); // Pass samples through the delay line with feedback: for (size_t c = 0; c < context.getInputBlock().getNumChannels(); c++) {