Capítulo 302 de 859

Chapter 302: AudioListener

Core Idea

The class represents a virtual listener of the all positional and non-positional audio effects in the scene. A three.js application usually creates a single listener. It is a mandatory constructor 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.

Key Concepts

  • context : AudioContext (readonly): The native audio context.
  • filter : AudioNode (readonly): An optional filter.
  • gain : GainNode (readonly): The gain node used for volume control.
  • timeDelta : number (readonly): Time delta values required for linearRampToValueAtTime() usage.

Reference Tables

Constructor

Signature
new AudioListener()

Properties

PropertyDescription
.context : AudioContext (readonly)The native audio context.
.filter : AudioNode (readonly)An optional filter.
.gain : GainNode (readonly)The gain node used for volume control.
.timeDelta : number (readonly)Time delta values required for linearRampToValueAtTime() usage.

Methods

MethodDescription
.getFilter() : AudioNodeReturns the current set filter.
.getInput() : GainNodeReturns the listener's input node.
.getMasterVolume() : numberReturns the applications master volume.
.removeFilter() : AudioListenerRemoves the current filter from this listener.
.setFilter( value : AudioNode ) : AudioListenerSets the given filter to this listener.
.setMasterVolume( value : number ) : AudioListenerSets the applications master volume. This volume setting affects all audio nodes in the scene.

Key Takeaways

  1. AudioListener extends: EventDispatcher → Object3D
  2. Most relevant properties: context, filter, gain, timeDelta.
  3. Key methods: getFilter, getInput, getMasterVolume, removeFilter.

Connects To