Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An offline render (track bounce, stems) runs the same clip path as live playback, so a streamed clip is popped from
its producer rings, and those rings fill with silence whenever the producer thread falls behind. An offline render has
no deadline, so it should never drop audio, but its output depends on disk and CPU timing.
Measured on 0.4.29 with the ALSA
nulldevice and a 48 kHz WAV clip (a seekable stream), 3 runs of 24 checks each:256 frames;
Change
Trackgets anoffline_random_accessflag. While it is set, aSeekableStreamingclip (PCM WAV at the enginerate) is read through the existing
clip_sample_windowrandom-access read, which blocks until it has exactly therequested frames, instead of the rings. The read is factored into
TrackData::read_clip_window_offline.OfflineClipReads, whichclears it when dropped. However the render ends (finished, cancelled or failed), live playback goes back to the
rings.
Readythemselves.process_offline_bounceandprocess_offline_stems_bouncenow call the render (render_offline_bounce,render_offline_stems_bounce) andsend
Readyonce it has returned. The engine starts a queued render as soon as it seesReady, possibly on anotherworker over the same tracks. If
Readywent out first, the first render's guard could clear the flag after thenext render had set it.
Streaming) still use the rings in offline renders.StreamingClipBuffer::read_window_intodecodes from the start of the file on every call and returns frames at thefile's own rate, so calling it once per block would be quadratic and off-rate. I've opened a separate issue for
that case.
Tests
offline_random_access_is_exact_from_the_first_block_at_a_clip_offsetinseekable_streaming.rs: a WAV clipwith
offset = 1000and the flag set gives four frame-exact blocks with no wait for the producer. Without thechange it fails on block 0 because the rings are still filling.
process_offline_bounce_cancels_and_restores_track_stateandprocess_offline_bounce_emits_progress_and_completionnow also assert that the flag is cleared afterwards.
offline_render_releases_clip_reads_before_the_worker_is_returned: the render returns without sendingReady,with the flag already cleared, and
Readyfollows.cargo test --features audio,midi,plugins: 528 passed, 1 ignored.cargo fmtandcargo clippy --all-targetsareclean for the change. One clippy warning remains in
src/midi/mtc.rs, which this change doesn't touch.above passed 24 of 24 in 3 runs, both under load and on an idle host.
Notes for review
process()on the same track would take the blocking read too. The bounce alreadylocks the live tracks and changes their transport position, playback state and level, so bouncing during playback
isn't safe today either. Separating offline renders from live track state is a bigger change that I haven't
attempted here.
Track, I'm happy to move it.Prepared with the help of an AI coding assistant (Claude Code). The tests and measurements above were run, not
inferred.