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-12-01 04:26:06 +00:00
|
|
|
* @extends {Tone.SignalBase}
|
2014-11-30 02:18:04 +00:00
|
|
|
* @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-12-01 04:26:06 +00:00
|
|
|
Tone.extend(Tone.ScaleExp, Tone.SignalBase);
|
2014-08-23 17:11:01 +00:00
|
|
|
|
|
|
|
/**
|
2015-02-06 22:47:26 +00:00
|
|
|
* The minimum output value.
|
|
|
|
* @memberOf Tone.ScaleExp#
|
|
|
|
* @type {number}
|
|
|
|
* @name exponent
|
2014-08-23 17:11:01 +00:00
|
|
|
*/
|
2015-02-06 22:47:26 +00:00
|
|
|
Object.defineProperty(Tone.ScaleExp.prototype, "exponent", {
|
|
|
|
get : function(){
|
|
|
|
return this._exp.value;
|
|
|
|
},
|
|
|
|
set : function(exp){
|
|
|
|
this._exp.value = exp;
|
|
|
|
}
|
|
|
|
});
|
2014-08-23 17:11:01 +00:00
|
|
|
|
|
|
|
/**
|
2015-02-06 22:47:26 +00:00
|
|
|
* The minimum output value.
|
|
|
|
* @memberOf Tone.ScaleExp#
|
|
|
|
* @type {number}
|
|
|
|
* @name min
|
2014-08-23 17:11:01 +00:00
|
|
|
*/
|
2015-02-06 22:47:26 +00:00
|
|
|
Object.defineProperty(Tone.ScaleExp.prototype, "min", {
|
|
|
|
get : function(){
|
|
|
|
return this._scale.min;
|
|
|
|
},
|
|
|
|
set : function(min){
|
|
|
|
this._scale.min = min;
|
|
|
|
}
|
|
|
|
});
|
2014-08-23 17:11:01 +00:00
|
|
|
|
|
|
|
/**
|
2015-02-06 22:47:26 +00:00
|
|
|
* The maximum output value.
|
|
|
|
* @memberOf Tone.ScaleExp#
|
|
|
|
* @type {number}
|
|
|
|
* @name max
|
2014-08-23 17:11:01 +00:00
|
|
|
*/
|
2015-02-06 22:47:26 +00:00
|
|
|
Object.defineProperty(Tone.ScaleExp.prototype, "max", {
|
|
|
|
get : function(){
|
|
|
|
return this._scale.max;
|
|
|
|
},
|
|
|
|
set : function(max){
|
|
|
|
this._scale.max = max;
|
|
|
|
}
|
|
|
|
});
|
2014-08-23 17:11:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clean up
|
2015-02-02 03:56:33 +00:00
|
|
|
* @returns {Tone.ScaleExp} `this`
|
2014-08-23 17:11:01 +00:00
|
|
|
*/
|
|
|
|
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;
|
2015-02-02 03:56:33 +00:00
|
|
|
return this;
|
2014-08-23 17:11:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return Tone.ScaleExp;
|
|
|
|
});
|