Class DynamicsCompressorNode
Lowers the volume of loud passages so the mix stays clear of clipping: the
Web Audio DynamicsCompressorNode.
Every parameter is k-rate. The detector follows the loudest channel, the
gain curve has a soft knee getKnee() decibels wide centred on
getThreshold(), and gain changes are smoothed by getAttack() and
getRelease(). As in browsers the signal is delayed by a 6 ms look-ahead
and a make-up gain raises the result so that a full-scale signal comes out
near full scale. The specification leaves the exact curve to the
implementation, so values match browsers in shape, not to the sample.
OfflineAudioContext audio = new OfflineAudioContext(2, 44100, 44100);
GainNode mix = audio.createGain();
DynamicsCompressorNode comp = audio.createDynamicsCompressor();
comp.getThreshold().setValue(-18);
comp.getRatio().setValue(4);
mix.connect(comp).connect(audio.getDestination());
-
Method Summary
Modifier and TypeMethodDescriptionHow fast the gain falls when the signal gets louder: the time constant in seconds, 0.003 by default.getKnee()The width of the soft knee in dB, 30 by default.getRatio()How many dB of input above the threshold make one dB of output, 12 by default.floatThe gain reduction currently applied, in dB: 0 or negative.How fast the gain recovers when the signal gets quieter: the time constant in seconds, 0.25 by default.The level, in dB, above which the signal is compressed; -24 by default.Methods inherited from class AudioNode
connect, connect, connect, connect, disconnect, disconnect, disconnect, disconnect, disconnect, getChannelCount, getChannelCountMode, getChannelInterpretation, getContext, getNumberOfInputs, getNumberOfOutputs, setChannelCount, setChannelCountMode, setChannelInterpretation
-
Method Details
-
getThreshold
The level, in dB, above which the signal is compressed; -24 by default.
Returns
the parameter
-
getKnee
The width of the soft knee in dB, 30 by default.
Returns
the parameter
-
getRatio
How many dB of input above the threshold make one dB of output, 12 by default.
Returns
the parameter
-
getAttack
How fast the gain falls when the signal gets louder: the time constant in seconds, 0.003 by default.
Returns
the parameter
-
getRelease
How fast the gain recovers when the signal gets quieter: the time constant in seconds, 0.25 by default.
Returns
the parameter
-
getReduction
public float getReduction()The gain reduction currently applied, in dB: 0 or negative.
Returns
decibels
-