This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

PannerNode

Summary

This interface represents a processing node which positions / spatializes an incoming audio stream in three-dimensional space. The spatialization is in relation to the AudioContext’s AudioListener (listener attribute). The audio stream from the input will be either mono or stereo, depending on the connection(s) to the input. The output of this node is hard-coded to stereo (2 channels) and currently cannot be configured.

Properties

coneInnerAngle
A parameter for directional audio sources, this is an angle inside of which there will be no volume reduction. The default value is 360.
coneOuterAngle
A parameter for directional audio sources, this is an angle outside of which the volume will be reduced to a constant value of coneOuterGain. The default value is 360.
coneOuterGain
A parameter for directional audio sources, this is the amount of volume reduction outside of the coneOuterAngle. The default value is 0.
distanceModel
Determines which algorithm will be used to reduce the volume of an audio source as it moves away from the listener. See below for the available choices. The default is INVERSE_DISTANCE.
maxDistance
The maximum distance between source and listener, after which the volume will not be reduced any further. The default value is 10000.
panningModel
Determines which spatialization algorithm will be used to position the audio in 3D space. See below for the available choices. The default is HRTF.
refDistance
A reference distance for reducing volume as source moves further from the listener. The default value is 1.
rolloffFactor
Describes how quickly the volume is reduced as source moves away from listener. The default value is 1.

Methods

setOrientation
Describes which direction the audio source is pointing in the 3D cartesian coordinate space. Depending on how directional the sound is (controlled by the cone attributes), a sound pointing away from the listener can be very quiet or completely silent. The x, y, and z parameters represent a direction vector in 3D space. The default value is (1,0,0).
setPosition
Sets the position of the audio source relative to the listener attribute. A 3D cartesian coordinate system is used. The x, y, and z parameters represent the coordinates in 3D space. The default value is (0,0,0).
setVelocity
Sets the velocity vector of the audio source. This vector controls both the direction of travel and the speed in 3D space. This velocity relative to the listener’s velocity is used to determine how much doppler shift (pitch change) to apply. The x, y, and z parameters describe a direction vector indicating direction of travel and intensity. The default value is (0,0,0).

Events

No events.

Related specifications

W3C Web Audio API
W3C Editor’s Draft