diff --git a/Audio/Chain/DSP/DSPRubberbandNode.h b/Audio/Chain/DSP/DSPRubberbandNode.h index c9816d79f..7680e74f2 100644 --- a/Audio/Chain/DSP/DSPRubberbandNode.h +++ b/Audio/Chain/DSP/DSPRubberbandNode.h @@ -25,6 +25,8 @@ - (void)process; - (AudioChunk * _Nullable)convert; +- (double)secondsBuffered; + @end #endif /* DSPRubberbandNode_h */ diff --git a/Audio/Chain/DSP/DSPRubberbandNode.m b/Audio/Chain/DSP/DSPRubberbandNode.m index c4c9a05f6..9b13500fe 100644 --- a/Audio/Chain/DSP/DSPRubberbandNode.m +++ b/Audio/Chain/DSP/DSPRubberbandNode.m @@ -513,4 +513,20 @@ static void * kDSPRubberbandNodeContext = &kDSPRubberbandNodeContext; return outputChunk; } +- (double)secondsBuffered { + double rbBuffered = 0.0; + if(ts) { + // We don't use Rubber Band's latency function, because at least in Cog's case, + // by the time we call this function, and also, because it doesn't account for + // how much audio will be lopped off at the end of the process. + // + // Tested once, this tends to be close to zero when actually called. + rbBuffered = stretchIn - stretchOut; + if(rbBuffered < 0.0) { + rbBuffered = 0.0; + } + } + return [buffer listDuration] + rbBuffered; +} + @end