Driven by the live fresh-eyes finding: a naive racer finishes with 0% paint — the core mechanic is currently skippable. G makes paint route-guaranteed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2.6 KiB
2.6 KiB
Lane F — Audio (procedural, event-driven)
Owns: src/audio/, demos/lane-f.html, src/demo/lane-f.ts.
Never touches: contracts, world, game, main, package.json, other lanes' dirs.
No new deps, no audio asset files — everything synthesized with WebAudio
(oscillators, noise buffers, filters, envelopes). Comedy > realism.
Mission
BLOBBO is silent. Sound is half the comedy of a wobble game. Build a tiny procedural sound engine that reacts to the frozen wire events only.
Deliverables (src/audio/)
engine.ts—AudioEngine: lazyAudioContext(create/resume ONLY after theui:playevent or first user gesture — browsers block earlier), master gain, mute toggle (persist in localStorageblobbo:muted), and a small polyphony cap (~8 voices) so event storms don't clip.sounds.ts— synthesized one-shots, all pitch-randomized ±10% per play:- squish (blob:landed — gain and pitch scale with
impact; big drops = big splat) - boing (blob:jumped — springy sine sweep; also used by the gap launcher)
- splat (paint:splatted target:'blob' — wet noise burst; slightly different pitch per colour, use PALETTE order for a pentatonic-ish mapping)
- sparkle (paint:request-cleanse — bubbly arpeggio)
- clank+windup (machine:signal — ratchet tick accelerating ~0.5s, matches the telegraph)
- fanfare (race:finished — dumb triumphant 4-note; extra flourish if new best)
- tick (race:started — single starter blip)
- optional ambient: very quiet lo-fi room tone / conveyor hum when near machines — only if cheap.
- squish (blob:landed — gain and pitch scale with
install.ts—installAudio(world): subscribes to the events above onworld.events, returns{ engine }. Listens forui:playto unlock. A tiny 🔈/🔇 DOM button bottom-right toggles mute.- Demo
demos/lane-f.html+src/demo/lane-f.ts: sound board — a button per sound + sliders for the impact parameter. Verifies every sound in isolation.
Acceptance
npm run buildpasses. No AudioContext created before first gesture/ui:play(verify: constructing the engine logs nothing andctx === nulluntil unlock).- Every listed event produces a distinct, non-clipping sound; rapid splat storms (10/s) stay clean via the voice cap.
- Mute persists across reloads.
- Sounds are SHORT (<400ms except fanfare) and mixed well below pain (master ~-12dB).
Events you consume (never emit gameplay events)
blob:landed {impact}, blob:jumped, paint:splatted {color,target},
paint:request-cleanse, machine:signal {id}, race:started,
race:finished {time,best}, ui:play (from Lane H's title screen).