Split The code is public; the app answers only to the crew.

`audio.ts` has never been tested: a recording AudioContext, the way the renderer has a recording GL context #152

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Pushed. `bun run check` passes (types + all 681 tests, up from 680).

shipped merged

opened this

Pushed. bun run check passes (types + all 681 tests, up from 680).

audio.ts now takes its AudioContext constructor as an argument to createAudio(Ctor = window.AudioContext ?? webkitAudioContext) — the only production change, and main.ts's call site (createAudio()) is untouched.

src/client/audio.test.ts is new: a fake AudioContext (FakeAudioContext/FakeNode/FakeParam, mirroring recorder() in renderer.test.ts) that logs every node created, every connect edge, every .value set and every scheduled ramp. Tests cover:

  • no context is built until the first sound or resume(), and only once
  • muted makes zero nodes; setMuted(false) restores sound
  • a volume set before the first sound lands on master once it exists; setVolume(NaN) keeps the old volume; volume clamps to 0..1
  • a shot's pan sign agrees with ears() for left/right, and a shot past the reference distance is quieter than a near one
  • pain twice inside 140ms plays once, and again once the window passes
  • world("beep", …, pitch) uses the given pitch, falls back to the table frequency otherwise; explode/blast share a path and ignore pitch; an unknown name creates only the panner
  • a hundred shots cost exactly 1 + 100*6 nodes, and every started source/oscillator has a matching stop

Nothing about the synthesis itself was touched. README's "everything except the last five is headless" line is corrected to four, with audio moved into the same "checked against a recording context" bucket as renderer/hud.

Closes #80

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs