Skip to content

feat: add Practice mode — play a tune's part on a real drum and get scored on your timing#151

Open
pliski wants to merge 6 commits into
beatboxjs:mainfrom
pliski:practice
Open

feat: add Practice mode — play a tune's part on a real drum and get scored on your timing#151
pliski wants to merge 6 commits into
beatboxjs:mainfrom
pliski:practice

Conversation

@pliski

@pliski pliski commented Jun 4, 2026

Copy link
Copy Markdown

This is a proposal — discussion in #150. An unsolicited feature I built for my own use as a beginner drummer, offered upstream in case it helps others.
Opened as a draft alongside #150 so the code is visible, with no assumption it should be merged as-is — I'd value your read on whether it fits the project first.
A live instance my group uses: https://ror-player.quaidubas30.ch (microphone + headphones).

What this adds

A new Practice tab. The user plays one instrument's part on a real drum into their microphone, and RoR Player scores their timing and accuracy against the tune.

How it works

  • Onset detection (src/services/onsetDetector*): an AudioWorklet computes RMS energy with an adaptive noise floor and emits an onset per detected drum hit.
  • Engine (src/services/practiceEngine.ts): runs a count-in, then loops the tune (your part solo, or the band minus your part) and anchors a per-loop baseline on the real audio loop wrap.
  • Scorer (src/services/practiceScorer.ts): matches detected onsets against the expected timeline on an unrolled monotonic loop timeline, yielding per-stroke verdicts and a 0–100 score.
  • UI (src/ui/practice/): toolbar (tune/part/instrument/mode), a live score rail with a timing meter, the per-stroke partition highlight, and an acoustic-loopback latency calibration wizard.

How to try it

Open Practice, pick a tune → part → instrument, put on headphones, press
Start, and play along after the count-in. Use ⚙ → Calibrate to measure your
audio latency.

Notes for reviewers

  • Needs a microphone and headphones (speaker bleed is counted as your hits).

  • The build emits a separately-served onsetDetector.worklet-*.js — AudioWorklet code cannot be inlined.

  • New dev-dependency: @types/audioworklet (typings only).

  • The Practice i18n namespace is intentionally English-only for now.

  • Additive / opt-in: shared components (pattern-player, hybrid-sidebar) gained default-off props, so Listen and Compose are byte-unchanged.

  • Companion documentation PR: docs: add Practice mode user guide ror-player-docs#1

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.

1 participant