{{ 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")}} {{readonlyInline}}
- Is a {{k-rate}} {{domxref("AudioParam")}} representing the decibel value above which the compression will start taking effect.
- {{domxref("DynamicsCompressorNode.knee")}} {{readonlyInline}}
-
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 between0
and40
. (Though theAudioParam
returned is read-only, the value it represents is not.) - {{domxref("DynamicsCompressorNode.ratio")}} {{readonlyInline}}
-
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 between1
and20
. (Though theAudioParam
returned is read-only, the value it represents is not.) - {{domxref("DynamicsCompressorNode.reduction")}} {{readonlyInline}}
-
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 theDynamicsCompressorNode
. The range of this value is between-20
and0
(in dB). (Though theAudioParam
returned is read-only, the value it represents is not.) - {{domxref("DynamicsCompressorNode.attack")}} {{readonlyInline}}
-
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 between0
and1
. (Though theAudioParam
returned is read-only, the value it represents is not.) - {{domxref("DynamicsCompressorNode.release")}} {{readonlyInline}}
-
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 between0
and1
. (Though theAudioParam
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 |