import { Param } from "../../core/context/Param"; import { ToneAudioNode, ToneAudioNodeOptions } from "../../core/context/ToneAudioNode"; import { Decibels, Positive, Time } from "../../core/type/Units"; import { optionsFromArguments } from "../../core/util/Defaults"; import { readOnly } from "../../core/util/Interface"; interface CompressorOptions extends ToneAudioNodeOptions { attack: Time; knee: Decibels; ratio: Positive; release: Time; threshold: Decibels; } /** * Compressor is a thin wrapper around the Web Audio * [DynamicsCompressorNode](http://webaudio.github.io/web-audio-api/#the-dynamicscompressornode-interface). * 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](https://en.wikipedia.org/wiki/Dynamic_range_compression). * @example * import { Compressor } from "tone"; * const comp = new Compressor(-30, 3); * @category Component */ export class Compressor extends ToneAudioNode { readonly name: string = "Compressor"; /** * the compressor node */ private _compressor: DynamicsCompressorNode = this.context.createDynamicsCompressor(); readonly input = this._compressor; readonly output = this._compressor; /** * The decibel value above which the compression will start taking effect. * @min -100 * @max 0 */ readonly threshold: Param; /** * The amount of time (in seconds) to reduce the gain by 10dB. * @min 0 * @max 1 */ readonly attack: Param