2014-11-30 02:18:04 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/signal/Scale", "Tone/signal/Pow"],
|
2014-11-02 01:52:49 +00:00
|
|
|
function(Tone){
|
2014-08-23 17:11:01 +00:00
|
|
|
|
|
|
|
/**
|
2014-09-05 15:32:33 +00:00
|
|
|
* @class performs an exponential scaling on an input signal.
|
2014-11-30 02:18:04 +00:00
|
|
|
* Scales a normal gain range [0,1] exponentially
|
2014-08-23 17:11:01 +00:00
|
|
|
* to the output range of outputMin to outputMax.
|
|
|
|
*
|
|
|
|
* @constructor
|
2014-11-30 02:18:04 +00:00
|
|
|
* @extends {Tone.Scale}
|
|
|
|
* @param {number} [outputMin=0]
|
|
|
|
* @param {number} [outputMax=1]
|
|
|
|
* @param {number} [exponent=2] the exponent which scales the incoming signal
|
2014-08-23 17:11:01 +00:00
|
|
|
*/
|
2014-11-30 02:18:04 +00:00
|
|
|
Tone.ScaleExp = function(outputMin, outputMax, exponent){
|
2014-08-23 17:11:01 +00:00
|
|
|
|
2014-11-30 02:18:04 +00:00
|
|
|
/**
|
|
|
|
* scale the input to the output range
|
|
|
|
* @type {Tone.Scale}
|
2014-08-23 17:11:01 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2014-11-30 02:18:04 +00:00
|
|
|
this._scale = this.output = new Tone.Scale(outputMin, outputMax);
|
2014-08-23 17:11:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
2014-11-02 01:52:49 +00:00
|
|
|
* @type {Tone.Pow}
|
2014-11-30 02:18:04 +00:00
|
|
|
* @private
|
2014-08-23 17:11:01 +00:00
|
|
|
*/
|
2014-11-30 02:18:04 +00:00
|
|
|
this._exp = this.input = new Tone.Pow(this.defaultArg(exponent, 2));
|
2014-08-23 17:11:01 +00:00
|
|
|
|
2014-11-30 02:18:04 +00:00
|
|
|
this._exp.connect(this._scale);
|
2014-08-23 17:11:01 +00:00
|
|
|
};
|
|
|
|
|
2014-11-30 02:18:04 +00:00
|
|
|
Tone.extend(Tone.ScaleExp, Tone.Scale);
|
2014-08-23 17:11:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set the exponential scaling curve
|
|
|
|
* @param {number} exp the exponent to raise the incoming signal to
|
|
|
|
*/
|
|
|
|
Tone.ScaleExp.prototype.setExponent = function(exp){
|
2014-11-30 02:18:04 +00:00
|
|
|
this._exp.setExponent(exp);
|
2014-08-23 17:11:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-11-30 02:18:04 +00:00
|
|
|
* set the minimum output value
|
|
|
|
* @param {number} min the minimum output value
|
2014-08-23 17:11:01 +00:00
|
|
|
*/
|
2014-11-30 02:18:04 +00:00
|
|
|
Tone.ScaleExp.prototype.setMin = function(min){
|
|
|
|
this._scale.setMin(min);
|
2014-08-23 17:11:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-11-30 02:18:04 +00:00
|
|
|
* set the minimum output value
|
|
|
|
* @param {number} min the minimum output value
|
2014-08-23 17:11:01 +00:00
|
|
|
*/
|
2014-11-30 02:18:04 +00:00
|
|
|
Tone.ScaleExp.prototype.setMax = function(max){
|
|
|
|
this._scale.setMax(max);
|
2014-08-23 17:11:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clean up
|
|
|
|
*/
|
|
|
|
Tone.ScaleExp.prototype.dispose = function(){
|
2014-09-06 22:55:11 +00:00
|
|
|
Tone.prototype.dispose.call(this);
|
2014-08-23 17:11:01 +00:00
|
|
|
this._scale.dispose();
|
|
|
|
this._scale = null;
|
2014-11-30 02:18:04 +00:00
|
|
|
this._exp.dispose();
|
|
|
|
this._exp = null;
|
2014-08-23 17:11:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return Tone.ScaleExp;
|
|
|
|
});
|