AudioListener - Verge3D User Manual - Soft8Soft
Description: Learn how to use AudioListener in your interactive 3D apps made with Verge3D

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.

## Code Example

`// create an AudioListener and add it to the camera const listener = new v3d.AudioListener(); app.camera.add(listener); // create a global audio source const sound = new v3d.Audio(listener); // load a sound and set it as the Audio object's buffer const audioLoader = new v3d.AudioLoader(); audioLoader.load('myaudio.mp3', 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 : Float

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

## Methods

### # .getInput() → GainNode

Return the gainNode.

### # .removeFilter() → this

Set the filter property to `null`.

### # .getFilter() → AudioNode

Returns the value of the filter property.

### # .setFilter(value : AudioNode) → this

Set the filter property to `value`.

### # .getMasterVolume() → Float

Return the volume.

### # .setMasterVolume(value : Float) → this

Set the volume.

## Puzzles

Verge3D offers audio puzzles to simplify work with sounds and music.

## Source

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