web audio

Demonstrates the use of the Web Audio API to produce spatialized audio. Note how the volume changes as you move closer to or further from the cube (drag middle mouse button). Note also how the sound is louder when you face the side of the cube that you first see when the app loads (drag left mouse button to orbit).

What if you wanted something simpler: a sound that plays at the same volume regardless of where the listener is? This is useful for atmospheric noises (wind, birds chirping, etc.). Instead of a panner node, a gain node could be used. It can be created via

var gainNode = audioContext.createGainNode();

its volume set between zero and one via, e.g.

gainNode.gain.value = 0.5;

and then connected to the source and destination the same as the panner in the example.

example 28: web audio