From cb5a8eab7eba3ba498590cc7872af75bb0da5a52 Mon Sep 17 00:00:00 2001 From: Geraint Luff Date: Tue, 5 Aug 2025 07:59:59 +0100 Subject: [PATCH] Zero `.exact()` output when it's too short --- signalsmith-stretch.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/signalsmith-stretch.h b/signalsmith-stretch.h index 542a003..1ef9716 100644 --- a/signalsmith-stretch.h +++ b/signalsmith-stretch.h @@ -405,7 +405,16 @@ struct SignalsmithStretch { template bool exact(Inputs &&inputs, int inputSamples, Outputs &&outputs, int outputSamples) { - if (outputSamples < outputLatency()*2) return false; // too short for this + if (outputSamples < outputLatency()*2) { + // to short for this - zero the output just to be polite + for (int c = 0; c < channels; ++c) { + auto &&channel = outputs[c]; + for (int i = 0; i < outputSamples; ++i) { + channel[i] = 0; + } + } + return false; + } struct ZeroPaddedInput { Inputs &inputs;