Object3D

AudioListener

The AudioListener represents a virtual listener of the all positional and non-positional audio effects in the scene.
A Verge3D application usually creates a single instance of AudioListener. It is a mandatory construtor parameter for audios entities like Audio and PositionalAudio.
In most cases, the listener object is a child of the camera. So the 3D transformation of the camera represents the 3D transformation of the listener.

Example

webaudio / sandbox
webaudio / timing
webaudio / visualizer

// create an AudioListener and add it to the camera var listener = new v3d.AudioListener(); camera.add(listener); // create a global audio source var sound = new v3d.Audio(listener); // load a sound and set it as the Audio object's buffer var audioLoader = new v3d.AudioLoader(); audioLoader.load('sounds/ambient.ogg', function(buffer) { sound.setBuffer(buffer); sound.setLoop(true); sound.setVolume(0.5); sound.play(); });

Constructor

AudioListener()

Create a new AudioListener.

Properties

.context : AudioContext

The AudioContext of the listener given in the constructor.

.gain : GainNode

A GainNode created using AudioContext.createGain().

.filter : AudioNode

Default is null.

.timeDelta : Number

Time delta value for audio entities. Use in context of AudioParam.linearRampToValueAtTimeDefault(). Default is 0.

Methods

.getInput () : GainNode

Return the gainNode.

.removeFilter () : AudioListener

Set the filter property to null.

.getFilter () : AudioNode

Returns the value of the filter property.

.setFilter (value : AudioNode) : AudioListener

Set the filter property to value.

.getMasterVolume () : Float

Return the volume.

.setMasterVolume (value : Number) : AudioListener

Set the volume.

Source

For more info on how to obtain the source code of this module see this page.