mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
48 lines
No EOL
1,009 B
JavaScript
48 lines
No EOL
1,009 B
JavaScript
define(["Tone/core/Tone", "Tone/component/Compressor"], function(Tone){
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* @class A limiter on the incoming signal. Composed of a Tone.Compressor
|
|
* with a fast attack and decay value.
|
|
*
|
|
* @extends {Tone}
|
|
* @constructor
|
|
* @param {number} threshold the threshold in decibels
|
|
*/
|
|
Tone.Limiter = function(threshold){
|
|
|
|
/**
|
|
* the compressor
|
|
* @private
|
|
* @type {Tone.Compressor}
|
|
*/
|
|
this._compressor = this.input = this.output = new Tone.Compressor({
|
|
"attack" : 0.001,
|
|
"decay" : 0.001,
|
|
"threshold" : threshold
|
|
});
|
|
|
|
/**
|
|
* The threshold of of the limiter
|
|
* @type {AudioParam}
|
|
*/
|
|
this.threshold = this._compressor.threshold;
|
|
};
|
|
|
|
Tone.extend(Tone.Limiter);
|
|
|
|
/**
|
|
* clean up
|
|
* @returns {Tone.Limiter} `this`
|
|
*/
|
|
Tone.Limiter.prototype.dispose = function(){
|
|
Tone.prototype.dispose.call(this);
|
|
this._compressor.dispose();
|
|
this._compressor = null;
|
|
this.threshold = null;
|
|
return this;
|
|
};
|
|
|
|
return Tone.Limiter;
|
|
}); |