Tone.js/Tone/signal/EqualPowerGain.js
2014-11-30 17:36:56 -05:00

39 lines
No EOL
796 B
JavaScript

define(["Tone/core/Tone", "Tone/signal/WaveShaper"], function(Tone){
"use strict";
/**
* @class Convert an incoming signal between 0,1 to an equal power gain scale.
*
* @extends {Tone}
* @constructor
*/
Tone.EqualPowerGain = function(){
/**
* @type {Tone.WaveShaper}
* @private
*/
this._eqPower = this.input = this.output = new Tone.WaveShaper(function(val){
if (Math.abs(val) < 0.001){
//should output 0 when input is 0
return 0;
} else {
return Tone.prototype.equalPowerScale(val);
}
}, 4096);
};
Tone.extend(Tone.EqualPowerGain);
/**
* clean up
*/
Tone.EqualPowerGain.prototype.dispose = function(){
Tone.prototype.dispose.call(this);
this._eqPower.dispose();
this._eqPower = null;
};
return Tone.EqualPowerGain;
});