Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class DynamicsCompressorNode

  1. Object
  2. AudioNode
  3. 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());

Methods

public AudioParam getThreshold()The level, in dB, above which the signal is compressed; -24 by default.
public AudioParam getKnee()The width of the soft knee in dB, 30 by default.
public AudioParam getRatio()How many dB of input above the threshold make one dB of output, 12 by default.
public AudioParam getAttack()How fast the gain falls when the signal gets louder: the time constant in seconds, 0.003 by default.
public AudioParam getRelease()How fast the gain recovers when the signal gets quieter: the time constant in seconds, 0.25 by default.
public float getReduction()The gain reduction currently applied, in dB: 0 or negative.

Inherited methods

Method details

getThreshold

public AudioParam getThreshold()
The level, in dB, above which the signal is compressed; -24 by default.

Returns

the parameter

getKnee

public AudioParam getKnee()
The width of the soft knee in dB, 30 by default.

Returns

the parameter

getRatio

public AudioParam getRatio()
How many dB of input above the threshold make one dB of output, 12 by default.

Returns

the parameter

getAttack

public AudioParam getAttack()
How fast the gain falls when the signal gets louder: the time constant in seconds, 0.003 by default.

Returns

the parameter

getRelease

public AudioParam 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