PSY — Winning Device

canonical psytrance groovebox · the winning device of the PSY family
164
tests green
+105
new tests
6
foundation modules
12
sibling repos studied

Status foundation layer complete · runtime integration partial

W1 MusicalTransport — PLL with octave-fold, gap recovery, confidence decay (15 tests A–J × 5 seeds)
W2 DSP primitives — PolyBLEP + ZDF SVF + FM + wavetable (40 tests)
W4 MusicalDirector — DO-NOTHING abstention, 5 conditions (12 tests)
W5 Grammar learning — 3 classes with provenance (12 tests)
W6 Render — offline + stems + WAV encoder (11 tests)
W7 MIDI — Web MIDI + 24ppq clock + SMF0 export (15 tests)
W8 PWA + service worker + self-diagnose — inline via Blob URL in index.html
W9 Foundation loader — index.html exposes window.PSY_FOUNDATION (additive, non-breaking)
W3 AudioWorklet in live path — deferred (needs browser verification)
W11 registry promotion — DONE (6 components ADMITTED v1)

Foundation modules ADMITTED v1 · pure ESM · zero deps

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).

The roast 10 hard truths · evidence-grounded · cited with file:line

Architecture is more sophisticated than the product. PSY6_ARCHITECTURE.md describes 5 layers, 3 distinct times, 10 test streams A–J. None of it was built. FOUNDATION_VERSION.md admits "NOTHING promoted yet."
The foundation is dead — it does not run. foundation/foundation.mjs is 28.4KB of excellent pure code. index.html has its own inline copy of all the model logic. Double maintenance.
Scheduler is from 2015. setInterval(scheduler, 25) at index.html:885. CROSS_REPO_AUDIT flags it as risk #1: background-tab stalls. PsySynthPro proved a real AudioWorklet fits in 18KB.
No real DSP. None. Zero PolyBLEP. Zero ZDF. Zero wavetable. Zero FM. PsySynthPro runs all of these per-sample. You call yourself "Professional Psytrance Workstation."
Beat detection = zero. 145 lines on latency model in architecture doc. Product: bpm = 120 + v*45 from a knob. psy4 faked confidence with low-band energy. psy5 built the real thing.
"Learning" is seed++. PSY6-ULTIMATE learns 3 grammars while you play. psystar syncs P2P. psy5 has contextual bandit with abstention. You increment a constant.
Smallest test suite in the family. 59 tests vs psy-foundation's 729, psy-sampler's 653, psy5's 250. The most important contract — A–J — exists in NO repo.
Every "modern" capability — missing. No PWA, no MIDI clock out, no offline render, no stem export, no arrangement undo, no provenance gate, no DO-NOTHING abstention, no soak test.
Credentials leaked in a chat session. PSY6_ARCHITECTURE.md §9.9: "leaked credentials (turso.txt) — ROTATE ALL." Listed as open risk for months. Unresolved security incident.
The painful contradiction. Your own architecture says "Build less. Connect better. Measure everything. One source of truth. One musical clock." You built more, connected less, measured once, have two sources of truth, and zero clocks.

Documentation committed to the repo

Run the tests Node 24+ · zero deps

# clone + run
git clone https://github.com/dudududi144-source/psy.git
cd psy
node --test tests/*.test.mjs tests/foundation-consumer/*.test.mjs
# expected output
ℹ tests 164
ℹ pass 164
ℹ fail 0