PannerNode: PannerNode() constructor
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
BaseAudioContextrepresenting the audio context you want the node to be associated with. optionsOptional-
A
PannerOptionsdictionary object defining the properties you want thePannerNodeto have:panningModel-
The
PannerNode.panningModelyou want thePannerNodeto have (the default isequalpower.) distanceModel-
The
PannerNode.distanceModelyou want thePannerNodeto have (the default isinverse.) positionX-
The
PannerNode.positionXyou want thePannerNodeto have (the default is0.) positionY-
The
PannerNode.positionYyou want thePannerNodeto have (the default is0.) positionZ-
The
PannerNode.positionZyou want thePannerNodeto have (the default is0.) orientationX-
The
PannerNode.orientationXyou want thePannerNodeto have (the default is1.) orientationY-
The
PannerNode.orientationYyou want thePannerNodeto have (the default is0.) orientationZ-
The
PannerNode.orientationZyou want thePannerNodeto have (the default is0.) refDistance-
The
PannerNode.refDistanceyou want thePannerNodeto have. The default is1, and negative values are not allowed. maxDistance-
The
PannerNode.maxDistanceyou want thePannerNodeto have. The default is10000, and non-positive values are not allowed. rolloffFactor-
The
PannerNode.rolloffFactoryou want thePannerNodeto have. The default is1, and negative values are not allowed. coneInnerAngle-
The
PannerNode.coneInnerAngleyou want thePannerNodeto have (the default is360.) coneOuterAngle-
The
PannerNode.coneOuterAngleyou want thePannerNodeto have (the default is360.) coneOuterGain-
The
PannerNode.coneOuterGainyou want thePannerNodeto 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.channelCountfor 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.channelCountModefor 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.channelCountModefor more information including default values.)
Exceptions
RangeError-
Thrown if the
refDistance,maxDistance, orrolloffFactorproperties have been given a value that is outside the accepted range. InvalidStateErrorDOMException-
Thrown if the
coneOuterGainproperty 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
| desktop | mobile | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
PannerNode() constructor | |||||||||||