Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1098411 of AudioListener

  • Revision slug: Web/API/AudioListener
  • Revision title: AudioListener
  • Revision id: 1098411
  • Created:
  • Creator: jpmedley
  • Is current revision? No
  • Comment

Revision Content

{{ 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")}}.

We see the position, up and front vectors of an AudioListener, with the up and front vectors at 90° from the other

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")}}
TBD
{{domxref("AudioListener.forwardY")}}
TBD
{{domxref("AudioListener.forwardZ")}}
TBD
{{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

{{CompatibilityTable}}
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

See also

Revision Source

<p>{{ APIRef("Web Audio API") }}</p>

<div>
<p>The <code>AudioListener</code> interface represents the position and orientation of the unique person listening to the audio scene, and is used in <a href="/en-US/docs/Web/API/Web_Audio_API/Web_audio_spatialisation_basics">audio spatialisation</a>. All {{domxref("PannerNode")}}s spatialise in relation to the <code>AudioListener</code> stored in the {{domxref("AudioContext.listener")}} attribute.</p>
</div>

<p>It is important to note that there is only one listener per context and that it isn't an {{domxref("AudioNode")}}.</p>

<p><img alt="We see the position, up and front vectors of an AudioListener, with the up and front vectors at 90° from the other" src="https://mdn.mozillademos.org/files/9715/WebAudioListener.png" style="display:block; height:250px; margin:0px auto; width:634px" /></p>

<h2 id="Properties">Properties</h2>

<p><em>Inherits properties from its parent, </em>{{domxref('AudioNode')}}.</p>

<dl>
 <dt>{{domxref("AudioListener.positionX")}}</dt>
 <dd>Represents the horizontal position of the source in a right-hand cartesian coordinate sytem.</dd>
 <dt>{{domxref("AudioListener.positionY")}}</dt>
 <dd>Represents the vertical position of the source in a right-hand cartesian coordinate sytem.</dd>
 <dt>{{domxref("AudioListener.positionZ")}}</dt>
 <dd>Represents the longitudinal (back and forth) position of the source in a right-hand cartesian coordinate sytem.</dd>
 <dt>{{domxref("AudioListener.forwardX")}}</dt>
 <dd>TBD</dd>
 <dt>{{domxref("AudioListener.forwardY")}}</dt>
 <dd>TBD</dd>
 <dt>{{domxref("AudioListener.forwardZ")}}</dt>
 <dd>TBD</dd>
 <dt>{{domxref("AudioListener.upX")}}</dt>
 <dd>TBD</dd>
 <dt>{{domxref("AudioListener.upY")}}</dt>
 <dd>TBD</dd>
 <dt>{{domxref("AudioListener.upZ")}}</dt>
 <dd>TBD</dd>
</dl>

<h2 id="Methods">Methods</h2>

<p><em>Inherits methods from its parent,&nbsp;</em>{{domxref('AudioNode')}}.</p>

<dl>
 <dt>{{domxref("AudioListener.setOrientation()")}}</dt>
 <dd>Defines the orientation of the listener.</dd>
</dl>

<h2 id="Deprecated_features">Deprecated features</h2>

<p>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:</p>

<ul>
 <li>Only {{domxref("AudioBufferSourceNode")}}s were pitched up or down, not other source nodes.</li>
 <li>The behavior to adopt when an {{domxref("AudioBufferSourceNode")}} was connected to multiple {{domxref("PannerNode")}}s was unclear.</li>
 <li>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.</li>
</ul>

<dl>
 <dt>{{domxref("AudioListener.dopplerFactor")}}</dt>
 <dd>Is a double value representing the amount of pitch shift to use when rendering a <a href="https://en.wikipedia.org/wiki/Doppler_effect">doppler effect</a>.</dd>
 <dt>{{domxref("AudioListener.speedOfSound")}}</dt>
 <dd>Is a double value representing the speed of sound, in <em>meters per second</em>.</dd>
 <dt>{{domxref("AudioListener.setPosition()")}}</dt>
 <dd>Defines the position of the listener.</dd>
</dl>

<h2 id="Example">Example</h2>

<p>{{page("/en-US/docs/Web/API/AudioContext.createPanner","Example")}}</p>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Web Audio API', '#the-audiolistener-interface', 'AudioListener')}}</td>
   <td>{{Spec2('Web Audio API')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome(10.0)}}{{property_prefix("webkit")}}</td>
   <td>{{CompatGeckoDesktop(25.0)}}&nbsp;</td>
   <td>{{CompatNo}}</td>
   <td>15.0{{property_prefix("webkit")}}<br />
    22 (unprefixed)</td>
   <td>6.0{{property_prefix("webkit")}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>26.0</td>
   <td>1.2</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>33.0</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web_Audio_API/Using_Web_Audio_API">Using the Web Audio API</a></li>
</ul>
Revert to this revision