Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. AudioListener

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.

We see the position, up and front vectors of an AudioListener, with the up and front vectors at 90° from the other.

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.positionX

Represents the horizontal position of the listener in a right-hand cartesian coordinate system. The default is 0.

AudioListener.positionY

Represents the vertical position of the listener in a right-hand cartesian coordinate system. The default is 0.

AudioListener.positionZ

Represents the longitudinal (back and forth) position of the listener in a right-hand cartesian coordinate system. The default is 0.

AudioListener.forwardX

Represents 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.forwardY

Represents 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.forwardZ

Represents 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.upX

Represents 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.upY

Represents 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.upZ

Represents 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()Deprecated

Sets the orientation of the listener.

AudioListener.setPosition()Deprecated

Sets the position of the listener.

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

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp