Web Audio API
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- : A
PannerOptionsdictionary object defining the properties you want thePannerNodeto have:panningModel- : The PannerNode.panningModel you want the PannerNode to have (the default is
equalpower.)
- : The PannerNode.panningModel you want the PannerNode to have (the default is
distanceModel- : The PannerNode.distanceModel you want the PannerNode to have (the default is
inverse.)
- : The PannerNode.distanceModel you want the PannerNode to have (the default is
positionX- : The PannerNode.positionX you want the PannerNode to have (the default is
0.)
- : The PannerNode.positionX you want the PannerNode to have (the default is
positionY- : The PannerNode.positionY you want the PannerNode to have (the default is
0.)
- : The PannerNode.positionY you want the PannerNode to have (the default is
positionZ- : The PannerNode.positionZ you want the PannerNode to have (the default is
0.)
- : The PannerNode.positionZ you want the PannerNode to have (the default is
orientationX- : The PannerNode.orientationX you want the PannerNode to have (the default is
1.)
- : The PannerNode.orientationX you want the PannerNode to have (the default is
orientationY- : The PannerNode.orientationY you want the PannerNode to have (the default is
0.)
- : The PannerNode.orientationY you want the PannerNode to have (the default is
orientationZ- : The PannerNode.orientationZ you want the PannerNode to have (the default is
0.)
- : The PannerNode.orientationZ you want the PannerNode to have (the default is
refDistance- : The PannerNode.refDistance you want the PannerNode to have. The default is
1, and negative values are not allowed.
- : The PannerNode.refDistance you want the PannerNode to have. The default is
maxDistance- : The PannerNode.maxDistance you want the PannerNode to have. The default is
10000, and non-positive values are not allowed.
- : The PannerNode.maxDistance you want the PannerNode to have. The default is
rolloffFactor- : The PannerNode.rolloffFactor you want the PannerNode to have. The default is
1, and negative values are not allowed.
- : The PannerNode.rolloffFactor you want the PannerNode to have. The default is
coneInnerAngle- : The PannerNode.coneInnerAngle you want the PannerNode to have (the default is
360.)
- : The PannerNode.coneInnerAngle you want the PannerNode to have (the default is
coneOuterAngle- : The PannerNode.coneOuterAngle you want the PannerNode to have (the default is
360.)
- : The PannerNode.coneOuterAngle you want the PannerNode to have (the default is
coneOuterGain- : The PannerNode.coneOuterGain you want the PannerNode to have. The default is
0, and its value can be in the range 0–1.
- : The PannerNode.coneOuterGain you want the PannerNode to have. The default is
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 of
channelCountMode.
- : 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 of
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". (See AudioNode.channelCountMode for more information including default values.)
- : 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
- : A
Exceptions
- RangeError
- : Thrown if the
refDistance,maxDistance, orrolloffFactorproperties have been given a value that is outside the accepted range.
- : Thrown if the
InvalidStateErrorDOMException- : Thrown if the
coneOuterGainproperty has been given a value outside the accepted range (0–1).
- : Thrown if the
Examples
const ctx = new AudioContext();
const options = {
positionX: 1,
maxDistance: 5000,
};
const myPanner = new PannerNode(ctx, options);
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
