WebMIDI · Music Theory · Real-time Signal Processing · 2026 · Solo — popularity-led research, Krumhansl-Schmuckler key-finding implementation, WebMIDI API integration, SVG piano roll renderer, lead sheet exporter, TDD, exact-SHA deployment
Note Roll
Real-time MIDI performance capture → Krumhansl-Schmuckler key detection → chord segmentation → exportable SVG lead sheet. All browser-local, no upload.
The problem
Musicians improvising melodic ideas face a painful workflow gap: voice memos capture audio but produce no structure, while notation software (Sibelius, MuseScore) requires expertise. The missing tool is zero-setup performance capture that instantly produces a shareable lead sheet showing key, chords, and a visual piano roll. The nightly concept came from secure inline radar run inline-20260902T231000-0700-github-star-radar: google-research/timesfm was daily rank #10 with 343 stars gained on 2026-09-02 and 30,184 total stars. Ranks 1-9 were exhausted with source-backed veto codes (RECENT_PORTFOLIO_DUPLICATE for ponytail/study-sync structural overlap, NO_MEANINGFUL_REAL_INPUT for agent-skills-collection-only sources, ONE_NIGHT_INFEASIBLE for LLM-runtime-dependent products, and LICENSE_OR_SAFETY for NousResearch/hermes-agent). TimesFM's domain — recognizing patterns in temporal data streams — maps directly to music performance as a real-time temporal data source. The adjacent product translates TimesFM's conceptual domain (temporal pattern recognition) into an original music capture tool, with no affiliation with Google Research and no use of the TimesFM model or weights.
Architecture
Key decisions
Krumhansl-Schmuckler algorithm from the 1982 psychoacoustics paper
Key detection is a Pearson correlation of a velocity-weighted pitch-class histogram against 24 key profiles (12 major, 12 minor) from Krumhansl and Kessler's 1982 psychoacoustic study. No external music library — the 24 profiles are embedded as typed arrays, the correlation is computed in pure TypeScript, and the result is a key name with a 0–1 confidence score. This means the algorithm is fully unit-testable and has no WASM or native dependency.
On-screen piano as a complete fallback — not a compromise
WebMIDI requires Chrome and a class-compliant device; most users don't have either. The SVG piano keyboard fires the identical MidiEvent interface as hardware MIDI, so the entire music engine pipeline is exercised without any hardware. The golden path is designed around the on-screen keyboard, not hardware MIDI — hardware is the enhancement, not the default.
50ms chord window balances block chords and arpeggios
A simultaneous block chord on a piano has realistic 10–40ms spread between key presses. A deliberate arpeggio has 100–400ms spacing. The 50ms window groups block chords into single segments while keeping arpeggiated lines as separate single-note segments. This produces musically correct chord labels without requiring the user to hold notes precisely.
TDD before any UI — 34 tests watched fail before implementation existed
All seven music-engine functions were specified as tests first (music-engine.test.ts). Each test was run and confirmed to fail before lib/music-engine.ts was written. The test suite covers: empty histogram (all zeros), velocity weighting, pitch class indexing, C/G major and A minor scale detection, chord template matching across 60 templates, chord window segmentation with noteoff filtering, tempo estimation from median IOI at 120 and 180 BPM, and buildPerformanceData completeness invariants.