Tone.js/Tone/component/MidSideCompressor.js

95 lines
2.2 KiB
JavaScript
Raw Normal View History

define(["Tone/core/Tone", "Tone/component/MidSideSplit", "Tone/component/MidSideMerge",
"Tone/component/Compressor", "Tone/core/AudioNode"], function(Tone){
2015-04-20 19:41:49 +00:00
"use strict";
/**
2015-07-02 19:45:40 +00:00
* @class Tone.MidSideCompressor applies two different compressors to the mid
* and side signal components. See Tone.MidSideSplit.
2015-04-20 19:41:49 +00:00
*
* @extends {Tone.AudioNode}
2015-06-20 23:25:49 +00:00
* @param {Object} options The options that are passed to the mid and side
* compressors.
2015-04-20 19:41:49 +00:00
* @constructor
*/
Tone.MidSideCompressor = function(options){
Tone.AudioNode.call(this);
2017-04-30 19:03:49 +00:00
options = Tone.defaultArg(options, Tone.MidSideCompressor.defaults);
2015-04-20 19:41:49 +00:00
/**
* the mid/side split
* @type {Tone.MidSideSplit}
* @private
*/
this._midSideSplit = this.input = new Tone.MidSideSplit();
/**
* the mid/side recombination
* @type {Tone.MidSideMerge}
* @private
*/
this._midSideMerge = this.output = new Tone.MidSideMerge();
/**
* The compressor applied to the mid signal
* @type {Tone.Compressor}
*/
this.mid = new Tone.Compressor(options.mid);
/**
* The compressor applied to the side signal
* @type {Tone.Compressor}
*/
this.side = new Tone.Compressor(options.side);
this._midSideSplit.mid.chain(this.mid, this._midSideMerge.mid);
this._midSideSplit.side.chain(this.side, this._midSideMerge.side);
this._readOnly(["mid", "side"]);
};
Tone.extend(Tone.MidSideCompressor, Tone.AudioNode);
2015-04-20 19:41:49 +00:00
/**
* @const
* @static
* @type {Object}
*/
Tone.MidSideCompressor.defaults = {
"mid" : {
"ratio" : 3,
"threshold" : -24,
"release" : 0.03,
"attack" : 0.02,
"knee" : 16
},
"side" : {
"ratio" : 6,
"threshold" : -30,
"release" : 0.25,
"attack" : 0.03,
"knee" : 10
}
};
/**
2015-06-20 23:25:49 +00:00
* Clean up.
* @returns {Tone.MidSideCompressor} this
2015-04-20 19:41:49 +00:00
*/
Tone.MidSideCompressor.prototype.dispose = function(){
Tone.AudioNode.prototype.dispose.call(this);
2015-04-20 19:41:49 +00:00
this._writable(["mid", "side"]);
this.mid.dispose();
this.mid = null;
this.side.dispose();
this.side = null;
this._midSideSplit.dispose();
this._midSideSplit = null;
this._midSideMerge.dispose();
this._midSideMerge = null;
return this;
};
return Tone.MidSideCompressor;
});