Skip to content
Tone.js

Compressor

class Component ↳ extends ToneAudioNode<CompressorOptions>

Compressor is a thin wrapper around the Web Audio DynamicsCompressorNode. Compression reduces the volume of loud sounds or amplifies quiet sounds by narrowing or “compressing” an audio signal’s dynamic range. Read more on Wikipedia.

const comp = new Tone.Compressor(-30, 3);
new Compressor(threshold?: number, ratio?: number)

Parameters

  • threshold number optional

    The value above which the compression starts to be applied.

  • ratio number optional

    The gain reduction ratio.

new Compressor(options?: Partial<CompressorOptions>)

Parameters

read-only

attack: Param<"time">

The amount of time (in seconds) to reduce the gain by 10dB.

Range: 0 to 1

read-only

input: DynamicsCompressorNode

The input node or nodes. If the object is a source, it does not have any input and this.input is undefined.

read-only

knee: Param<"decibels">

A decibel value representing the range above the threshold where the curve smoothly transitions to the “ratio” portion.

Range: 0 to 40

read-only

name: string

The name of the class

Default: "Compressor"

read-only

output: DynamicsCompressorNode

The output nodes. If the object is a sink, it does not have any output and this.output is undefined.

read-only

ratio: Param<"positive">

The amount of dB change in input for a 1 dB change in output.

Range: 1 to 20

read-only

release: Param<"time">

The amount of time (in seconds) to increase the gain by 10dB.

Range: 0 to 1

read-only

threshold: Param<"decibels">

The decibel value above which the compression will start taking effect.

Range: -100 to 0

read-only

reduction: number

A read-only decibel value for metering purposes, representing the current amount of gain reduction that the compressor is applying to the signal. If fed no signal the value will be 0 (no gain reduction).

dispose(): this

Dispose and disconnect

Returns this

static

getDefaults(): CompressorOptions

Returns all of the default options belonging to the class.

Returns CompressorOptions