The PannerNode() constructor of the Web Audio API creates a new PannerNode object instance.
new PannerNode(context)
new PannerNode(context, options)contextA BaseAudioContext representing the audio context you want the node to be associated with.
options OptionalA PannerOptions dictionary object defining the properties you want the PannerNode to have:
panningModelThe PannerNode.panningModel you want the PannerNode to have (the default is equalpower.)
distanceModelThe PannerNode.distanceModel you want the PannerNode to have (the default is inverse.)
positionXThe PannerNode.positionX you want the PannerNode to have (the default is 0.)
positionYThe PannerNode.positionY you want the PannerNode to have (the default is 0.)
positionZThe PannerNode.positionZ you want the PannerNode to have (the default is 0.)
orientationXThe PannerNode.orientationX you want the PannerNode to have (the default is 1.)
orientationYThe PannerNode.orientationY you want the PannerNode to have (the default is 0.)
orientationZThe PannerNode.orientationZ you want the PannerNode to have (the default is 0.)
refDistanceThe PannerNode.refDistance you want the PannerNode to have. The default is 1, and negative values are not allowed.
maxDistanceThe PannerNode.maxDistance you want the PannerNode to have. The default is 10000, and non-positive values are not allowed.
rolloffFactorThe PannerNode.rolloffFactor you want the PannerNode to have. The default is 1, and negative values are not allowed.
coneInnerAngleThe PannerNode.coneInnerAngle you want the PannerNode to have (the default is 360.)
coneOuterAngleThe PannerNode.coneOuterAngle you want the PannerNode to have (the default is 360.)
coneOuterGainThe PannerNode.coneOuterGain you want the PannerNode to have. The default is 0, and its value can be in the range 0–1.
channelCountRepresents 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.
channelCountModeRepresents 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.)
channelInterpretationRepresents 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.)
RangeErrorThrown if the refDistance, maxDistance, or rolloffFactor properties have been given a value that is outside the accepted range.
InvalidStateError DOMExceptionThrown if the coneOuterGain property has been given a value outside the accepted range (0–1).
const ctx = new AudioContext();
const options = {
positionX: 1,
maxDistance: 5000,
};
const myPanner = new PannerNode(ctx, options);