2015-02-24 00:46:28 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/component/MultibandSplit", "Tone/signal/Signal"], function(Tone){
|
2014-08-24 16:46:45 +00:00
|
|
|
|
2014-09-04 04:41:40 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-08-24 16:46:45 +00:00
|
|
|
/**
|
2015-07-02 19:45:40 +00:00
|
|
|
* @class Tone.EQ3 is a three band EQ with control over low, mid, and high gain as
|
2015-07-02 00:19:58 +00:00
|
|
|
* well as the low and high crossover frequencies.
|
2014-08-24 16:46:45 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone}
|
|
|
|
*
|
2015-06-20 23:25:49 +00:00
|
|
|
* @param {Decibels|Object} [lowLevel] The gain applied to the lows.
|
|
|
|
* @param {Decibels} [midLevel] The gain applied to the mid.
|
|
|
|
* @param {Decibels} [highLevel] The gain applied to the high.
|
2015-02-27 21:53:10 +00:00
|
|
|
* @example
|
2015-06-20 23:25:49 +00:00
|
|
|
* var eq = new Tone.EQ3(-10, 3, -20);
|
2014-08-24 16:46:45 +00:00
|
|
|
*/
|
2015-04-20 14:41:55 +00:00
|
|
|
Tone.EQ3 = function(){
|
2014-08-24 16:46:45 +00:00
|
|
|
|
2015-04-20 14:41:55 +00:00
|
|
|
var options = this.optionsObject(arguments, ["low", "mid", "high"], Tone.EQ3.defaults);
|
2014-08-24 16:46:45 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-13 19:58:06 +00:00
|
|
|
* the output node
|
|
|
|
* @type {GainNode}
|
2015-02-27 21:53:10 +00:00
|
|
|
* @private
|
2014-08-24 16:46:45 +00:00
|
|
|
*/
|
2014-10-13 19:58:06 +00:00
|
|
|
this.output = this.context.createGain();
|
2014-08-24 16:46:45 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-13 19:58:06 +00:00
|
|
|
* the multiband split
|
|
|
|
* @type {Tone.MultibandSplit}
|
2014-08-24 16:46:45 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2015-02-27 21:53:10 +00:00
|
|
|
this._multibandSplit = this.input = new Tone.MultibandSplit({
|
2014-10-13 19:58:06 +00:00
|
|
|
"lowFrequency" : options.lowFrequency,
|
|
|
|
"highFrequency" : options.highFrequency
|
|
|
|
});
|
2014-08-24 16:46:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the low gain
|
|
|
|
* @type {GainNode}
|
2015-02-06 22:49:04 +00:00
|
|
|
* @private
|
2014-08-24 16:46:45 +00:00
|
|
|
*/
|
2015-02-06 22:49:04 +00:00
|
|
|
this._lowGain = this.context.createGain();
|
2014-08-24 16:46:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the mid gain
|
|
|
|
* @type {GainNode}
|
2015-02-06 22:49:04 +00:00
|
|
|
* @private
|
2014-08-24 16:46:45 +00:00
|
|
|
*/
|
2015-02-06 22:49:04 +00:00
|
|
|
this._midGain = this.context.createGain();
|
2014-08-24 16:46:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the high gain
|
|
|
|
* @type {GainNode}
|
2015-02-06 22:49:04 +00:00
|
|
|
* @private
|
2014-08-24 16:46:45 +00:00
|
|
|
*/
|
2015-02-06 22:49:04 +00:00
|
|
|
this._highGain = this.context.createGain();
|
2014-08-24 16:46:45 +00:00
|
|
|
|
2015-02-24 00:46:28 +00:00
|
|
|
/**
|
|
|
|
* The gain in decibels of the low part
|
2015-06-13 23:29:25 +00:00
|
|
|
* @type {Decibels}
|
|
|
|
* @signal
|
2015-02-24 00:46:28 +00:00
|
|
|
*/
|
2015-05-23 22:57:05 +00:00
|
|
|
this.low = new Tone.Signal(this._lowGain.gain, Tone.Type.Decibels);
|
2015-02-24 00:46:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The gain in decibels of the mid part
|
2015-06-13 23:29:25 +00:00
|
|
|
* @type {Decibels}
|
|
|
|
* @signal
|
2015-02-24 00:46:28 +00:00
|
|
|
*/
|
2015-05-23 22:57:05 +00:00
|
|
|
this.mid = new Tone.Signal(this._midGain.gain, Tone.Type.Decibels);
|
2015-02-24 00:46:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The gain in decibels of the high part
|
2015-06-13 23:29:25 +00:00
|
|
|
* @type {Decibels}
|
|
|
|
* @signal
|
2015-02-24 00:46:28 +00:00
|
|
|
*/
|
2015-05-23 22:57:05 +00:00
|
|
|
this.high = new Tone.Signal(this._highGain.gain, Tone.Type.Decibels);
|
2015-02-24 00:46:28 +00:00
|
|
|
|
2015-05-22 14:12:50 +00:00
|
|
|
/**
|
2015-06-20 23:25:49 +00:00
|
|
|
* The Q value for all of the filters.
|
2015-06-13 23:29:25 +00:00
|
|
|
* @type {Positive}
|
|
|
|
* @signal
|
2015-05-22 14:12:50 +00:00
|
|
|
*/
|
|
|
|
this.Q = this._multibandSplit.Q;
|
|
|
|
|
2014-10-13 19:58:06 +00:00
|
|
|
/**
|
2015-06-20 23:25:49 +00:00
|
|
|
* The low/mid crossover frequency.
|
2015-06-13 23:29:25 +00:00
|
|
|
* @type {Frequency}
|
|
|
|
* @signal
|
2014-10-13 19:58:06 +00:00
|
|
|
*/
|
|
|
|
this.lowFrequency = this._multibandSplit.lowFrequency;
|
|
|
|
|
|
|
|
/**
|
2015-06-20 23:25:49 +00:00
|
|
|
* The mid/high crossover frequency.
|
2015-06-13 23:29:25 +00:00
|
|
|
* @type {Frequency}
|
|
|
|
* @signal
|
2014-10-13 19:58:06 +00:00
|
|
|
*/
|
|
|
|
this.highFrequency = this._multibandSplit.highFrequency;
|
|
|
|
|
2014-08-24 16:46:45 +00:00
|
|
|
//the frequency bands
|
2015-02-06 22:49:04 +00:00
|
|
|
this._multibandSplit.low.chain(this._lowGain, this.output);
|
|
|
|
this._multibandSplit.mid.chain(this._midGain, this.output);
|
|
|
|
this._multibandSplit.high.chain(this._highGain, this.output);
|
2014-09-12 00:31:37 +00:00
|
|
|
//set the gains
|
2015-05-22 14:12:50 +00:00
|
|
|
this.low.value = options.low;
|
2015-02-24 00:46:28 +00:00
|
|
|
this.mid.value = options.mid;
|
2015-05-22 14:12:50 +00:00
|
|
|
this.high.value = options.high;
|
2015-04-05 19:13:15 +00:00
|
|
|
this._readOnly(["low", "mid", "high", "lowFrequency", "highFrequency"]);
|
2014-08-24 16:46:45 +00:00
|
|
|
};
|
|
|
|
|
2015-04-20 14:41:55 +00:00
|
|
|
Tone.extend(Tone.EQ3);
|
2014-08-24 16:46:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the default values
|
|
|
|
*/
|
2015-04-20 14:41:55 +00:00
|
|
|
Tone.EQ3.defaults = {
|
2015-01-06 04:33:05 +00:00
|
|
|
"low" : 0,
|
|
|
|
"mid" : 0,
|
|
|
|
"high" : 0,
|
2014-08-24 16:46:45 +00:00
|
|
|
"lowFrequency" : 400,
|
|
|
|
"highFrequency" : 2500
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clean up
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.EQ3} this
|
2014-08-24 16:46:45 +00:00
|
|
|
*/
|
2015-04-20 14:41:55 +00:00
|
|
|
Tone.EQ3.prototype.dispose = function(){
|
2014-08-24 16:46:45 +00:00
|
|
|
Tone.prototype.dispose.call(this);
|
2015-04-05 19:13:15 +00:00
|
|
|
this._writable(["low", "mid", "high", "lowFrequency", "highFrequency"]);
|
2014-10-13 19:58:06 +00:00
|
|
|
this._multibandSplit.dispose();
|
|
|
|
this._multibandSplit = null;
|
2014-08-24 16:46:45 +00:00
|
|
|
this.lowFrequency = null;
|
|
|
|
this.highFrequency = null;
|
2015-02-24 00:46:28 +00:00
|
|
|
this._lowGain.disconnect();
|
2015-02-06 22:49:04 +00:00
|
|
|
this._lowGain = null;
|
2015-02-24 00:46:28 +00:00
|
|
|
this._midGain.disconnect();
|
2015-02-06 22:49:04 +00:00
|
|
|
this._midGain = null;
|
2015-02-24 00:46:28 +00:00
|
|
|
this._highGain.disconnect();
|
2015-02-06 22:49:04 +00:00
|
|
|
this._highGain = null;
|
2015-02-24 00:46:28 +00:00
|
|
|
this.low.dispose();
|
|
|
|
this.low = null;
|
|
|
|
this.mid.dispose();
|
|
|
|
this.mid = null;
|
|
|
|
this.high.dispose();
|
|
|
|
this.high = null;
|
2015-05-22 14:12:50 +00:00
|
|
|
this.Q = null;
|
2015-02-02 17:49:13 +00:00
|
|
|
return this;
|
2014-08-24 16:46:45 +00:00
|
|
|
};
|
|
|
|
|
2015-04-20 14:41:55 +00:00
|
|
|
return Tone.EQ3;
|
2014-08-24 16:46:45 +00:00
|
|
|
});
|