Interface AudioListener

This interface represents the position and orientation of the person listening to the audio scene. All PannerNode objects spatialize in relation to the AudioContext's listener. See this section for more details about spatialization.

Index

Properties

Methods

Properties

public dopplerFactor: number

A constant used to determine the amount of pitch shift to use when rendering a doppler effect. The default value is 1.

public speedOfSound: number

The speed of sound used for calculating doppler shift. The default value is 343.3 meters / second.

Methods

public setOrientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number)

Describes which direction the listener is pointing in the 3D cartesian coordinate space. Both a front vector and an up vector are provided. In simple human terms, the front vector represents which direction the person's nose is pointing. The up vector represents the direction the top of a person's head is pointing. These values are expected to be linearly independent (at right angles to each other). For normative requirements of how these values are to be interpreted, see the spatialization section.

Parameters

  • x: number

    x coordinate of a front direction vector in 3D space, with the default value being 0

  • y: number

    y coordinate of a front direction vector in 3D space, with the default value being 0

  • z: number

    z coordinate of a front direction vector in 3D space, with the default value being -1

  • xUp: number

    x coodinate of an up direction vector in 3D space, with the default value being 0

  • yUp: number

    y coodinate of an up direction vector in 3D space, with the default value being 1

  • zUp: number

    z coodinate of an up direction vector in 3D space, with the default value being 0

public setPosition(x: number, y: number, z: number)

Sets the position of the listener in a 3D cartesian coordinate space. PannerNode objects use this position relative to individual audio sources for spatialization.

The default value is (0,0,0)

Parameters

  • x: number
  • y: number
  • z: number

public setVelocity(x: number, y: number, z: number)

Sets the velocity vector of the listener. This vector controls both the direction of travel and the speed in 3D space. This velocity relative to an audio source's velocity is used to determine how much doppler shift (pitch change) to apply. The units used for this vector is meters / second and is independent of the units used for position and orientation vectors.

Parameters

  • x: number

    x coordinate of a direction vector indicating direction of travel and intensity. The default value is 0

  • y: number

    y coordinate of a direction vector indicating direction of travel and intensity. The default value is 0

  • z: number

    z coordinate of a direction vector indicating direction of travel and intensity. The default value is 0