2014-11-30 18:20:35 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/signal/WaveShaper"], function(Tone){
|
2014-11-30 01:32:33 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
2015-02-27 18:40:35 +00:00
|
|
|
* @class Convert an incoming signal between 0, 1 to an equal power gain scale.
|
2014-11-30 01:32:33 +00:00
|
|
|
*
|
2014-12-01 04:26:06 +00:00
|
|
|
* @extends {Tone.SignalBase}
|
2014-11-30 01:32:33 +00:00
|
|
|
* @constructor
|
2015-02-27 18:40:35 +00:00
|
|
|
* @example
|
2015-06-14 05:17:09 +00:00
|
|
|
* var eqPowGain = new Tone.EqualPowerGain();
|
2014-11-30 01:32:33 +00:00
|
|
|
*/
|
|
|
|
Tone.EqualPowerGain = function(){
|
|
|
|
|
2017-04-26 03:45:37 +00:00
|
|
|
Tone.SignalBase.call(this);
|
2014-11-30 01:32:33 +00:00
|
|
|
/**
|
2014-11-30 18:20:35 +00:00
|
|
|
* @type {Tone.WaveShaper}
|
2014-11-30 01:32:33 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2014-11-30 18:20:35 +00:00
|
|
|
this._eqPower = this.input = this.output = new Tone.WaveShaper(function(val){
|
2014-11-30 22:36:56 +00:00
|
|
|
if (Math.abs(val) < 0.001){
|
|
|
|
//should output 0 when input is 0
|
|
|
|
return 0;
|
|
|
|
} else {
|
2017-04-27 03:21:26 +00:00
|
|
|
return Tone.equalPowerScale(val);
|
2014-11-30 22:36:56 +00:00
|
|
|
}
|
2015-02-12 04:10:04 +00:00
|
|
|
}.bind(this), 4096);
|
2014-11-30 01:32:33 +00:00
|
|
|
};
|
|
|
|
|
2014-12-01 04:26:06 +00:00
|
|
|
Tone.extend(Tone.EqualPowerGain, Tone.SignalBase);
|
2014-11-30 01:32:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clean up
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.EqualPowerGain} this
|
2014-11-30 01:32:33 +00:00
|
|
|
*/
|
|
|
|
Tone.EqualPowerGain.prototype.dispose = function(){
|
2017-04-26 03:45:37 +00:00
|
|
|
Tone.SignalBase.prototype.dispose.call(this);
|
2014-11-30 18:20:35 +00:00
|
|
|
this._eqPower.dispose();
|
2014-11-30 01:32:33 +00:00
|
|
|
this._eqPower = null;
|
2015-02-02 03:56:33 +00:00
|
|
|
return this;
|
2014-11-30 01:32:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.EqualPowerGain;
|
2017-10-26 20:02:01 +00:00
|
|
|
});
|