Skip to content

fix(lyrics): adjustable lyric sync offset (#17)#18

Merged
isaaclins merged 1 commit into
mainfrom
fix/issue-17-lyric-offset
Jun 4, 2026
Merged

fix(lyrics): adjustable lyric sync offset (#17)#18
isaaclins merged 1 commit into
mainfrom
fix/issue-17-lyric-offset

Conversation

@isaaclins

Copy link
Copy Markdown
Owner

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.

  • Slider from −2.0s to +2.0s (50ms steps), with Earlier / Later labels, a live readout (e.g. 0.50 s earlier), and a Reset to in sync link.
  • Positive offset pulls lyric lines earlier to compensate for the lag; negative delays them.
  • Persisted in AppearanceSettings.lyricsOffsetMilliseconds — clamped, with a backward-compatible decode that defaults old settings.json files to 0.
  • Applied in ImmersiveLyricsView through both the live (TimelineView) and paused/static position paths, via a small testable helper LrcLineParser.effectivePositionMs (floored at 0 so a big negative offset can't skip the first line).
  • Localized in en/de/es.

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

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>
Copilot AI review requested due to automatic review settings June 4, 2026 06:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.lyricsOffsetMilliseconds with 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.
@isaaclins
isaaclins merged commit e149518 into main Jun 4, 2026
1 check passed
@isaaclins
isaaclins deleted the fix/issue-17-lyric-offset branch June 4, 2026 06:39
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.

[bug]: Lyrics not always in sync.

2 participants