foundation/transport.mjsv1
MusicalTransport — real PLL with phase correction, octave-fold, gap recovery, confidence decay. 3 distinct times (observed/estimated/predicted). Re-anchors only at bar boundaries.
15 tests · A–J × 5 seeds412 lines
Inspired by psy5 (TransportClock + 4 components, 250 tests) + psy4 BeatPLL (with documented confidence bug avoided).
foundation/dsp.mjsv1
PolyBLEP saw/square/triangle/pulse + ZDF SVF (cytomic) + 4-op FM + 6 wavetables + Adsr + saturation. Pure functions, bit-identical per seed.
40 tests~500 lines
Inspired by PsySynthPro (PolyBLEP+ZDF+FM+wavetable) + psy-foundation packages/dsp.
foundation/director.mjsv1
MusicalDirector with DO-NOTHING abstention. 5 conditions: low transport.confidence, unlocked, low energy + barsSinceRest>4, dense previous bar, rewardPrediction<threshold. EMA reward tracker.
12 tests293 lines
Inspired by psy5 contextual bandit with abstainThreshold.
foundation/grammar.mjsv1
3 grammar classes: BassGrammar (12×12 matrix), MelodicGrammar (25-bucket histogram), RhythmGrammar (16-step Bayesian). applyGrammarVariation preserves original timeline; mutated events carry provenance.
12 tests412 lines
Inspired by PSY6-ULTIMATE (3 grammar classes, 15 refs in index.html).
foundation/render.mjsv1
Offline render + per-device stem export + WAV encoder. renderPlan is pure; renderSong accepts injected AudioContext (metadata mode in Node, full render in browser). Byte-identical per seed.
11 tests278 lines
Inspired by psy-sampler (28× real-time, byte-identical per seed).
foundation/midi.mjsv1
Web MIDI input (defensive in Node) + 24ppq MidiClockOut + timelineToMidiFile (SMF0, 480 ticks/beat, Tempo meta, End of track). encodeVarLen/decodeVarLen.
15 tests358 lines
Inspired by psystar (24ppq clock) + PSY6-ULTIMATE (SMF0 export).