{{ APIRef("Web Audio API") }}
The AudioListener
interface represents the position and orientation of the unique person listening to the audio scene, and is used in audio spatialisation. All {{domxref("PannerNode")}}s spatialise in relation to the AudioListener
stored in the {{domxref("AudioContext.listener")}} attribute.
It is important to note that there is only one listener per context and that it isn't an {{domxref("AudioNode")}}.
Properties
Inherits properties from its parent, {{domxref('AudioNode')}}.
- {{domxref("AudioListener.positionX")}}
- Represents the horizontal position of the source in a right-hand cartesian coordinate sytem.
- {{domxref("AudioListener.positionY")}}
- Represents the vertical position of the source in a right-hand cartesian coordinate sytem.
- {{domxref("AudioListener.positionZ")}}
- Represents the longitudinal (back and forth) position of the source in a right-hand cartesian coordinate sytem.
- {{domxref("AudioListener.forwardX")}}
- Represents the horizontal position of the listener in the same cartesian coordinate sytem as the position (
positionX
,positionY
, andpositionZ
) values. The forward and up values are linearly independent of each other. The default is 0. - {{domxref("AudioListener.forwardY")}}
- Represents the vertical position of the listener in the same cartesian coordinate sytem as the position (
positionX
,positionY
, andpositionZ
) values. The forward and up values are linearly independent of each other. The default is 0. - {{domxref("AudioListener.forwardZ")}}
- Represents the longitudinal (back and forth) position of the listener in the same cartesian coordinate sytem as the position (
positionX
,positionY
, andpositionZ
) values. The forward and up values are linearly independent of each other. The default is 0. - {{domxref("AudioListener.upX")}}
- TBD
- {{domxref("AudioListener.upY")}}
- TBD
- {{domxref("AudioListener.upZ")}}
- TBD
Methods
Inherits methods from its parent, {{domxref('AudioNode')}}.
- {{domxref("AudioListener.setOrientation()")}}
- Defines the orientation of the listener.
Deprecated features
In a previous version of the specification, the three members listed below could be used to control the doppler effect applied to {{domxref("AudioBufferSourceNode")}}s connected downstream — these would be pitched up and down according to the relative speed of the {{domxref("PannerNode")}} and the {{domxref("AudioListener")}}. These features had a number of problems:
- Only {{domxref("AudioBufferSourceNode")}}s were pitched up or down, not other source nodes.
- The behavior to adopt when an {{domxref("AudioBufferSourceNode")}} was connected to multiple {{domxref("PannerNode")}}s was unclear.
- Because the velocity of the panner and the listener were not {{domxref("AudioParam")}}s, the pitch modification could not be smoothly applied, resulting in audio glitches.
- {{domxref("AudioListener.dopplerFactor")}}
- Is a double value representing the amount of pitch shift to use when rendering a doppler effect.
- {{domxref("AudioListener.speedOfSound")}}
- Is a double value representing the speed of sound, in meters per second.
- {{domxref("AudioListener.setPosition()")}}
- Defines the position of the listener.
Example
{{page("/en-US/docs/Web/API/AudioContext.createPanner","Example")}}
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('Web Audio API', '#the-audiolistener-interface', 'AudioListener')}} | {{Spec2('Web Audio API')}} |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(10.0)}}{{property_prefix("webkit")}} | {{CompatGeckoDesktop(25.0)}} | {{CompatNo}} | 15.0{{property_prefix("webkit")}} 22 (unprefixed) |
6.0{{property_prefix("webkit")}} |
Feature | Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | 26.0 | 1.2 | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | 33.0 |