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 663753 of DynamicsCompressorNode

  • Revision slug: Web/API/DynamicsCompressorNode
  • Revision title: DynamicsCompressorNode
  • Revision id: 663753
  • Created:
  • Creator: chrisdavidmills
  • Is current revision? No
  • Comment

Revision Content

{{ APIRef() }}

The DynamicsCompressorNode interface provides a compression effect, which lowers the volume of the loudest parts of the signal in order to help prevent clipping and distortion that can occur when multiple sounds are played and multiplexed together at once. This is often used in musical production and game audio. DynamicsCompressorNode is an {{domxref("AudioNode")}} that has exactly one input and one output; it is created using the {{domxref("AudioContext.createDynamicsCompressor")}} method.

  • Number of inputs 1
  • Number of outputs 1
  • Channel count mode "explicit"
  • Channel count 2
  • Channel interpretation "speakers"

Properties

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

{{domxref("DynamicsCompressorNode.threshold")}}
The threshold attribute has no effect on signals lowers than its value, but induce volume reduction on signal stronger than its value. Is a {{k-rate}} {{domxref("AudioParam")}} representing the decibel value above which the compression will start taking effect. Its default value is -24 and it can be set between -100 and 0. (Though the AudioParam returned is read-only, the value it represents is not.)
{{domxref("DynamicsCompressorNode.knee")}}
Describes the effect of a knee, showing two curves one for a hard knee, the other for a soft knee. Is a {{k-rate}} {{domxref("AudioParam")}} containing a decibel value representing the range above the threshold where the curve smoothly transitions to the compressed portion. Its default value is 30 and it can be set between 0 and 40. (Though the AudioParam returned is read-only, the value it represents is not.)
{{domxref("DynamicsCompressorNode.ratio")}}
Describes the effect of different ratio on the output signal Is a {{k-rate}} {{domxref("AudioParam")}} representing the amount of change, in dB, needed in the input for a 1 dB change in the output. Its default value is 12 and it can be set between 1 and 20. (Though the AudioParam returned is read-only, the value it represents is not.)
{{domxref("DynamicsCompressorNode.reduction")}}
Is a {{k-rate}} {{domxref("AudioParam")}} representing the amount of gain reduction currently applied by the compressor to the signal. Intended for metering purposes, it returns a value in dB, or 0 (no gain reduction) if no signal is fed into the DynamicsCompressorNode. The range of this value is between -20 and 0 (in dB). (Though the AudioParam returned is read-only, the value it represents is not.)
{{domxref("DynamicsCompressorNode.attack")}}
Is a {{k-rate}} {{domxref("AudioParam")}} representing the amount of time, in seconds, required to reduce the gain by 10 dB. It defines how quick the signal is adapted when its volume is increased. Its default value is 0.003 and it can be set between 0 and 1. (Though the AudioParam returned is read-only, the value it represents is not.)
{{domxref("DynamicsCompressorNode.release")}}
Is a {{k-rate}} {{domxref("AudioParam")}} representing the amount of time, in seconds, required to increase the gain by 10 dB. It defines how quick the signal is adapted when its volume is reduced. Its default value is 0.25 and it can be set between 0 and 1. (Though the AudioParam returned is read-only, the value it represents is not.)

Methods

No specific methods; inherits methods from its parent, {{domxref("AudioNode")}}.

Example

{{page("/en-US/docs/Web/API/AudioContext.createDynamicsCompressor","Example")}}

Specifications

Specification Status Comment
{{SpecName('Web Audio API', '#DynamicsCompressorNode-section', 'DynamicsCompressorNode')}} {{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() }}</p>
<div>
 <p>The <code>DynamicsCompressorNode</code> interface provides a compression effect, which lowers the volume of the loudest parts of the signal in order to help prevent clipping and distortion that can occur when multiple sounds are played and multiplexed together at once. This is often used in musical production and game audio. <code>DynamicsCompressorNode</code> is an {{domxref("AudioNode")}} that has exactly one input and one output; it is created using the {{domxref("AudioContext.createDynamicsCompressor")}} method.</p>
</div>
<ul class="audionodebox">
 <li><dfn>Number of inputs</dfn> <code>1</code></li>
 <li><dfn>Number of outputs</dfn> <code>1</code></li>
 <li><dfn>Channel count mode</dfn> <code>"explicit"</code></li>
 <li><dfn>Channel count</dfn> <code>2</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>
  {{domxref("DynamicsCompressorNode.threshold")}}</dt>
 <dd>
  <table class="withoutBorder">
   <tbody>
    <tr>
     <td><img alt="The threshold attribute has no effect on signals lowers than its value, but induce volume reduction on signal stronger than its value." src="https://mdn.mozillademos.org/files/5111/WebAudioThreshold.png" style="width: 257px; height: 219px; float: left;" /></td>
     <td style="vertical-align:top">Is a {{k-rate}} {{domxref("AudioParam")}} representing the decibel value above which the compression will start taking effect. Its default value is <code>-24</code> and it can be set between <code>-100</code> and <code>0</code>. (Though the <code>AudioParam</code> returned is read-only, the value it represents is not.)</td>
    </tr>
   </tbody>
  </table>
 </dd>
 <dt>
  {{domxref("DynamicsCompressorNode.knee")}}</dt>
 <dd>
  <table class="withoutBorder">
   <tbody>
    <tr>
     <td><img alt="Describes the effect of a knee, showing two curves one for a hard knee, the other for a soft knee." src="https://mdn.mozillademos.org/files/5113/WebAudioKnee.png" style="width: 257px; height: 244px;" /></td>
     <td style="vertical-align:top">Is a {{k-rate}} {{domxref("AudioParam")}} containing a decibel value representing the range above the threshold where the curve smoothly transitions to the compressed portion. Its default value is <code>30</code> and it can be set between <code>0</code> and <code>40</code>. (Though the <code>AudioParam</code> returned is read-only, the value it represents is not.)</td>
    </tr>
   </tbody>
  </table>
 </dd>
 <dt>
  {{domxref("DynamicsCompressorNode.ratio")}}</dt>
 <dd>
  <table class="withoutBorder">
   <tbody>
    <tr>
     <td><img alt="Describes the effect of different ratio on the output signal" src="https://mdn.mozillademos.org/files/5115/WebAudioRatio.png" /></td>
     <td style="vertical-align:top">Is a {{k-rate}} {{domxref("AudioParam")}} representing the amount of change, in dB, needed in the input for a 1 dB change in the output. Its default value is <code>12</code> and it can be set between <code>1</code> and <code>20</code>. (Though the <code>AudioParam</code> returned is read-only, the value it represents is not.)</td>
    </tr>
   </tbody>
  </table>
 </dd>
 <dt>
  {{domxref("DynamicsCompressorNode.reduction")}}</dt>
 <dd>
  Is a {{k-rate}} {{domxref("AudioParam")}} representing the amount of gain reduction currently applied by the compressor to the signal. Intended for metering purposes, it returns a value in dB, or <code>0</code> (no gain reduction) if no signal is fed into the <code>DynamicsCompressorNode</code>. The range of this value is between <code>-20</code> and <code>0</code> (in dB). (Though the <code>AudioParam</code> returned is read-only, the value it represents is not.)</dd>
 <dt>
  {{domxref("DynamicsCompressorNode.attack")}}</dt>
 <dd>
  Is a {{k-rate}} {{domxref("AudioParam")}} representing the amount of time, in seconds, required to reduce the gain by 10 dB. It defines how quick the signal is adapted when its volume is increased. Its default value is <code>0.003</code> and it can be set between <code>0</code> and <code>1</code>. (Though the <code>AudioParam</code> returned is read-only, the value it represents is not.)</dd>
 <dt>
  {{domxref("DynamicsCompressorNode.release")}}</dt>
 <dd>
  Is a {{k-rate}} {{domxref("AudioParam")}} representing the amount of time, in seconds, required to increase the gain by 10 dB. It defines how quick the signal is adapted when its volume is reduced. Its default value is <code>0.25</code> and it can be set between <code>0</code> and <code>1</code>. (Though the <code>AudioParam</code> returned is read-only, the value it represents is not.)</dd>
</dl>
<h2 id="Methods">Methods</h2>
<p><em>No specific methods; inherits methods from its parent, </em><em>{{domxref("AudioNode")}}</em>.</p>
<h2 id="Example">Example</h2>
<p>{{page("/en-US/docs/Web/API/AudioContext.createDynamicsCompressor","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', '#DynamicsCompressorNode-section', 'DynamicsCompressorNode')}}</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