Skip to content

Audio: Fixed time-stretched clips reading a stretcher-latency's worth of audio behind their play position - #404

Open
drowaudio wants to merge 1 commit into
developfrom
bugfix/timestretch_prime_latency_offset
Open

Audio: Fixed time-stretched clips reading a stretcher-latency's worth of audio behind their play position#404
drowaudio wants to merge 1 commit into
developfrom
bugfix/timestretch_prime_latency_offset

Conversation

@drowaudio

Copy link
Copy Markdown
Contributor

Summary

  • primeStretcher() in tracktion_WaveNode.cpp backed the source up by the stretcher's latency to warm it with real audio, but then only discarded the latency region of output. The next delivered frame was therefore a full latency behind readPosition. Fixed in both TimeStretchReader and ReadAheadTimeStretchReader by discarding the warm-up frames as well as the latency region, and clamping the read-ahead version's final pop so it can't over-discard.
  • Only stretchers that report a latency go through this path, which is currently just Signalsmith. That's the default mode in any build without Elastique or RubberBand, so this affects the default open-source configuration but not CI (which injects RubberBand).
  • Symptoms: launcher clips with a source offset started ~150ms early at 44.1kHz and ran past their expected end; looped clips glitched at each wrap. This is what makes the two ClipLauncher.test.cpp cases ("launch with clip source offset" and "switching scenes moves all tracks to the new scene") fail in builds without RubberBand.

Testing

  • Added an alignment check to runTimestretchedTests() in tracktion_WaveNode.test.cpp: a source with a silent middle second, played at clip offsets 0 and 1s, over every enabled stretch mode and both read-ahead settings. Fails without the fix (signalsmith only), passes with it. Because it iterates over enabled modes rather than the default, it exercises Signalsmith on CI too.
  • Full TestRunner suite passes locally (Debug, macOS, no RubberBand): 340/340 test cases, 10740 assertions.

Notes

  • SoundTouch produces no output at all through the read-ahead reader (pre-existing, consistent with the "Currently only works with RubberBand" note on the existing read-ahead test). That combination is skipped in the new test and is being looked at separately.

… of audio behind their play position, by discarding the warm-up frames as well as the latency region when priming

Only stretchers that report a latency (currently Signalsmith) go through primeStretcher(). It backed the source up by the latency to warm the stretcher with real audio but then only discarded the latency region of output, so the next delivered frame was a full latency behind readPosition. This showed up as launcher clips with a source offset starting ~150ms early and looped clips glitching at each wrap.

Adds a WaveNode test that checks each enabled stretcher lines the source up with the timeline at a non-zero clip offset, through both the normal and read-ahead readers.
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.68421% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.91%. Comparing base (54e3462) to head (47d1527).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...ktion_engine/playback/graph/tracktion_WaveNode.cpp 0.00% 13 Missing ⚠️
..._engine/playback/graph/tracktion_WaveNode.test.cpp 95.45% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #404      +/-   ##
===========================================
+ Coverage    58.69%   58.91%   +0.21%     
===========================================
  Files          562      562              
  Lines        78793    78842      +49     
  Branches     12325    12330       +5     
===========================================
+ Hits         46250    46450     +200     
+ Misses       32543    32392     -151     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant