AudioContext

  • Revision slug: Web/API/AudioContext
  • Revision title: AudioContext
  • Revision id: 478581
  • Created:
  • Creator: Btipling
  • Is current revision? No
  • Comment

Revision Content

{{WebAudioRef}} {{SeeCompatTable}}

The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an {{domxref("AudioNode")}}.

An audio context controls the creation of the nodes it contains and the execution of the audio processing, or decoding.

An AudioContext can be target of events, therefore it implements the {{domxref("EventTarget")}} interface.

Properties

{{domxref("AudioContext.destination")}} {{readonlyInline}}
Returns an {{domxref("AudioDestinationNode")}} representing the final destination of all audio in the context. It often represents an actual audio-rendering device.
{{domxref("AudioContext.sampleRate")}} {{readonlyInline}}
Returns a float representing the sample rate, in samples per second, used by all node in this context. This limitation means that sample-rate converters are not supported.
{{domxref("AudioContext.currentTime")}} {{readonlyInline}}
Returns a double representing an ever-increasing hardware time using for scheduling. It starts at 0 and cannot be stopped, paused or reset.
{{domxref("AudioContext.listener")}} {{readonlyInline}}
Returns the {{domxref("AudioListener")}} used for 3D spatialization.

Methods

Also implements methods from the interface {{domxref("EventTarget")}}.

{{domxref("AudioContext.createBuffer()")}}
Creates an {{domxref("AudioBuffer")}}.
{{domxref("AudioContext.createBufferSource()")}}
Creates an {{domxref("AudioBufferSourceNode")}}.
{{domxref("AudioContext.createMediaElementSource()")}}
Creates a {{domxref("MediaElementAudioSourceNode")}} associated with an {{domxref("HTMLMediaElement")}} associated with elements like {{HTMLElement("video")}} or {{HTMLElement("audio")}}.
{{domxref("AudioContext.createMediaStreamSource()")}}
Creates a {{domxref("MediaStreamAudioSourceNode")}} associated with a WebRTC {{domxref("MediaStream")}} representing an audio stream, that may come from the local computer microphone or other sources.
{{domxref("AudioContext.createMediaStreamDestination()")}}
Creates a {{domxref("MediaStreamAudioDestinationNode")}} associated with a WebRTC {{domxref("MediaStream")}} representing an audio stream, that may be stored in a local file or sent to another computer.
{{domxref("AudioContext.createScriptProcessor()")}}
Creates a {{domxref("ScriptProcessorNode")}}.
{{domxref("AudioContext.createAnalyser()")}}
Creates an {{domxref("AnalyserNode")}}.
{{domxref("AudioContext.createGain()")}}
Creates a {{domxref("GainNode")}}.
{{domxref("AudioContext.createDelay()")}}
Creates a {{domxref("DelayNode")}}.
{{domxref("AudioContext.createBiquadFilter()")}}
Creates a {{domxref("BiquadFilterNode")}}.
{{domxref("AudioContext.createWaveShaper()")}}
Creates a {{domxref("WaveShaperNode")}}.
{{domxref("AudioContext.createPanner()")}}
Creates a {{domxref("PannerNode")}}.
{{domxref("AudioContext.createConvolver()")}}
Creates a {{domxref("ConvolverNode")}}.
{{domxref("AudioContext.createChannelSplitter()")}}
Creates a {{domxref("ChannelSplitterNode")}}.
{{domxref("AudioContext.createChannelMerger()")}}
Creates a {{domxref("ChannelMergerNode")}}.
{{domxref("AudioContext.createDynamicsCompressor()")}}
Creates a {{domxref("DynamicsCompressorNode")}}.
{{domxref("AudioContext.createJavaScriptNode()")}}
Creates a {{domxref("JavaScriptNode")}}.
{{domxref("AudioContext.createOscillator()")}}
Creates an {{domxref("OscillatorNode")}}.
{{domxref("AudioContext.createWaveTable()")}}
Creates a {{domxref("WaveTableNode")}}.

Examples

---

Specifications

Specification Status Comment
{{SpecName('Web Audio API', '#AudioContext-section', 'AudioContext')}} {{Spec2('Web Audio API')}}  

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatVersionUnknown}}{{property_prefix("webkit")}} Activated on Nightly only {{CompatNo}} {{CompatNo}} {{CompatUnknown}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} Activated on Nightly only {{CompatNo}} {{CompatNo}} {{CompatUnknown}}

See also

  • Using Web Audio

Revision Source

<div>
  {{WebAudioRef}} {{SeeCompatTable}}</div>
<p>The <strong><code>AudioContext</code></strong> interface represents an audio-processing graph built from audio modules linked together, each represented by an {{domxref("AudioNode")}}.</p>
<p>An audio context controls the creation of the nodes it contains and the execution of the audio processing, or decoding.</p>
<p>An <code>AudioContext</code> can be target of events, therefore it implements the {{domxref("EventTarget")}} interface.</p>
<h2 id="Properties">Properties</h2>
<dl>
  <dt>
    {{domxref("AudioContext.destination")}} {{readonlyInline}}</dt>
  <dd>
    Returns an {{domxref("AudioDestinationNode")}} representing the final destination of all audio in the context. It often represents an actual audio-rendering device.</dd>
  <dt>
    {{domxref("AudioContext.sampleRate")}} {{readonlyInline}}</dt>
  <dd>
    Returns a float representing the sample rate, in samples per second, used by all node in this context. This limitation means that sample-rate converters are not supported.</dd>
  <dt>
    {{domxref("AudioContext.currentTime")}} {{readonlyInline}}</dt>
  <dd>
    Returns a double representing an ever-increasing hardware time using for scheduling. It starts at <code>0</code> and cannot be stopped, paused or reset.</dd>
  <dt>
    {{domxref("AudioContext.listener")}} {{readonlyInline}}</dt>
  <dd>
    Returns the {{domxref("AudioListener")}} used for 3D spatialization.</dd>
</dl>
<h2 id="Methods">Methods</h2>
<p><em>Also implements methods from the interface </em>{{domxref("EventTarget")}}.</p>
<dl>
  <dt>
    {{domxref("AudioContext.createBuffer()")}}</dt>
  <dd>
    Creates an {{domxref("AudioBuffer")}}.</dd>
  <dt>
    {{domxref("AudioContext.createBufferSource()")}}</dt>
  <dd>
    Creates an {{domxref("AudioBufferSourceNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createMediaElementSource()")}}</dt>
  <dd>
    Creates a {{domxref("MediaElementAudioSourceNode")}} associated with an {{domxref("HTMLMediaElement")}} associated with elements like {{HTMLElement("video")}} or {{HTMLElement("audio")}}.</dd>
  <dt>
    {{domxref("AudioContext.createMediaStreamSource()")}}</dt>
  <dd>
    Creates a {{domxref("MediaStreamAudioSourceNode")}} associated with a <a href="/en-US/docs/WebRTC">WebRTC</a> {{domxref("MediaStream")}} representing an audio stream, that may come from the local computer microphone or other sources.</dd>
  <dt>
    {{domxref("AudioContext.createMediaStreamDestination()")}}</dt>
  <dd>
    Creates a {{domxref("MediaStreamAudioDestinationNode")}} associated with a <a href="/en-US/docs/WebRTC">WebRTC</a> {{domxref("MediaStream")}} representing an audio stream, that may be stored in a local file or sent to another computer.</dd>
  <dt>
    {{domxref("AudioContext.createScriptProcessor()")}}</dt>
  <dd>
    Creates a {{domxref("ScriptProcessorNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createAnalyser()")}}</dt>
  <dd>
    Creates an {{domxref("AnalyserNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createGain()")}}</dt>
  <dd>
    Creates a {{domxref("GainNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createDelay()")}}</dt>
  <dd>
    Creates a {{domxref("DelayNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createBiquadFilter()")}}</dt>
  <dd>
    Creates a {{domxref("BiquadFilterNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createWaveShaper()")}}</dt>
  <dd>
    Creates a {{domxref("WaveShaperNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createPanner()")}}</dt>
  <dd>
    Creates a {{domxref("PannerNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createConvolver()")}}</dt>
  <dd>
    Creates a {{domxref("ConvolverNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createChannelSplitter()")}}</dt>
  <dd>
    Creates a {{domxref("ChannelSplitterNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createChannelMerger()")}}</dt>
  <dd>
    Creates a {{domxref("ChannelMergerNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createDynamicsCompressor()")}}</dt>
  <dd>
    Creates a {{domxref("DynamicsCompressorNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createJavaScriptNode()")}}</dt>
  <dd>
    Creates a {{domxref("JavaScriptNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createOscillator()")}}</dt>
  <dd>
    Creates an {{domxref("OscillatorNode")}}.</dd>
  <dt>
    {{domxref("AudioContext.createWaveTable()")}}</dt>
  <dd>
    Creates a {{domxref("WaveTableNode")}}.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<p>---</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', '#AudioContext-section', 'AudioContext')}}</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>{{CompatVersionUnknown}}{{property_prefix("webkit")}}</td>
        <td>Activated on Nightly only</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatUnknown}}</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>IE Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown}}</td>
        <td>Activated on Nightly only</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>Using Web Audio</li>
</ul>
Revert to this revision