From 0262df7c534820de9cddf306e470588b029c28de Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 16 Feb 2025 14:03:16 -0800 Subject: [PATCH] Bug Fix: Rubber Band handles end of track gap The code was polling the input chunk duration after emptying out the chunk's samples, which resulted in an input duration account sitting at exactly zero, so the end overrun flush would not be cut short properly, resulting in gaps between tracks. Correct the input sum to tabulate before emptying the input chunk, so output remains properly gapless. Signed-off-by: Christopher Snowhill --- Audio/Chain/DSP/DSPRubberbandNode.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Audio/Chain/DSP/DSPRubberbandNode.m b/Audio/Chain/DSP/DSPRubberbandNode.m index 1beadc955..c4c9a05f6 100644 --- a/Audio/Chain/DSP/DSPRubberbandNode.m +++ b/Audio/Chain/DSP/DSPRubberbandNode.m @@ -439,6 +439,8 @@ static void * kDSPRubberbandNodeContext = &kDSPRubberbandNodeContext; streamTimeRatio = [chunk streamTimeRatio]; isHDCD = [chunk isHDCD]; + stretchIn += [chunk duration] / tempo; + size_t frameCount = [chunk frameCount]; NSData *sampleData = [chunk removeSamples:frameCount]; @@ -446,8 +448,6 @@ static void * kDSPRubberbandNodeContext = &kDSPRubberbandNodeContext; cblas_scopy((int)frameCount, ((const float *)[sampleData bytes]) + i, channels, rsPtrs[i], 1); } - stretchIn += [chunk duration] / tempo; - endOfStream = [[previousNode buffer] isEmpty] && [previousNode endOfStream] == YES; int len = (int)frameCount;