fix(lyrics): adjustable lyric sync offset (#17)#18
Merged
Conversation
Lyrics could appear to lag the audio by a fraction of a second (the fetched LRC timings plus playback-report latency). Add a user-adjustable sync nudge so listeners can pull lyric lines earlier (or later) to taste. - AppearanceSettings gains lyricsOffsetMilliseconds (±2000ms, clamped, backward-compatible decode defaulting to 0) - LrcLineParser.effectivePositionMs applies the nudge before active-line selection; floored at 0 so a large negative offset can't skip line one - ImmersiveLyricsView feeds the offset through both the live TimelineView and the static (paused) position paths - Appearance settings gains a 'Lyric sync' slider with Earlier/Later labels, a live value readout, and a reset-to-in-sync link (en/de/es) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a persisted, user-adjustable lyrics timing offset to compensate for perceived lyric highlight lag, and applies that offset consistently in the immersive lyrics rendering path.
Changes:
- Introduces
AppearanceSettings.lyricsOffsetMillisecondswith clamping and backward-compatible decoding. - Adds a Settings → Appearance slider UI to adjust/reset the lyrics offset with localized labels and live value readout.
- Applies the offset via a shared helper (
LrcLineParser.effectivePositionMs) and adds unit tests covering offset behavior and settings decode/clamp.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| SpotiglassTests/LrcParsingTests.swift | Adds unit tests for effective-position offset behavior and settings decode/clamping. |
| Spotiglass/Views/ImmersiveLyricsView.swift | Applies the effective position (with offset) to both animated and static lyric position paths. |
| Spotiglass/Settings/SpotiglassSettingsModel.swift | Persists/clamps the new lyrics offset setting and supports legacy settings decoding. |
| Spotiglass/Settings/AppearanceSettingsView.swift | Adds the lyrics offset slider UI, readout, and reset action in Appearance settings. |
| Spotiglass/Services/LrcLineParser.swift | Adds the helper to compute effective position with a zero floor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+29
to
+32
| /// A positive `offsetMs` advances lyric selection (lines appear earlier, to | ||
| /// compensate for the usual fetch/playback-report lag); a negative value | ||
| /// delays it. The result is floored at zero so the very first line never | ||
| /// gets skipped by a large negative offset. |
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.
Closes #17.
Problem
Lyrics could feel ~0.5s late — the LRC line timings plus the latency in Spotify's position reports nudge the highlighted line behind what you actually hear.
Fix
Adds a user-adjustable lyric sync offset (the reporter's own suggestion), in Settings → Appearance, right under lyrics text size.
0.50 s earlier), and a Reset to in sync link.AppearanceSettings.lyricsOffsetMilliseconds— clamped, with a backward-compatible decode that defaults oldsettings.jsonfiles to0.ImmersiveLyricsViewthrough both the live (TimelineView) and paused/static position paths, via a small testable helperLrcLineParser.effectivePositionMs(floored at 0 so a big negative offset can't skip the first line).Tests
4 new unit tests (offset shifts active line, floors at zero, legacy decode default, out-of-range clamp). Full suite green: 791 passed, 0 failures.
🤖 Generated with Claude Code