PannerNode
The PannerNode
interface represents the position and behavior of an audio source signal in space. It is an AudioNode
audio-processing module describing its position with right-hand Cartesian coordinates, its movement using a velocity vector and its directionality using a directionality 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!
Number of inputs | 1 |
---|---|
Number of outputs | 1 |
Channel count mode | "clamped-max" |
Channel count | 2 |
Channel interpretation | "speakers" |
Constructor
PannerNode()
-
Creates a new
PannerNode
object 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
. This is why these values are not marked read only, which is how they appear in the WebIDL.
PannerNode.coneInnerAngle
-
Is 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
attribute. PannerNode.coneOuterGain
-
A double value describing the amount of volume reduction outside the cone defined by the
coneOuterAngle
attribute. Its default value is0
, 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 itsvalue
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 itsvalue
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 itsvalue
property. The default is value is 0. PannerNode.panningModel
-
An enumerated value determining which spatialisation 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 itsvalue
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 itsvalue
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 itsvalue
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
anddistanceModel
. 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.
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 theBaseAudioContext.listener
attribute.) -
PannerNode.setOrientation()
-
Defines the direction the audio source is playing in.
-
PannerNode.setVelocity()
-
Defines the velocity vector of the audio source — how fast it is moving and in what direction. In a previous version of the specification, the
PannerNode
had a velocity that could pitch up or downAudioBufferSourceNode
s connected downstream. This feature was not clearly specified and had a number of issues, so it was removed from the specification.
Examples
See BaseAudioContext.createPanner()
for example code.
Specifications
Specification |
---|
Web Audio API # PannerNode |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
PannerNode |
14 |
12 |
25 |
No |
15 |
14.1
6-14.1
|
≤37 |
18 |
25 |
14 |
14.5
6-14.5
|
1.0 |
PannerNode |
55
Before Chrome 59, the default values were not supported.
|
79 |
53 |
No |
42 |
14.1 |
55
Before version 59, the default values were not supported.
|
55
Before Chrome 59, the default values were not supported.
|
53 |
42 |
14.5 |
6.0
Before Samsung Internet 7.0, the default values were not supported.
|
coneInnerAngle |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
coneOuterAngle |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
coneOuterGain |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
distanceModel |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
maxDistance |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
orientationX |
52 |
79 |
50 |
No |
39 |
14.1 |
52 |
52 |
50 |
41 |
14.5 |
6.0 |
orientationY |
52 |
79 |
50 |
No |
39 |
14.1 |
52 |
52 |
50 |
41 |
14.5 |
6.0 |
orientationZ |
52 |
79 |
50 |
No |
39 |
14.1 |
52 |
52 |
50 |
41 |
14.5 |
6.0 |
panningModel |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
positionX |
52 |
79 |
50 |
No |
39 |
14.1 |
52 |
52 |
50 |
41 |
14.5 |
6.0 |
positionY |
52 |
79 |
50 |
No |
39 |
14.1 |
52 |
52 |
50 |
41 |
14.5 |
6.0 |
positionZ |
52 |
79 |
50 |
No |
39 |
14.1 |
52 |
52 |
50 |
41 |
14.5 |
6.0 |
refDistance |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
rolloffFactor |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
setOrientation |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
setPosition |
14 |
12 |
25 |
No |
15 |
6 |
≤37 |
18 |
25 |
14 |
6 |
1.0 |
setVelocity |
14-56 |
12-79 |
25-63 |
No |
15-43 |
6-14.1 |
≤37-56 |
18-56 |
25-63 |
14-43 |
6-14.5 |
1.0-6.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PannerNode