From ead160497b3b7352cc6fddb600517b6ebca80a6f Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 25 Jan 2023 18:35:55 +0100 Subject: [PATCH] Fix excess padding handling in StftHelper --- src/util/stft.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/util/stft.rs b/src/util/stft.rs index ac9fa761..24eb1c20 100644 --- a/src/util/stft.rs +++ b/src/util/stft.rs @@ -461,13 +461,12 @@ impl StftHelper { *scratch_sample += *padding_sample; } - let remaining_padding = padding_to_copy - self.padding; - if remaining_padding > 0 { - padding_buffer.copy_within(..padding_to_copy, 0); - } + // Any remaining padding tail should be moved towards the start of the + // buffer + padding_buffer.copy_within(padding_to_copy.., 0); // And we obviously don't want this to feedback - padding_buffer[remaining_padding..].fill(0.0); + padding_buffer[self.padding - padding_to_copy..].fill(0.0); } // The actual overlap-add part of the equation