Repository navigation
Conversation
…Stage 2 A non-identity TimeGrid used to be realised by stretching Stage 1's rendered waveform in Stage 2 (WSOLA via SoundTouch). Stretching an already-vocoded signal leaves an audible vibrato/tremor on sustained notes, because the waveform is resampled after the vocoder has fixed the harmonic phase. Stage 1 now applies the time mapping to its own conditioning: mel/log-linear frames and the F0/UV track are warped by tauInverse before synthesis, so the vocoder generates the stretched result directly and Stage 2 becomes a pure copy. This keeps the signal to exactly one vocoder pass -- the previous path was one pass plus a waveform stretch, and the obvious alternative (re-analyse and re-synthesise) would have been two. TimeGridConditioningWarp::stage1BakesGrid is the single predicate deciding which regime a render is in; ContentRenderService tracks per-content whether Stage 1 baked a given timeGridRevision, and Stage2TimeStretchRebuilder reads that flag to choose copy vs stretch. The WSOLA path is kept for the cases the bake does not cover. Consequences handled here: - The F0 timeline is indexed in source time while chunk boundaries are in output time. When baking, the F0 query range is mapped through tauInverse; otherwise a grid that moves output onto a different source position reads the wrong frames and can blank voiced regions. - Fast paths that publish un-warped audio (blank-chunk settle, the AutoTune light pitch path) are suppressed while baking: skipping the vocoder would discard the time mapping entirely. - setContentTimeGrid must now re-run Stage 1, via the same requestRenderForLocalMutationRange path other local edits use. It deliberately does not invalidate TimeStretchCache by hand -- that advances the generation and makes the result Stage 2 just published stale, so the playback reader returns 0 samples and the track goes silent. - A non-identity grid advances contentRevision in the content owners. RenderCache::reconcileFullPlanAndRequest decides re-render by comparing contentRevision alone, so bumping only timeGridRevision made every handle drag a no-op: anchors moved on screen and nothing was re-synthesised. Tests: TimeGridConditioningWarpTests covers the mapping contract (monotonicity, endpoint pinning, chunk-seam continuity); ContentSnapshotProjectionTests covers the contentRevision rule across identity/non-identity transitions.
Dragging one handle re-rendered the whole track: setContentTimeGrid asked for the entire [0, duration] range, and RenderCache decides what to re-run by whether a chunk intersects the request. A 290 s clip meant all 82 chunks went through the vocoder again for a one-anchor nudge. Only two segments actually change when an anchor moves -- the ones either side of it -- because every other segment keeps the same source/output pair and so the same slope. timeGridAffectedOutputRange diffs the before/after snapshots by handle id (ids are stable across drag and undo/redo; source_seconds are immutable once inserted, so an id whose output_seconds moved was dragged) and returns the union of the neighbouring anchors' output positions. Insert and delete widen it to the anchors on both sides, since merging or splitting a segment changes both. Differential analysis is only taken when a narrow range is actually trustworthy; anything else falls back to the full track, because over-rendering is far cheaper than shipping stale audio. The before/after snapshot is read before applyTimeGrid, and only when the edit will bake (or when Stage 1 has baked before, i.e. reverting a baked grid to identity still needs the diff) -- getContentSnapshot rebuilds the whole snapshot and identity-only edits go down the Stage 2 path, so they should not pay for it. Tests: TimeGridEditTests asserts a middle-anchor drag narrows to exactly its neighbour span, edge-anchor drags cover the ends, insert/delete widen correctly, and identical grids report no change.
Map source-timeline edit ranges onto the output timeline used by Stage 1 chunks when a TimeGrid is baked, so pitch and note edits re-render the correct chunks. Rebase published revision tags after a republish-only content change so playback keeps reading existing PCM. Stage an ASCII-named demo wav for the Windows POST_BUILD copy step. Add regression tests for both fixes.
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
A non-identity TimeGrid is realised by stretching Stage 1's rendered waveform
in Stage 2 (WSOLA via SoundTouch). Stretching an already-vocoded signal leaves
an audible vibrato/tremor on sustained notes: the waveform is resampled after
the vocoder has fixed the harmonic phase, so every analysis window re-decides
pitch-period alignment independently. Short TimeGrid segments (~30-60 ms, below
SoundTouch's 73-90 ms analysis window) are the worst case -- the joins between
them are phase-incoherent.
Approach
Stage 1 now applies the time mapping to its own conditioning. Mel/log-linear
frames and the F0/UV track are warped by
tauInversebefore synthesis, so thevocoder generates the stretched result directly and Stage 2 becomes a pure copy.
This keeps the signal at exactly one vocoder pass. The previous path was one
pass plus a waveform stretch; the obvious alternative (re-analyse and
re-synthesise) would have been two, which loses detail and doubles cost.
TimeGridConditioningWarp::stage1BakesGridis the single predicate decidingwhich regime a render is in.
ContentRenderServicerecords per-content whetherStage 1 baked a given
timeGridRevision, andStage2TimeStretchRebuilderreads that flag to choose copy vs stretch. The WSOLA path is kept for the cases
the bake does not cover.
Consequences handled
boundaries are in output time. When baking, the F0 query range is mapped
through
tauInverse; otherwise a grid that moves output onto a differentsource position reads the wrong frames and can blank voiced regions.
settleBlankChunkand theAutoTune light-pitch path publish un-warped audio; skipping the vocoder there
would discard the time mapping entirely.
setContentTimeGridmust re-run Stage 1, through the samerequestRenderForLocalMutationRangepath other local edits use. Itdeliberately does not invalidate
TimeStretchCacheby hand -- that advancesthe generation, makes the result Stage 2 just published stale, and the
playback reader then returns 0 samples, i.e. the whole track goes silent.
contentRevisionin the content owners.reconcileFullPlanAndRequestdecides re-render by comparingcontentRevisionalone, so bumping onlytimeGridRevisionmade every handledrag a no-op: anchors moved on screen and nothing was re-synthesised.
Second commit: re-render only the edited span
Dragging one handle used to re-render the whole track --
setContentTimeGridasked for the entire
[0, duration]range, andRenderCachedecides what tore-run by whether a chunk intersects the request. A 290 s clip meant all 82
chunks went through the vocoder again for a one-anchor nudge.
Only two segments actually change when an anchor moves -- the ones either side of
it.
timeGridAffectedOutputRangediffs the before/after snapshots by handle id(ids are stable across drag and undo/redo;
source_secondsare immutable onceinserted, so an id whose
output_secondsmoved was dragged) and returns theunion of the neighbouring anchors' output positions. Insert and delete widen it
to both sides, since merging or splitting a segment changes both.
Anything not confidently narrow falls back to the full track: over-rendering is
far cheaper than shipping stale audio.
Tests
TimeGridConditioningWarpTests-- mapping contract: monotonicity, endpointpinning, chunk-seam continuity.
ContentSnapshotProjectionTests-- thecontentRevisionrule acrossidentity/non-identity transitions.
TimeGridEditTests-- middle-anchor drag narrows to exactly its neighbourspan, edge-anchor drags cover the ends, insert/delete widen correctly,
identical grids report no change.
40/40 ctest passing. Verified that this branch builds and passes on its own,
without the CopyVocal import branch.