v1.0.10 · Release snapshot

Documentation comes from this release commit, without inheriting newer content. Commit: 63ea8c2b3d.

Piano DevTool

One Electron app (also runnable as a plain web server) that replaces the old analytics bridge and adds MIDI / soundfont sync to the phone. The MIDI visualizer and soundfont lab stay standalone (bun run midi:viz, bun run soundfont:lab). Source: tools/piano-devtool-desktop. Wire protocol: @piano/network/devtool-protocol (shared by the tool and the app).

TabWhat it does
DevicesConnect a phone (QR / LAN) for analytics + library sync; connected phones and sync state; the first sync-capable phone is auto-selected for Library; switch with Use for library when several are online; Clear dev data.
AnalyticsLive event stream per device, @piano/analytics contract validation, contract coverage, saved sessions; Classic visualizer sub-tab (no duplicate connect UI — use Devices).
Library & SyncManifest sync bar (revision, Push to devices); upload MIDI / SF2 (SF2 On relay list under the drop zone); App song list from the phone; Gameplay / Learn; add / override.

| Sound | Realtime sampler + mixer tuning on a connected phone, a looping test phrase, live meters, and named presets saved on this computer. See Sound tab. | | Adaptive tempo | Live tracking + tuning of the hidden per-play tempo multiplier: ON/OFF and why (Remote Config, dev override), the live m, stats and per-bar decisions of the current / last play, the policy numbers in force, a log of flag / threshold-tuning / play / decision changes (exportable as a .log file) and a play report for a music specialist (Markdown + per-bar CSV); tuning can be exported / imported as JSON (also accepts a Remote Config adaptive_tempo object) and copied as Remote Config JSON. See Adaptive tempo tab. | | Haptics | Realtime gameplay-haptic tuning on a connected phone: Light / Medium / Strong tone bundles, a per-event (Perfect tap, hold complete, miss) tone (exact strength + sharpness) or preset pattern choice with Play on phone, the hold rumble, and the rush limiter (target rate, burst, min gap, softest gain) with a synthetic Rush test and live requested / played / dropped stats; export / import JSON. See Haptics tab. |

Run

bun run devtool:dev     # Electron + Vite HMR (shell UI hot-reloads)
bun run devtool:web     # production UI build + browser → http://localhost:7799 (no HMR)
bun run devtool:start   # production build in Electron (no HMR)
bun run devtool:dist    # DMG → tools/piano-devtool-desktop/release/

Use devtool:dev while editing the DevTool UI. devtool:web / devtool:start run electron-vite build first — that is intentional for QA/production-like runs, not day-to-day UI work.

analytics:bridge and analytics:desktop:* remain as aliases. The tool is not a Bun workspace; root scripts install it on demand via scripts/ensure-devtool-deps.ts (the Electron binary is skipped for typecheck/tests and downloaded on first devtool:dev|start|dist, which also compiles the macos-alias addon the DMG maker needs, since deps install with --ignore-scripts). bun run typecheck and bun run test cover it (typecheck:tools, //#test:app:tools).

Architecture

  • One port (default 7799, PIANO_DEVTOOL_PORT): static UI, /api/* and the WebSocket hub.
  • Control plane = WebSocket JSON, data plane = HTTP. The WS only carries small messages; files are downloaded over HTTP from content-addressed URLs (sha256), so a re-push of unchanged files costs nothing.
  • Manifest { revision, songs[], soundfonts[] } is the desired state. DevSong carries { id, fileName, mode: "add" | "override", meta, midi: { sha256, bytes } }; DevSoundFont carries { id, name, sha256, bytes, activateOnSync }. The app diffs it against what it has installed.
  • Hello handshake. { type: "hello", role: "app", protocolVersion, device }. A hello without protocolVersion is an analytics-only client. The relay keeps a sync socket and an events socket per device so one phone shows up as one device row.
  • Protocol v14 (DEVTOOL_PROTOCOL_VERSION; v14 adds the Haptics tab's haptics_state / request_haptics_state / set_haptics / play_haptic / haptic_rush_test, see Haptics tab; v13 swapped the adaptive-tempo thresholds for the pause-driven tap-windowed model; v12 adds the Timing tab's timing_state / request_timing_state / set_timing, see Timing tab; v8 adds adaptive_tempo_state, v9 set_adaptive_tempo + live signals, v10 timingZone, v11 the song / per-bar log / decision context, see Adaptive tempo tab): v2 added the audio_* messages below; v3 reshaped their sound to the instrument-sampler prototype's model (v4 adds levels, v5 adds limiters, v6 the master limiter's ceiling / look-ahead / release, v7 autoPlay, below; sound-model.ts). An older app never answers (or fails validation on) them and the Sound tab shows no state for it.
  • Security. Internal QA only: loopback, this machine's own addresses, and private LAN peers (RFC1918 / link-local) may connect with no proxy headers; proxied or public-internet clients get 401. Caps: MIDI 5 MB, SF2 300 MB.
  • Data lives in Electron userData/devtool (web mode: ~/.piano-devtool, PIANO_DEVTOOL_DATA).

App side (src/core/devtool-sync/)

Enabled only by EXPO_PUBLIC_ENABLE_DESKTOP_TOOLS=1 (also true) — one flag for the analytics WS bridge and MIDI/SF2 sync. It is not gated on __DEV__, so a PO can use a release-config internal build. The committed .env turns it on; CI sets it per ref (0 on dev, main, release/ios* and v* tags, the .env value on other branches: ci-cd.md). With the flag off, the DevTool graph (sync client, analytics bridge, Settings section) is not bundled: its entry points require it behind a literal process.env.EXPO_PUBLIC_ENABLE_DESKTOP_TOOLS test that release builds fold away. A config test (config/__tests__/devtool-flag.test.ts) checks that no CI workflow or EAS profile defaults it to on and that the store refs stay strictly off.

EXPO_PUBLIC_FORCE_AUTO_PLAY=1 makes every session start in auto play (usePianoUiStore.autoPlayMode, via src/features/piano/forced-auto-play.ts). It only takes effect together with EXPO_PUBLIC_ENABLE_DESKTOP_TOOLS=1, and the Sound tab can still switch auto play off for the run. For a premium user with no ads, pair it with EXPO_PUBLIC_APP_VARIANT=sim (stub IAP that is always premium).

FileRole
sync-client.tsWS state machine: connect, hello, receive manifest_changed, install, ack, progress, answer catalog / bundled-chart requests, retry.
installer.tsDownload to <sha>.part, size check, sha256 check (≤ 32 MB), atomic rename, 3 retries, keep the previous version on failure, sweep unreferenced files.
store.tsPersisted installed manifest, active soundfont id, last sync time; live connection / phase / progress / error.
commit-outcome.tsPersist the outcome and keep the soundfont choice coherent (activate-on-sync, fall back when removed).
dev-midi.ts, dev-library.tsIn-memory registry of installed dev MIDI; installed songs / soundfonts for the catalog.
dev-soundfonts.ts, use-dev-soundfonts.tsInstalled soundfonts as picker choices (<root><sha>.sf2 URIs).
status-summary.tsView model for the Settings "DEV SYNC" section.
runtime.tsstartDevToolSync, retryDevToolSync, clearDevToolData.

Boot wiring lives in src/bootstrap/devtool-sync.ts (idle-scheduled from useBootstrapEntrySDK): it loads dev MIDI from disk first (a song pushed yesterday plays today without the desktop), then starts the client. core/* may not import features/*, so everything that needs the catalog or sampler settings is composed here.

Songs

  • Chart precedence (getGameplayChart): dev MIDI registry → bundled ChartJson → runtime MIDI.
  • add: a synthetic catalog entry (free, isPublicDomain so the store-submission filter keeps it) merged by catalog-merge.ts into the catalog queries.
  • override: keeps the catalog id and monetisation, so progress and unlocks are preserved; only the chart changes.
  • The preview of an overridden song still uses the bundled chart.

Soundfonts

SoundFontSource = number | { id, uri } flows through the whole SF2 pipeline (sampler, shared bank, PCM cache, loader, native decoder). A { uri } source skips Asset.fromModule and decodes the synced file directly; the PCM cache treats dev fonts as the same only when the content-hashed uri matches. sampler-settings-store holds devSoundFont (overrides the bundled soundFont while set). The Sound sheet's SoundFontChoiceRow lists synced fonts as extra chips; bootstrap/dev-soundfont-sync.ts applies the persisted / activateOnSync choice after each sync and falls back to the bundled font if it was removed.

Catalog tab (song sheet → Remote Config)

For the PO: when the song sheet changes, Read sheet & convert turns it into the catalog payload the app reads from Remote Config (song_catalog), then Copy JSON → paste in the Firebase console → Publish. The conversion is scripts/catalog-sync/remote-catalog.ts (shared with the build-time sync and bun run catalog:publish-remote) and the result is round-tripped through the app's own PayloadParser, so what you copy is what phones accept.

  • Server: POST /api/catalog/export { sheetUrl?, minAppVersion? } → { json, version, sha256, stats, warnings, vsBundled, fileNames }; GET /api/catalog/defaults. Only https://docs.google.com/spreadsheets/… URLs are fetched (isAllowedSheetUrl).
  • From a repo checkout the export keeps the bundled songs' file names and reports songs added / missing versus songs.json (fileNames: "repo"); a packaged app has no checkout and derives names from the sheet ("sheet-only").
  • A malformed sheet row is skipped with a warning naming its row number; an empty sheet is an error.
  • Full workflow and limits: features/catalog.md.

Sound tab (realtime audio tuning)

A Music Specialist tunes the app's piano sound while it plays. Edits are live on the device; nothing is written into the repo until a developer bakes an approved sound into the defaults.

The model. The sound is the instrument-sampler prototype's, one piano group, in its units: envelope (attack / hold / decay / sustain dB / release; null = the SoundFont's own), tone (filter, filter envelope, vibrato, spread, tune, drift — each block switches between the SoundFont's own and custom), velocity (soft / linear / hard curve + 1…127 range), mix (volume dB, pan, mute, solo), sends (auto balance or manual dry / reverb / delay), inserts (compressor → amp → EQ → modulation), the shared reverb and delay buses (room type, pre-delay, decay, damping, size, diffusion, cuts, return; ping-pong, tempo sync, feedback, cuts, wobble, return) master (volume dB, 3-band EQ, limiter on / off with ceiling, look-ahead and release) levels (SFX / preview / music output level in dB: SFX and preview cut only, music −60…+6; the bottom of a fader is silent) and limiters (a look-ahead limiter per SFX / backing / preview bus: on, input dB, ceiling dB, look-ahead ms, release ms). Defaults, every range and the clamping live there once (DEFAULT_SOUND, SOUND_RANGES, mergeSound); the DevTool sliders and the app's clamp read the same table.

Messages (packages/network/src/devtool-protocol/audio.ts, validated with valibot on both ends):

DirectionMessagePurpose
UI → apprequest_audio_stateAsk for the full state (sent on selecting a device).
UI → appset_audioDeep-partial patch of the sound, plus soundFont? and autoPlay? (gameplay auto play). Values are clamped by mergeSound. A soundFont patch decodes on the device (async — expect extra audio_state pushes while loading).
UI → appaudio_actiontest_phrase_start, test_phrase_stop, reset_defaults, all_notes_off.
UI → appaudio_meter_subscribeStart / stop the 100 ms meter stream.
app → UIaudio_stateThe full sound, the loaded SF2's own envelope (soundFontEnvelope, the starting point of the envelope sliders), active soundfont, load status, the choice list, test phrase state, autoPlay / autoPlayAvailable. Coalesced at 120 ms.
app → UIaudio_meterPeak, RMS, CPU load, active voices, clipping (a metric the backend cannot measure is null).
app → UIaudio_errorA rejected or failed request.

The relay forwards the four UI → app messages to the sync socket of the chosen deviceId (anything that fails ServerToAppSchema is dropped), broadcasts the app → UI frames tagged with the deviceId, and turns meters off on the phone when the last UI client disconnects.

App side. audio-control-port.ts (the port), audio-sound-state.ts (the session-only Sound being edited), audio-sound.ts (the Sound → engine config / mixer conversion), audio-test-phrase.ts (looping phrase) and src/bootstrap/devtool-audio.ts (composition with the real stores) — details in audio-engine.md. The Sound is session-only: a launch starts from DEFAULT_SOUND and Reset to app defaults returns to it.

Auto play. Gameplay auto play (usePianoUiStore.autoPlayMode) is switched from the Sound tab's Auto play checkbox only — the AUTO pill on the song list is gone. It rides set_audio / audio_state, is session-only (a relaunch starts off) and stays on if the desktop disconnects. Remote Config auto_play still gates it on release builds (autoPlayAvailable; dev builds always allow it).

UI. Laid out like the prototype's screen: the Soundfont dropdown at the top, then collapsible sections — Piano (page tabs Mix & sends / Inserts / Sound; the Sound page has Envelope / Filter / Pitch & stereo / Velocity chips, and a one-line summary shows while a section is closed), Effect buses (shared) (reverb with room-type chips, delay with ping-pong / note-value chips), Master (a boost above 0 dB is real: it rides the limiter's input gain) and App levels & limiters (SFX, Preview, Music faders and a limiter card per bus). Sections start collapsed except Piano and are remembered in localStorage. Sliders send at most one patch per 40 ms; after a local edit the device echo is ignored for 500 ms so a slider never jumps back. Readouts and snapping (−∞ at the bottom of a fader, "off" near zero, 20 kHz = open) follow the prototype. A dot marks controls that differ from the baseline.

Export. Copy as TS defaults copies the whole sound as a literal for SOUND_DEFAULTS in sound-model.ts; the engine and mixer defaults are then updated to match (the parity test in audio-sound.test.ts lists what differs). Set baseline here marks the reference for the “changed” dots.

Presets · import / export. The Presets card (SoundPresets.tsx) keeps named sounds in audio-presets.json on the Mac (≤ 100, names unique case-insensitively): Save current (name + optional note), Load (sends the whole sound to the phone as one set_audio patch), Delete. Export current / per-row Export / Export all download a .json file; Import (drop or choose a file) merges it into the bank through POST /api/audio-presets/import, replacing same-named presets and reporting how many were added / replaced. The file is one format, { version: 1, presets: [{ name, updatedAt, note?, sound }] } (a single config is a bank of one); import also accepts a lone preset object or a bare sound, named after the file. Only the shape is validated on import — the app clamps every value (mergeSound) when the sound is loaded. The SoundFont choice is not part of a preset. Pure helpers and tests: lib/sound-presets-io.ts, tests/sound-presets-io.test.ts.

Not in the Sound tab (prototype only). The prototype's guitar groups, song player / BGM, tap-velocity source, BGM ducking, "Clear tails" and compressor GR meter have no counterpart in the app (no guitars, no recorded backing, no native tail clear / GR read-out), so they are not offered.

Adaptive tempo tab

Live view and tuning of adaptive tempo on a connected phone: a gauge and a chart of m / target over the play (song tempo 1.0 as the reference, decision dots), a tap-offset meter with the lag gate drawn on it, and a Tune live panel — dev mode (rc / off / default), presets and a slider per threshold. A threshold change reaches the running play at once; mode and profile apply from the next play. Tuning is honoured by a development build and by any build with the desktop tools compiled in (EXPO_PUBLIC_ENABLE_DESKTOP_TOOLS=1, e.g. an internal release build; dev.honoured), never by a store build and is persisted on the phone (MMKV adaptive-tempo-dev).

DirectionMessagePurpose
UI → apprequest_adaptive_tempo_stateAsk for the state (sent when the tab opens or the device changes).
UI → appset_adaptive_tempo (v9)patch: devMode, thresholds (merged into the live tuning), clear (keys back to profile / Remote Config), reset (drop all tuning first). forceM (one-shot: jump the running play's multiplier now with a 1 s ramp, clamped 0.3–1; a fresh watch window starts). The app answers with a fresh adaptive_tempo_state.
app → UIadaptive_tempo_stateremote (Remote Config enabled / profile / threshold overrides, live), dev (override mode, honoured in a development or desktop-tools build), effective (outcome of both), config (the policy numbers in force), tuning (the thresholds set from the DevTool) and play (null until a normal-song play mounted; v11 adds song, bars and the musical context of each decision, see below). Coalesced at 250 ms.

play carries the song, whether the policy ran (active, else inactiveReason: off (rc), off (dev), not a normal song, no wait mode), playing (false once left — the last play stays visible), the live m / target / floor, lagMs (median tap offset), the running stats (min / mean m, floor hits, auto-pauses, median pause wait, notes, strays, play time) and the last 40 decisions (bar tick, target m, reason). The tab also keeps a per-device Changes log (Remote Config or dev override flips, effective ON/OFF, play started / ended) with timestamps — that is the answer to "when did it turn on".

Zones wording (tempo logic). Perfect+ / Perfect / Great are ± zones around the hit line — the late side mirrors the early one below it (× pauseZoneScale: Perfect late, Great late) — and only Early (before the line) and Late (after it) are one-sided, with Late = a pause (no tap by the Great-late edge). The Zones card of the simulation and the tuning group Zones · Late = pause use these words.

Simulation (desktop only, no protocol). The tab's left card runs the REAL policy (createAdaptiveTempo + the engine's tempo-ramp maths, imported from @rhythm/engine) against a synthetic song and a model player the way the app's adapter drives it in wait mode: bar lines are evaluated before the notes on them, a late tap inside the mirrored pause zone is a late Perfect / Great, a longer freeze is an auto-pause (and may snap the tempo), and the windows come from the Timing tab. It reads the numbers being edited — the device's config over the sliders' local drafts — so a threshold change reshapes the curve at once, and can be compared with the profile's own numbers (no tuning) for the same player. Shown: the multiplier over the bars (floor / ceiling / the player's comfort tempo, a dot per decision with its reason), the auto-pauses, a stats table (final / min / max / mean tempo, settled-from bar, decisions, direction changes, pauses, Perfect share, time frozen) and the decision list. The player is a model: a comfort tempo (× the song's), a late habit, jitter, blank rate and an optional hard stretch; pressure = tempo in force / comfort, and above 1 the player gets later, jitterier and blanks more. A Scenario picker replaces the constant skill with a player whose skill changes during the song (bad start then recovers, tires, swings, taps late…; the dotted purple line is then the comfort curve). The tab's Presets include Smooth and Calm (simulator-tuned, see adaptive-tempo.md §12). Deterministic per seed. It checks the policy's logic and sensitivity, not real input latency or audio. Code: lib/adaptive-sim.ts (pure, tests/adaptive-sim.test.ts), components/adaptive-simulator.tsx.

Play report (v11). The Play report card exports what a music specialist needs without the build:

  • adaptive-tempo-report-<time>.md — song (authored BPM, time signature, bars, length), summary (min / mean m and the BPM that means, accuracy, auto-pauses), every tempo decision in words (bar, song time, m and BPM before → after, why, lag, recent pauses), a bar-by-bar table (BPM, m, Perfect / Great / Early / Late / Miss, auto-pauses, strays, median tap offset), a note-by-note table (bar, beat in the bar, song time, pitch, judgement, tap offset, pause wait, strays, m, BPM), the policy numbers in force and a short "how to read this".
  • adaptive-tempo-bars-<time>.csv — one row per bar for a spreadsheet; the bar where the tempo was decided also carries the decision (reason code, new m / BPM, signals).
  • adaptive-tempo-notes-<time>.csv — one row per judged note (MIDI key + pitch name, beat, judgement, offset, pause, m, BPM); an empty offset is a miss. Notes can be exported while playing: a live push carries only the notes the desktop has not seen (play.notesFrom = index of notes[0]; the sync client keeps the cursor per connection, a request_adaptive_tempo_state or a reconnect resends all), the desktop appends them (mergeNoteDelta) and asks for the full state when a delta does not continue what it holds. Up to 1500 notes are kept.

The Changes log gets one Decision — Bar 12 (0:34.2): 1.00 → 0.90 (120 → 108 BPM) — slow down — … line per decision, and the development console line ([adaptive-tempo] … decision bar=12 t=34.3s m=1.00→0.90 bpm=120.0→108.0 lag=+82ms pauses=2 …) carries the same fields. Bars and decisions use the song time without the intro padding, so they line up with the audio; bar n is the n-th bar from the song start, a decision at its line applies from that bar on. At most 400 bars and 200 decisions are kept per play. The new wire fields are optional, so an older app simply produces a report without bar data.

App side. features/piano/adaptive-tempo/recorder.ts records the play (fed by useAdaptiveTempo only in a development build or when EXPO_PUBLIC_ENABLE_DESKTOP_TOOLS=1; a store build records nothing), devtool-port.ts composes it with the live Remote Config and dev stores into core/devtool-sync/adaptive-tempo-control.ts, wired in bootstrap/devtool-sync.ts.

Timing tab

Live editing of the hit windows on a connected phone, in musical units. A zone is a subdivision per beat (sub): its length is 60000 / (BPM × sub) ms — the same maths as the delay-time table. At the reference 120 BPM sub 1 = 1/4 = 500 ms, sub 2 = 1/8 = 250 ms, sub 4 = 1/16 = 125 ms, sub 16 = 1/64 = 31.25 ms; dotted is sub × 2/3, triplet sub × 3/2. A bigger sub is a shorter window.

Factory ladder (BASE_TIMING_SUBDIVISIONS, judgement-window-scaling.ts):

Zonesubnotems @ 120
Perfect+81/3262.5
Perfect late grace41/16125
Perfect41/16125
Great late grace21/8250
Great21/8250
Too early11/4500
Audio quantize41/16125

Live window for a song at bpm: clamp(ms@120 × (120 / bpm) ^ bpmScale). bpmScale 1 (default) is exactly 60000 / (bpm × sub) — beat-proportional, so a fast song has shorter windows in ms but the same musical length; 0 keeps the same ms at every tempo; in between blends. Audio quantize is always beat-proportional. The app clamps every value (TIMING_WINDOW_MS_CLAMPS, ordering Perfect+ < Perfect < Great < Too early) and answers with what it holds.

Simulation (left, pinned while you edit). A ruler of the zones on a time axis against the song's beat grid, a lane drawn like the in-app timing layer (hit line, Perfect / Perfect+ bands, Great and Too-early lines, the audio-quantize band, beat / bar lines) with falling notes, and a table of each zone's edge in ms, lane px and note value at the preview BPM. An auto player taps every note at a chosen offset ± jitter (or Manual: Space / Tap) and the judgement counts show what a tapper at that offset would get. It reads the draft values, so a slider reshapes the zones before the device has answered. Pure model: lib/timing-visual.ts (liveWindows, classifyOffsetMs — parity-tested against the engine's classifyHit).

The controls: a number box (sub/beat) + slider (ms @ 120, bounded by the app's clamps) + "snap to note" per zone, with the note name, ms @ 120, ms and lane px at a preview BPM; a BPM-scale slider; presets (Factory, Ladder A tight, Dotted / triplet, Legacy ms = the pre-subdivision 32 / 190 / 25 / 465 / 692 at every tempo for an A/B); Export… / Import… a .json ({ kind: "piano-timing-config", version: 1, subdivisions, quantizeSubdivision, bpmScale, msAt120Bpm }; an import also accepts a bare map of subdivisions or ms @ 120 and replaces the whole config). Moving a slider writes the app's persisted hit-window / quantize stores (the ones the in-app TimingPanel edits), so the next tap of the running song uses it and it survives a relaunch.

DirectionMessagePurpose
UI → apprequest_timing_stateAsk for the state (sent when the tab opens or the device changes).
UI → appset_timing (v12)patch: subdivisions (any of perfectPlus / perfect / perfectLate / great / early, plus the optional greatLate — extra Great grace past perfectLate, 0 = off; "Great late grace" row in the Timing tab), quantizeSubdivision, bpmScale, reset (factory first). One zone cascades its neighbours like a TimingPanel drag; several zones are applied as a set.
app → UItiming_stateconfig (what the app scores with), factory, referenceBpm (120) and limits (ms @ 120 per zone, quantize, bpmScale). Coalesced at 120 ms.

App side: timing-devtool-model.ts (pure: ms @ 120 ↔ sub, patch → clamped snapshot), timing-devtool-port.ts (the stores) behind TimingControlPort (timing-control.ts). Desktop: tabs/TimingTab.tsx, lib/timing.ts.

Haptics tab

Live tuning of the gameplay haptics on a connected phone (physical device only — the simulator has no Taptic Engine). Changes apply to the next haptic of the running song and persist on the phone in a build with EXPO_PUBLIC_ENABLE_DESKTOP_TOOLS=1; any other build boots on the factory numbers, so a tuned value can never reach a store build.

  • Strength — Light / Medium / Strong. One click switches the Perfect tap and hold-complete to a tone of that strength and sets the hold rumble (Medium ≈ today's Perfect tap). The badge shows which bundle the phone matches (factory presets / custom otherwise).
  • Factory numbers (FACTORY_HAPTIC_CONFIG, tuned by the PO from this tab on 23/10/2026; what every build plays until the DevTool changes it): Perfect tap and Hold complete as tones (0.5 / 0.35 and 0.5 / 0.3), hold rumble 0.32 / 0.22, Miss off, rush limiter 9 taps/s · burst 3 · min gap 40 ms · softest 0.5 · window 450 ms. A build whose native module lacks playDiscrete falls back to each event's preset (heavyTap, warning, noteMiss).
  • Per event (Perfect tap, Hold complete, Miss): enable, and either a Tone — one tap at an exact Strength and Sharpness, played with Pulsar's RealtimeComposer_playDiscrete — or a Preset pattern (a fixed Pulsar pattern picked by its app-level intent; Pulsar has no intensity knob for these, so the limiter cannot soften them). Play on phone fires the event as configured, skipping the limiter. Miss is off by default (Game Mode has no miss haptic today).
  • Hold rumble. Enable, strength and sharpness of the sustained rumble (Haptics.startGameHold). Keep sharpness low — a sharp sustained event makes the Taptic Engine buzz audibly.
  • Rush limiter (rush-limiter.ts, in @piano/network/haptics so the app and the tab's chart run the same code). On a rush chart (Rush E) the old fixed 30 ms window still allowed ~33 native calls/s, which smear into a buzz and cost JS-thread time. The limiter keeps ordinary play untouched and thins only sustained density: a min gap (also merges a chord into one haptic), a token bucket (burst taps back to back, then refilled at targetRatePerSec), and softening of the surviving tone taps by target / density (floored at minGain). Density is measured at run time over windowMs — no per-song BPM. Hold-complete is never density-limited; a miss is dropped right after a fired tap. Dropped taps never reach the native engine. Presets: Off (only the 30 ms floor), Balanced (the factory limiter), Calm.
  • Limiter preview chart. Under the engine sliders, a chart runs the same limiter code over a synthetic stream (BPM × subdivision, seconds, chord size — simulateRush in @piano/network/haptics) and redraws as a slider is dragged: one row shows every note asked (grey = played, red = dropped), the other the haptics played, with bar height = strength. It shows which notes would play and how strong, not how it feels. The first 3 s are drawn; the totals (asked / played per second, dropped share, softest strength) cover the whole stream.
  • Rush test & live stats. Feeds a synthetic BPM × subdivision stream (optionally chords) through the real limiter and the Taptic Engine, so a rush chart can be felt without playing it; the stats show asked vs played rate and the dropped share, and a live chart plots the phone's last 20 s of asked vs played rate against the target (from the test or from real play; it falls to zero when the phone goes quiet).
DirectionMessagePurpose
UI → apprequest_haptics_stateAsk for the state (sent when the tab opens or the device changes).
UI → appset_haptics (v14)patch: any of tap / holdComplete / miss (enabled, mode tone|preset, amplitude, sharpness, preset), hold (enabled, amplitude, sharpness), rush (enabled, targetRatePerSec, burst, minGapMs, minGain, windowMs); reset: true first returns to the factory numbers. The app clamps and answers with what it holds.
UI → appplay_hapticevent: tap | holdComplete | miss | hold (about a second) — plays it now, ignoring the limiter.
UI → apphaptic_rush_testrun, and for a start bpm, subdivision, seconds, chord (clamped by the app).
app → UIhaptics_stateconfig, factory, limits, the presets an event can pick, limiter stats (requested / fired / dropped, rates) and rushTestRunning. Coalesced at 150 ms.

App side: gameplay-config.ts (pure config, factory, clamps), gameplay-config-state.ts (live holder), gameplay-config-persist.ts (MMKV, desktop-tools builds only), Haptics.playGameEvent("tap" | "holdComplete" | "miss") / startGameHold() in engine.ts (the gameplay call sites in useMagicJudgement and tap-decorations-defer), and haptics-control.ts (the port + rush-test runner rush-test.ts). Haptics.play(intent) is unchanged for UI, Learn and tutorial haptics. Desktop: HapticsTab.tsx, lib/haptics.ts (bundles, presets, export / import piano-haptics-config).

Device-unverified: how RealtimeComposer_playDiscrete behaves while a hold's RealtimeComposer_set rumble is active (shared native composer — the source is in the Pulsar pod binary). If it ducks the hold, fall back to a cached PatternComposer single-tap pattern per quantized (strength, sharpness).

Settings

With the flag on, Settings shows DEV SYNC: connection, aggregate status (e.g. Syncing 42%), per-file MIDI / SoundFont rows with download percent while syncing, library counts, last sync, the last error, Retry sync and Clear synced data. On the desktop, Devices shows the same per-item percent and progress bars; Library upload shows percent while pushing MIDI or SF2 to the relay.

TestFlight / physical device (no Metro)

  • The phone must reach the Mac over LAN (same Wi‑Fi, or Mac joined to the iPhone Personal Hotspot). 4G alone cannot open ws://172.16.x / 192.168.x on your Mac. If Safari on the phone cannot load http://<mac-lan-ip>:7799, fix network/firewall/AP isolation before debugging QR or deeplinks.
  • Pairing uses the QR deeplink (magicpiano://analytics-bridge?url=ws://…) — TestFlight never auto-connects via Metro. Scan once; the app persists the endpoint in MMKV.
  • Internal iOS builds with EXPO_PUBLIC_ENABLE_DESKTOP_TOOLS=1 add NSLocalNetworkUsageDescription (plugins/withDevtoolLocalNetwork.ts). After install, allow Settings → Privacy & Security → Local Network → Magic Piano if iOS prompts or blocks the socket.

Known limitations

  • Backing tracks (BGM) are intentionally not synced.
  • Downloads retry from scratch; there is no HTTP Range resume.
  • sha256 verification is skipped above 32 MB (hashing needs the file in memory); a size check still applies.
  • Clear dev data is undone by the next reconnect, because the relay re-pushes the manifest on hello. Remove the SF2 from On relay under the SF2 upload card, or a dev song via App song list → Remove, to make it permanent.

Tests

  • Tool: bun test --isolate tools/piano-devtool-desktop (bun run test:app:tools) — includes tests/audio.test.ts (relay routing, presets), tests/audio-control.test.ts (ranges, patch batching, TS export) and tests/sound-format.test.ts (readouts), tests/catalog-export.test.ts + tests/catalog-export-lib.test.ts (sheet → catalog export).
  • Protocol: packages/network/tests/haptics-protocol.test.ts, packages/network/tests/devtool-protocol.test.ts, packages/network/tests/audio-protocol.test.ts, packages/network/tests/sound-model.test.ts.
  • App: src/core/devtool-sync/__tests__ (incl. haptics-control.test.ts), src/core/services/haptics/__tests__ (rush limiter, config, game events, rush test), src/bootstrap/__tests__, src/features/catalog/__tests__, src/features/settings.