feat(metronome): beat click during normal playback - #22
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughStaff View adds a persisted Metronome toggle to the options pill. During normal playback, beat advancement triggers reused study-beep clicks with downbeat accents. Study mode, seeks, paused audio, and insufficient beat data suppress clicks. Tests cover the metronome tick behavior. ChangesMetronome playback
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@screen.js`:
- Around line 3382-3384: The metronome tick logic around _svMetroBeatIdx must
distinguish ordinary beat advances from completed silent seek transitions,
including exact one-beat forward and backward seeks. In screen.js lines
3382-3384, track audio seek completion so the next tick only resynchronizes
without calling _svStudyBeep; update tests/metronome.test.js lines 35-58 to
model seek completion and cover both exact-one-beat seek directions.
- Around line 3365-3370: Update _svMetroTick in screen.js to return when
_svIsFocused is false before processing the shared audio element or emitting
clicks. In tests/metronome.test.js, expose _svIsFocused in the harness and add
coverage confirming an unfocused instance remains silent; the test site requires
this direct harness and assertion change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c73db240-4262-4b29-b51f-118b97637548
📒 Files selected for processing (3)
CHANGELOG.mdscreen.jstests/metronome.test.js
Adds a METRONOME toggle to the options pill that clicks on every beat of bundle.beats during normal playback (accented on downbeats, measure >= 0). Study mode is excluded — it already runs its own preroll count-in clicks. Reuses the existing _svStudyBeep click and its lazily-recreated AudioContext rather than opening a second audio path. _svMetroTick binary-searches beats the same way _svSyncCursor does, tracking the last beat index a click fired for (_svMetroBeatIdx) so an ordinary one-beat advance clicks while a seek/jump just resyncs silently. State is persisted to localStorage and reset alongside the cursor's own per-song reset points (teardown, init, chart change). Co-Authored-By: Claude Sonnet <noreply@anthropic.com> Signed-off-by: gionnibgud <gionnibgud@gmail.com>
Two review findings on _svMetroTick: - Shared #audio in split-screen: gate on _svIsFocused so only the focused panel clicks/advances state. - A seek forward by exactly one beat satisfied the "advanced one beat" check and clicked, violating the seek-resyncs-silently contract. Attach a 'seeked' listener (mirrors _svStudySeekHandler) that flags the next tick to resync without clicking, covering A/B loop wraps too. Co-Authored-By: Claude Sonnet <noreply@anthropic.com> Signed-off-by: gionnibgud <gionnibgud@gmail.com>
cb36ef0 to
c2267f9
Compare
What
A METRONOME toggle in the Staff View options pill: clicks on every beat of
bundle.beatsduring normal playback, accented on downbeats (measure >= 0). Persisted tolocalStorage.Study mode is deliberately excluded — it already runs its own preroll count-in clicks, and a gated note-by-note run has no steady pulse to click against.
How
_svStudyBeepclick and its lazily-recreatedAudioContextrather than opening a second audio path._svMetroTickbinary-searchesbeatsthe same way_svSyncCursordoes, tracking the last beat index a click fired for (_svMetroBeatIdx): an ordinary one-beat advance clicks, while a seek/jump resyncs silently. No click while paused, in study mode, or before the first beat._svMetroBeatIdxresets alongside the cursor's own per-song reset points (teardown,init(), chart change).Testing
npm test— 112/112 pass (104 existing + 8 new intests/metronome.test.js, following the suite's existing source-extraction pattern: accent-on-downbeat, silent mid-beat, seek resync, pre-first-beat reset, metronome off, study mode, paused/missing audio, <2 beats).Note
Depends on nothing in #21, but both branches touch the same
## [Unreleased]anchor inCHANGELOG.md— whichever merges second may need a trivial conflict resolution there.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests