1The recipe for a gust of air
The base is pink noise (gentler than white noise, it “sounds” more like air) run through a lowpass filter. The stronger the wind, the wider the filter opens and the higher the volume — the air becomes both more present and brighter.
const src = ctx.createBufferSource(); // pink-noise loop src.buffer = pinkNoise; src.loop = true; const lp = ctx.createBiquadFilter(); // a lowpass filter lp.type = 'lowpass'; lp.frequency.value = 180 + k * 2400; // k = |wind| / MAX_WIND, 0 to 1 src.connect(lp).connect(gain).connect(out);
On top of that base we layer, as needed, a resonance (a singing bandpass) for the howl, or gusts driven by slow oscillators. Four assemblies give four characters.
2Adapt to strength, reveal the heading
A single value drives everything: the game's wind, from −95 to +95 px/s². Its magnitude (0 to 1) opens the filter, raises the volume and deepens the gusts; its sign gives the direction (positive = rightward).
To hear that heading, the sound leans across the stereo field toward the side the wind blows (the stronger it is, the more it leans). And in “directional gust” mode, a gust travels across your headphones left to right (or the reverse), swelling as it passes: you can't mistake the ear.
StereoPannerNode: pan = sign · strength, from −1 (hard left) to +1 (hard right). The travelling gust simply animates that pan over time.3TV spatialization — stereo, depth & timbre
The TV convention: left/right via stereo pan (X position), front-to-back via the depth volume, and up-down via a slight timbre tilt — brighter up top, deeper down low. Pick a sound, then click the battlefield to emit it at that position.