PannerNode: PannerNode() constructor
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
The PannerNode()
constructor of the Web Audio API creates a new PannerNode
object instance.
Syntax
new PannerNode(context)
new PannerNode(context, options)
Parameters
context
-
A
BaseAudioContext
representing the audio context you want the node to be associated with. options
Optional-
A
PannerOptions
dictionary object defining the properties you want thePannerNode
to have:panningModel
-
The
PannerNode.panningModel
you want thePannerNode
to have (the default isequalpower
.) distanceModel
-
The
PannerNode.distanceModel
you want thePannerNode
to have (the default isinverse
.) positionX
-
The
PannerNode.positionX
you want thePannerNode
to have (the default is0
.) positionY
-
The
PannerNode.positionY
you want thePannerNode
to have (the default is0
.) positionZ
-
The
PannerNode.positionZ
you want thePannerNode
to have (the default is0
.) orientationX
-
The
PannerNode.orientationX
you want thePannerNode
to have (the default is1
.) orientationY
-
The
PannerNode.orientationY
you want thePannerNode
to have (the default is0
.) orientationZ
-
The
PannerNode.orientationZ
you want thePannerNode
to have (the default is0
.) refDistance
-
The
PannerNode.refDistance
you want thePannerNode
to have. The default is1
, and negative values are not allowed. maxDistance
-
The
PannerNode.maxDistance
you want thePannerNode
to have. The default is10000
, and non-positive values are not allowed. rolloffFactor
-
The
PannerNode.rolloffFactor
you want thePannerNode
to have. The default is1
, and negative values are not allowed. coneInnerAngle
-
The
PannerNode.coneInnerAngle
you want thePannerNode
to have (the default is360
.) coneOuterAngle
-
The
PannerNode.coneOuterAngle
you want thePannerNode
to have (the default is360
.) coneOuterGain
-
The
PannerNode.coneOuterGain
you want thePannerNode
to have. The default is0
, and its value can be in the range 0–1. channelCount
-
Represents an integer used to determine how many channels are used when up-mixing and down-mixing connections to any inputs to the node. (See
AudioNode.channelCount
for more information.) Its usage and precise definition depend on the value ofchannelCountMode
. channelCountMode
-
Represents an enumerated value describing the way channels must be matched between the node's inputs and outputs. (See
AudioNode.channelCountMode
for more information including default values.) channelInterpretation
-
Represents an enumerated value describing the meaning of the channels. This interpretation will define how audio up-mixing and down-mixing will happen. The possible values are
"speakers"
or"discrete"
. (SeeAudioNode.channelCountMode
for more information including default values.)
Exceptions
RangeError
-
Thrown if the
refDistance
,maxDistance
, orrolloffFactor
properties have been given a value that is outside the accepted range. InvalidStateError
DOMException
-
Thrown if the
coneOuterGain
property has been given a value outside the accepted range (0–1).
Examples
const ctx = new AudioContext();
const options = {
positionX: 1,
maxDistance: 5000,
};
const myPanner = new PannerNode(ctx, options);
Specifications
Specification |
---|
Web Audio API # dom-pannernode-pannernode |
Browser compatibility
BCD tables only load in the browser