AudioListener
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
TheAudioListener interface represents the position and orientation of the unique person listening to the audio scene, and is used inaudio spatialization. AllPannerNodes spatialize in relation to theAudioListener stored in theBaseAudioContext.listener attribute.
It is important to note that there is only one listener per context and that it isn't anAudioNode.

In this article
Instance properties
Note:The position, forward, and up value are set and retrieved using different syntaxes. Retrieval is done by accessing, for example,AudioListener.positionX, while setting the same property is done withAudioListener.positionX.value. This is why these values are not marked read only, which is how they appear in the specification's IDL.
AudioListener.positionXRepresents the horizontal position of the listener in a right-hand cartesian coordinate system. The default is 0.
AudioListener.positionYRepresents the vertical position of the listener in a right-hand cartesian coordinate system. The default is 0.
AudioListener.positionZRepresents the longitudinal (back and forth) position of the listener in a right-hand cartesian coordinate system. The default is 0.
AudioListener.forwardXRepresents the horizontal position of the listener's forward direction in the same cartesian coordinate system as the position (
positionX,positionY, andpositionZ) values. The forward and up values are linearly independent of each other. The default is 0.AudioListener.forwardYRepresents the vertical position of the listener's forward direction in the same cartesian coordinate system as the position (
positionX,positionY, andpositionZ) values. The forward and up values are linearly independent of each other. The default is 0.AudioListener.forwardZRepresents the longitudinal (back and forth) position of the listener's forward direction in the same cartesian coordinate system as the position (
positionX,positionY, andpositionZ) values. The forward and up values are linearly independent of each other. The default is -1.AudioListener.upXRepresents the horizontal position of the top of the listener's head in the same cartesian coordinate system as the position (
positionX,positionY, andpositionZ) values. The forward and up values are linearly independent of each other. The default is 0.AudioListener.upYRepresents the vertical position of the top of the listener's head in the same cartesian coordinate system as the position (
positionX,positionY, andpositionZ) values. The forward and up values are linearly independent of each other. The default is 1.AudioListener.upZRepresents the longitudinal (back and forth) position of the top of the listener's head in the same cartesian coordinate system as the position (
positionX,positionY, andpositionZ) values. The forward and up values are linearly independent of each other. The default is 0.
Instance methods
AudioListener.setOrientation()DeprecatedSets the orientation of the listener.
AudioListener.setPosition()DeprecatedSets the position of the listener.
Note:Although these methods are deprecated they are currently the only way to set the orientation and position in Firefox (seeFirefox bug 1283029).
Deprecated features
ThesetOrientation() andsetPosition() methods have been replaced by setting their property value equivalents. For examplesetPosition(x, y, z) can be achieved by settingpositionX.value,positionY.value, andpositionZ.value respectively.
Example
SeeBaseAudioContext.createPanner() for example code.
Specifications
| Specification |
|---|
| Web Audio API> # AudioListener> |