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";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Convert an incoming signal between 0,1 to an equal power gain scale.
|
|
|
|
*
|
|
|
|
* @extends {Tone}
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
Tone.EqualPowerGain = function(){
|
|
|
|
|
|
|
|
/**
|
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 {
|
|
|
|
return Tone.prototype.equalPowerScale(val);
|
|
|
|
}
|
|
|
|
}, 4096);
|
2014-11-30 01:32:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.EqualPowerGain);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clean up
|
|
|
|
*/
|
|
|
|
Tone.EqualPowerGain.prototype.dispose = function(){
|
|
|
|
Tone.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;
|
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.EqualPowerGain;
|
|
|
|
});
|