freecoding.school100% FREE · NO SIGNUP
API ArcadeISSUE #3 of 23

web audio api · oscillators · gain · context

ApiaVSLegacy Larry
Apia saysThe Web Audio API builds sound from nodes — oscillators, gain, filters — in an audio graph.

Create an AudioContext, then wire nodes: an OscillatorNode (tone) → GainNode (volume) → context.destination (speakers). It's a routing graph for synthesis, effects, and analysis (visualizers). The context must be started/resumed from a user gesture due to autoplay rules.

Power-ups you unlock

Legacy Larry attacks — common mistakes

Boss battleSketch a beep: oscillator → gain → destination, started on click.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;padding:20px"><button id="b">beep</button>
<script>document.getElementById('b').onclick=()=>{const ctx=new AudioContext();const osc=ctx.createOscillator();const g=ctx.createGain();osc.connect(g);g.connect(ctx.destination);g.gain.value=0.1;osc.frequency.value=440;osc.start();osc.stop(ctx.currentTime+0.2);};</script></body></html>
▶ Open the interactive comic issue
‹ Webgl · The 3d Gpu InterfaceWebrtc · Peer-To-Peer Media ›