大网数据广告活动
Web 标准与前端开发

PannerNode

· 52CE 我爱测

The `PannerNode` interface defines an audio-processing object that represents the location, direction, and behavior of an audio source signal in a simulated physical space. This AudioNode uses right-hand Cartesian coordinates to describe the source's _position_ as a vector and it

Web Audio API

The PannerNode interface defines an audio-processing object that represents the location, direction, and behavior of an audio source signal in a simulated physical space. This AudioNode uses right-hand Cartesian coordinates to describe the source's position as a vector and its orientation as a 3D directional cone.

A PannerNode always has exactly one input and one output: the input can be mono or stereo but the output is always stereo (2 channels); you can't have panning effects without at least two audio channels!

The PannerNode defines a spatial position and direction for a given signal.

<table class="properties"> <tbody> <tr> <th scope="row">Number of inputs</th> <td><code>1</code></td> </tr> <tr> <th scope="row">Number of outputs</th> <td><code>1</code></td> </tr> <tr> <th scope="row">Channel count mode</th> <td><code>"clamped-max"</code></td> </tr> <tr> <th scope="row">Channel count</th> <td><code>2</code></td> </tr> <tr> <th scope="row">Channel interpretation</th> <td><code>"speakers"</code></td> </tr> </tbody> </table>

Constructor

  • PannerNode.PannerNode
    • : Creates a new PannerNode object instance.

Instance properties

Inherits properties from its parent, AudioNode.

[!NOTE] The orientation and position value are set and retrieved using different syntaxes, since they're stored as AudioParam values. Retrieval is done by accessing, for example, PannerNode.positionX. While setting the same property is done with PannerNode.positionX.value.

  • PannerNode.coneInnerAngle
    • : A double value describing the angle, in degrees, of a cone inside of which there will be no volume reduction.
  • PannerNode.coneOuterAngle
    • : A double value describing the angle, in degrees, of a cone outside of which the volume will be reduced by a constant value, defined by the coneOuterGain property.
  • PannerNode.coneOuterGain
    • : A double value describing the amount of volume reduction outside the cone defined by the coneOuterAngle attribute. Its default value is 0, meaning that no sound can be heard.
  • PannerNode.distanceModel
    • : An enumerated value determining which algorithm to use to reduce the volume of the audio source as it moves away from the listener. Possible values are "linear", "inverse" and "exponential". The default value is "inverse".
  • PannerNode.maxDistance
    • : A double value representing the maximum distance between the audio source and the listener, after which the volume is not reduced any further.
  • PannerNode.orientationX
    • : Represents the horizontal position of the audio source's vector in a right-hand Cartesian coordinate system. While this AudioParam cannot be directly changed, its value can be altered using its AudioParam.value property. The default is value is 1.
  • PannerNode.orientationY
    • : Represents the vertical position of the audio source's vector in a right-hand Cartesian coordinate system. The default is 0. While this AudioParam cannot be directly changed, its value can be altered using its AudioParam.value property. The default is value is 0.
  • PannerNode.orientationZ
    • : Represents the longitudinal (back and forth) position of the audio source's vector in a right-hand Cartesian coordinate system. The default is 0. While this AudioParam cannot be directly changed, its value can be altered using its AudioParam.value property. The default is value is 0.
  • PannerNode.panningModel
    • : An enumerated value determining which spatialization algorithm to use to position the audio in 3D space.
  • PannerNode.positionX
    • : Represents the horizontal position of the audio in a right-hand Cartesian coordinate system. The default is 0. While this AudioParam cannot be directly changed, its value can be altered using its AudioParam.value property. The default is value is 0.
  • PannerNode.positionY
    • : Represents the vertical position of the audio in a right-hand Cartesian coordinate system. The default is 0. While this AudioParam cannot be directly changed, its value can be altered using its AudioParam.value property. The default is value is 0.
  • PannerNode.positionZ
    • : Represents the longitudinal (back and forth) position of the audio in a right-hand Cartesian coordinate system. The default is 0. While this AudioParam cannot be directly changed, its value can be altered using its AudioParam.value property. The default is value is 0.
  • PannerNode.refDistance
    • : A double value representing the reference distance for reducing volume as the audio source moves further from the listener. For distances greater than this the volume will be reduced based on rolloffFactor and distanceModel.
  • PannerNode.rolloffFactor
    • : A double value describing how quickly the volume is reduced as the source moves away from the listener. This value is used by all distance models.

Instance methods

Inherits methods from its parent, AudioNode.

  • PannerNode.setPosition()
    • : Defines the position of the audio source relative to the listener (represented by an AudioListener object stored in the BaseAudioContext.listener attribute.)
  • PannerNode.setOrientation()
    • : Defines the direction the audio source is playing in.

Examples

See BaseAudioContext.createPanner() for example code.

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。