Skip to content

feat(editor): grouping-aware click, ruler ticks, and comb (P2-6) - #277

Merged
byrongamatos merged 1 commit into
mainfrom
feat/editor-grouping-aware
Jul 15, 2026
Merged

feat(editor): grouping-aware click, ruler ticks, and comb (P2-6)#277
byrongamatos merged 1 commit into
mainfrom
feat/editor-grouping-aware

Conversation

@ChrisBeWithYou

@ChrisBeWithYou ChrisBeWithYou commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

⚠ STACKED on #276 (P2-5 authored marks) — base is feat/editor-markers-hold-group. After #276 squash-merges: git rebase --onto main feat/editor-markers-hold-group feat/editor-grouping-aware, retarget, ancestry check (the #230 ritual).

What

P2-6 — the grouping field's three consumers, so an authored 7/8 (2+2+3) actually teaches the riff instead of just labeling it:

  1. Metronome accents the grouping-cell starts — 2+2+3 clicks strong-weak-strong-weak-strong-weak-weak, so you hear where the pick pattern resets.
  2. Ruler group-ticks — accents draw bright at full tick density, and at far zoom (where per-beat ticks are dropped but the bar still has ≥28 px) the few sub-bar ticks are spent on the accents instead of vanishing.
  3. The suggest comb corroborates on the FELT pulse — accented positions carry double weight, so a candidate barline whose onsets land on the 2+2+3 accents out-scores one that merely matches an even seven. A wrong grouping (3+2+2 against a 2+2+3 performance) scores below the right one — the detector genuinely prefers the authored feel.

No grouping = bit-identical behavior everywhere (pinned by test): the accent map degrades to downbeat-only, the comb's uniform weights reproduce the exact old mean, the ruler draws what it always drew.

How

  • _groupingAccentMapPure([2,2,3], 7) → [1,0,1,0,1,0,0] + a by-measure lookup in tempo-marks.js; the live lookup (_groupingAccentsLive) is memoized on the immutable marks-array identity — no per-frame builds on the draw/scheduler hot paths.
  • _metroClicksInWindowPure gains the lookup as plain data (sliced-env safe); a window-edge back-scan keeps mid-bar scheduler windows accent-correct.
  • _suggestCombPure(…, accentMap) weighted mean; threaded through the march and the best-candidate probe via opts.accentsByMeasure.

Testing

tests/grouping_aware.test.mjs (5 cases, fails on main): accent-map shapes (incl. bad-sum degradation), lookup coverage, click accents incl. the mid-window back-scan, the comb ordering (right grouping > even > wrong grouping on an accent-only onset fixture) plus exact backwards-compat mean, ruler tick gating. Full suites green: 160 files / 0 fail, lint at baseline.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EBQCHCNA81E9tHmSDHSe2Q

Summary by CodeRabbit

  • New Features

    • Metronome accents now follow authored meter groupings, such as 7/8 grouped as 2+2+3.
    • Ruler ticks emphasize grouping boundaries for easier rhythm navigation.
    • Tempo suggestions now give greater weight to onset timing at grouping accents.
    • Bars without groupings retain their previous behavior.
  • Tests

    • Added coverage for grouping-aware metronome timing, ruler ticks, and tempo suggestions.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 12802d0a-235e-41bf-a7e3-822aa2e7bef2

📥 Commits

Reviewing files that changed from the base of the PR and between 0e637b3 and ecfeda8.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • src/audio.js
  • src/ruler.js
  • src/tempo-marks.js
  • src/tempo-suggest.js
  • tests/grouping_aware.test.mjs

📝 Walkthrough

Walkthrough

Authored meter groupings now generate accent maps used by metronome clicks, ruler ticks, and tempo suggestion scoring. Ungrouped bars retain downbeat-only behavior, and new tests cover grouping validation and each consumer.

Changes

Grouping-aware timing

Layer / File(s) Summary
Accent-map generation
src/tempo-marks.js, tests/grouping_aware.test.mjs, CHANGELOG.md
Grouping data is converted into memoized measure-scoped accent maps, with tests for valid and invalid groupings and changelog documentation.
Metronome and ruler accents
src/audio.js, src/ruler.js, tests/grouping_aware.test.mjs
Metronome clicks and ruler subdivision ticks use grouping accents while preserving ungrouped behavior.
Accent-weighted tempo suggestions
src/tempo-suggest.js, tests/grouping_aware.test.mjs
Tempo comb scoring weights accented grouping positions and passes measure-specific accent maps through candidate selection.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TempoMarks
  participant Metronome
  participant Ruler
  participant TempoSuggest
  TempoMarks->>Metronome: provide live grouping accent maps
  TempoMarks->>Ruler: provide live grouping accent maps
  TempoMarks->>TempoSuggest: provide measure accent maps
  Metronome->>Metronome: accent grouped-cell clicks
  Ruler->>Ruler: emphasize grouped subdivision ticks
  TempoSuggest->>TempoSuggest: weight grouped-cell onset scores
Loading

Possibly related PRs

Suggested reviewers: byrongamatos

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/editor-grouping-aware

Comment @coderabbitai help to get the list of available commands.

The authored meter grouping's three consumers, so 2+2+3 actually
teaches the riff:

- Metronome: _metroClicksInWindowPure takes the measure→accent-map
  lookup (plain data, sliced-env safe) and accents grouping-cell starts;
  window-edge back-scan keeps mid-bar scheduler windows accent-correct.
- Ruler: grouping accents draw bright at full tick density, and at far
  zoom (pxPerBeat < 6, pxPerBar >= 28) the sparse sub-bar ticks are
  SPENT on the accents (_rulerGroupTickPure) instead of vanishing.
- Suggest comb: _suggestCombPure gains an accentMap — accented positions
  carry double weight, so a phase aligned with the FELT pulse out-scores
  even subdivision (and a WRONG grouping scores below the right one);
  threaded through the march + best-candidate probe via
  opts.accentsByMeasure, built from live marks in _suggestCompute.

The shared lookup (_groupingAccentsLive) is memoized on the immutable
marks array identity — no per-frame builds on the draw/scheduler paths.
No grouping anywhere = bit-identical behavior (pinned).

tests/grouping_aware.test.mjs (5 cases, fails on main): accent maps,
by-measure lookup, click accents (incl. mid-window back-scan), grouped-
beats-even comb ordering (right grouping > wrong grouping > none on an
accent-only fixture), ruler tick gating.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EBQCHCNA81E9tHmSDHSe2Q
@byrongamatos
byrongamatos force-pushed the feat/editor-grouping-aware branch from aea8882 to ecfeda8 Compare July 15, 2026 20:31
@byrongamatos
byrongamatos merged commit a642625 into main Jul 15, 2026
3 of 4 checks passed
@byrongamatos
byrongamatos deleted the feat/editor-grouping-aware branch July 15, 2026 20:31
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.

2 participants