AnalyserNode

  • Revision slug: Web/API/AnalyserNode
  • Revision title: AnalyserNode
  • Revision id: 431159
  • Created:
  • Creator: leobalter
  • Is current revision? No
  • Comment

Revision Content

{{WebAudioRef}}

{{SeeCompatTable}}

The AnalyserNode interface represents a node able to provide real-time frequency and time-domain analysis information. It is an {{domxref("AudioNode")}} that passes the audio stream unchanged from the input to the output. It has exactly one input and one output. The node works even if the output is not connected.

Without modifying the audio stream, the node allows to get the frequency and time-domain data associated to it, using a FFT.

  • Number of inputs 1
  • Number of outputs 1 (but may be left unconnected)
  • Channel count mode "explicit"
  • Channel count 1
  • Channel interpretation "speakers"

Properties

Inherits properties from its parent, {{domxref("AudioNode")}}.

{{domxref("AnalyserNode.fftSize")}}
Is an unsigned long value representing the size of the Fast Fourier Transform to be used to determine the frequency domain. It must be a non-zero power of 2 in the range between 32 and 2048, included; its default value is 2048. If not a power of 2, or outside the specified range, the exception INDEX_SIZE_ERR is thrown.
{{domxref("AnalyserNode.frequencyBinCount")}} {{readonlyInline}}
Is an unsigned long value containing half the FFT size.
{{domxref("AnalyserNode.minDecibels")}}
Is a double value representing the minimum power value in the scaling range for the FFT analysis data for conversion to unsigned bytw values. If a value greater than AnalyserNode.maxDecibels is set, an INDEX_SIZE_ERR exception is thrown. It defaults to -100.
{{domxref("AnalyserNode.maxDecibels")}}
Is a double value representing the maximumum power value in the scaling range for the FFT analysis data for conversion to unsigned bytw values. If a value smaller than AnalyserNode.minDecibels is set, an INDEX_SIZE_ERR exception is thrown. It defaults to -30.
{{domxref("AnalyserNode.smoothingTimeConstant")}}
Is a double value representing the averaging constant with the last analysis frame. It must be between 0 and 1, included and defaults to 0.8 (and 0 meaning no time averaging). If outside this range, an INDEX_SIZE_ERR exception is thrown

Methods

Inherits methods from its parent, {{domxref("AudioNode")}}.

{{domxref("Analyser.getFloatFrequencyData()")}}
Copies the current frequency data into the array, the passed floating-point array. If the array has fewer elements than the frequencyBinCount, excess elements are dropped. If it has more elements than needed, excess elements are ignored.
{{domxref("Analyser.getByteFrequencyData()")}}
Copies the current frequency data into the array, the passed unsigned byte array. If the array has fewer elements than the frequencyBinCount, excess elements are dropped. If it has more elements than needed, excess elements are ignored.
{{domxref("Analyser.getByteTimeDomainData()")}}
Copies the current waveform, or time-domain, data into the array, the passed unsigned byte array. If the array has fewer elements than the fftSize, excess elements are dropped. If it has more elements than needed, excess elements are ignored.

Examples

 

Specifications

Specification Status Comment
{{SpecName('Web Audio API', '#AnalyserNode-section', 'AnalyserNode')}} {{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 {{CompatNo}} Activated on Nightly only {{CompatNo}} {{CompatNo}} {{CompatUnknown}}

See also

  • Using Web Audio API

Revision Source

<p>{{WebAudioRef}}</p>
<p>{{SeeCompatTable}}</p>
<p>The <strong><code>AnalyserNode</code></strong><strong> </strong>interface represents a node able to provide real-time frequency and time-domain analysis information. It is an {{domxref("AudioNode")}} that passes the audio stream unchanged from the input to the output. It has exactly one input and one output. The node works even if the output is not connected.</p>
<p><img alt="Without modifying the audio stream, the node allows to get the frequency and time-domain data associated to it, using a FFT." src="https://mdn.mozillademos.org/files/5119/WebAudioFFT.png" style="width: 661px; height: 174px;" /></p>
<ul class="audionodebox">
  <li><dfn>Number of inputs</dfn> <code>1</code></li>
  <li><dfn>Number of outputs</dfn> <code>1</code> (but may be left unconnected)</li>
  <li><dfn>Channel count mode</dfn> <code>"explicit"</code></li>
  <li><dfn>Channel count</dfn> <code>1</code></li>
  <li><dfn>Channel interpretation</dfn> <code>"speakers"</code></li>
</ul>
<h2 id="Properties">Properties</h2>
<p><em>Inherits properties from its parent, </em><em>{{domxref("AudioNode")}}</em>.</p>
<dl>
  <dt>
    <span id="cke_bm_91S" style="display: none;">&nbsp;</span>{{domxref("AnalyserNode.fftSize")}}</dt>
  <dd>
    Is an unsigned long value representing the size of the <a href="/en-US/docs/" title="/en-US/docs/">Fast Fourier Transform</a> to be used to determine the frequency domain. It must be a non-zero power of 2 in the range between <code>32</code> and <code>2048</code>, included; its default value is <code>2048</code>. If not a power of 2, or outside the specified range, the exception <code>INDEX_SIZE_ERR</code> is thrown.</dd>
  <dt>
    {{domxref("AnalyserNode.frequencyBinCount")}} {{readonlyInline}}</dt>
  <dd>
    Is an unsigned long value containing half the FFT size<strong>.</strong></dd>
  <dt>
    {{domxref("AnalyserNode.minDecibels")}}</dt>
  <dd>
    Is a double value representing the minimum power value in the scaling range for the FFT analysis data for conversion to unsigned bytw values. If a value greater than <code>AnalyserNode.maxDecibels</code> is set, an <code>INDEX_SIZE_ERR</code> exception is thrown. It defaults to <code>-100</code>.</dd>
  <dt>
    {{domxref("AnalyserNode.maxDecibels")}}</dt>
  <dd>
    Is a double value representing the maximumum power value in the scaling range for the FFT analysis data for conversion to unsigned bytw values. If a value smaller than <code>AnalyserNode.minDecibels</code> is set, an <code>INDEX_SIZE_ERR</code> exception is thrown. It defaults to <code>-30</code>.</dd>
  <dt>
    {{domxref("AnalyserNode.smoothingTimeConstant")}}</dt>
  <dd>
    Is a double value representing the averaging constant with the last analysis frame. It must be between <code>0</code> and <code>1</code>, included and defaults to <code>0.8</code> (and <code>0</code> meaning no time averaging). If outside this range, an <code>INDEX_SIZE_ERR</code> exception is thrown</dd>
</dl>
<h2 id="Methods">Methods</h2>
<p><em>Inherits methods from its parent, </em><em>{{domxref("AudioNode")}}</em>.</p>
<dl>
  <dt>
    {{domxref("Analyser.getFloatFrequencyData()")}}</dt>
  <dd>
    Copies the current frequency data into the <code>array</code>, the passed floating-point array. If the array has fewer elements than the <code>frequencyBinCount</code>, excess elements are dropped. If it has more elements than needed, excess elements are ignored.</dd>
</dl>
<dl>
  <dt>
    {{domxref("Analyser.getByteFrequencyData()")}}</dt>
  <dd>
    Copies the current frequency data into the <code>array</code>, the passed unsigned byte array. If the array has fewer elements than the <code>frequencyBinCount</code>, excess elements are dropped. If it has more elements than needed, excess elements are ignored.</dd>
</dl>
<dl>
  <dt>
    {{domxref("Analyser.getByteTimeDomainData()")}}</dt>
  <dd>
    Copies the current waveform, or time-domain, data into the <code>array</code>, the passed unsigned byte array. If the array has fewer elements than the <code>fftSize</code>, excess elements are dropped. If it has more elements than needed, excess elements are ignored.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<p>&nbsp;</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', '#AnalyserNode-section', 'AnalyserNode')}}</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>{{CompatNo}}</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 API</li>
</ul>
Revert to this revision