Architecture and Data
From source MIDI bytes to a verified score
Version 1.0.0 inlines the UI, worker, synthesizer and built-in scores in a single local HTML file. Playback becomes available only after the physics replay passes.
Main modules
| Source Files | Responsibilities and Invariants |
|---|---|
| midi.mjs / instruments.mjs | Parse bounded SMF format 0 or 1 with PPQ timing. Merge program changes for each channel across tracks. Bind each note to its program at onset. Tracks, channels and programs identify parts, including parts with the same instrument. |
| quartet.mjs / examples.mjs | Generate the quartet, octet and older samples from note events. Built-in and imported scores use the same parser. |
| orchestra-score.mjs / phrase.mjs | Validate seats and passages, integrate the tempo map, group simultaneous onsets and read or write versioned projects. These modules run independently of the DOM. |
| ensemble.mjs / sequence.mjs | Search independently for each seat, divide paths into rooms and collect collisions. The duet and the ensemble use the same result structure. |
| solver.mjs / physics.js / reverse.mjs | Replay physics at fixed 1/120-second steps. Verify collision order, pitches, timing and whether the path is reversible. Preserve the original game wall geometry, scales, octave markings and chord rules. |
| orchestra.mjs / orchestra-stage.mjs | Handle rehearsal state, background tasks, mixer controls, Canvas paths and the score timeline. Separate and shared views project the same data. Balls do not collide with each other. |
| monitor.mjs / loudness.mjs / eq.mjs | Route every live AudioContext through preamp, ten biquad EQ bands (bypassed while off), the listening volume and analysers. Measure sample peak, RMS, stereo correlation and BS.1770 loudness from K-weighted samples. Offline WAV renders skip the monitor. |
| hifi.mjs / hifi-draw.mjs | Run the Listening Room: move the active stage into a full-screen overlay, drive its transport through a view adapter, and draw the spectrum, meters, vectorscope and EQ graph. Layout, EQ and volume are stored in localStorage. |
| stage-fx.mjs / duet-room.mjs | Draw every stage with one renderer: night backdrop, auto-fit camera, pitch-colored glowing walls, comet trail, hit ripples, sparks and note names, the searching overlay and the solved reveal. Effects are pure functions of playback time, so pause, loop and reverse play redraw exactly. |
| orchestra-audio.mjs / ensemble-sound.mjs / audio.js | Provide a shared clock, per-seat audio buses and nine synthesized sounds. Playback and WAV export share routing and gain rules. |
Timing and data
Internal positions count quarter-note beats from zero. The interface displays that value plus one. A passage [firstBeat,lastBeat) collects only onsets inside the interval. The app integrates the source tempo map in sections. The physics tempo rounds the opening tempo and clamps it to 60-140 BPM. Converted events retain their original times in seconds. Shared lead-in is lead=30/bpm. Total stage duration is the passage duration plus twice the lead-in.