Repository navigation
Fix SRT/ASS subtitle sync at non-1x editor playback rates - #13
Merged
Merged
Conversation
When the editor's playback rate was not 1x, SRT/ASS subtitles appeared at "normal" 1x timing because ResolveCueTiming() called jukebox.SecondsToBeats(seconds) without accounting for the AudioSource pitch (which controls the editor's playback rate). Fix: Add GetJukeboxPlaybackRate() helper that reads AudioSource.pitch from the jukebox's component and divide the subtitle seconds by this rate before calling SecondsToBeats(). At 0.5x playback, SecondsToBeats (10 / 0.5) = SecondsToBeats(20) correctly returns the beat that CurrentBeat reaches at real-time second 20 (when audio-content second 10 plays at 0.5x speed). Also fix a secondary bug where karaoke segment beats from SRT/ASS were not recomputed on session restart (stale from previous session): remove the !segment.Beat.HasValue guard so seconds-based segments always get their beat recomputed. JSON-based segments (Beat set, Seconds unset) are unaffected. Co-authored-by: Brollyy <12004018+Brollyy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix SRT/ASS subtitles playback rate handling
Fix SRT/ASS subtitle sync at non-1x editor playback rates
Mar 18, 2026
This comment was marked as outdated.
This comment was marked as outdated.
The previous fix read the playback rate once at session start, which was wrong because the editor allows changing the rate mid-session. Add _resolvedPlaybackRate field to track which rate was used for the last ResolveCueTiming() call. In Update(), read the current AudioSource.pitch each frame; if it differs from _resolvedPlaybackRate, re-run ResolveCueTiming() with the new rate and reset _activeCue and the karaoke cache so the display is immediately re-evaluated. ResolveCueTiming now accepts the pre-read playbackRate parameter to avoid reading AudioSource.pitch twice per frame. Co-authored-by: Brollyy <12004018+Brollyy@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
…ntBeat JukeboxScript.CurrentBeat advances based on wall-clock time and does not account for AudioSource.pitch, causing subtitles to drift from the audio at non-1x playback rates. Replace CurrentBeat with GetContentBeat() which reads AudioSource.time (the true content position regardless of pitch) and converts to beats via SecondsToBeats(). Falls back to CurrentBeat when no AudioSource is available. This removes all previous rate-division hacks and keeps cues as simple beat values converted once at session start. Co-authored-by: Brollyy <12004018+Brollyy@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
Brollyy
marked this pull request as ready for review
March 25, 2026 19:41
Owner
|
@codex[agent] review this PR |
Copilot stopped work on behalf of
Brollyy due to an error
March 25, 2026 19:43
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fa7b717b4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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.
SRT/ASS subtitles always appeared at 1x wall-clock timing regardless of the editor's playback rate, because
JukeboxScript.CurrentBeatadvances based on wall-clock time and does not account forAudioSource.pitch.Changes
GetContentBeat(jukebox)— new helper that derives the current beat fromAudioSource.time(which always reflects the true audio content position regardless of pitch) viaSecondsToBeats(), instead of relying onjukebox.CurrentBeat. Falls back toCurrentBeatwhen noAudioSourceor clip is available.Beat query in
Update()— replacedjukebox.CurrentBeatwithGetContentBeat(jukebox)so subtitle cue matching uses the actual audio content position at any editor playback rate.Subtitle cues remain stored as simple beat values, converted once at session start via the original
SecondsToBeats()call with no rate adjustments. The fix is entirely in how the current playback position is queried — not in how cue timing is resolved.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.