2015-04-05 16:13:03 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/signal/WaveShaper", "Tone/signal/Signal"], function(Tone){
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
2015-06-19 04:52:04 +00:00
|
|
|
* @class Maps a NormalRange [0, 1] to an AudioRange [-1, 1].
|
|
|
|
* See also Tone.AudioToGain.
|
2015-04-05 16:13:03 +00:00
|
|
|
*
|
|
|
|
* @extends {Tone.SignalBase}
|
|
|
|
* @constructor
|
|
|
|
* @example
|
2015-06-14 05:17:09 +00:00
|
|
|
* var g2a = new Tone.GainToAudio();
|
2015-04-05 16:13:03 +00:00
|
|
|
*/
|
|
|
|
Tone.GainToAudio = function(){
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {WaveShaperNode}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._norm = this.input = this.output = new Tone.WaveShaper(function(x){
|
|
|
|
return Math.abs(x) * 2 - 1;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.GainToAudio, Tone.SignalBase);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clean up
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.GainToAudio} this
|
2015-04-05 16:13:03 +00:00
|
|
|
*/
|
|
|
|
Tone.GainToAudio.prototype.dispose = function(){
|
|
|
|
Tone.prototype.dispose.call(this);
|
2015-04-05 18:42:14 +00:00
|
|
|
this._norm.dispose();
|
2015-04-05 16:13:03 +00:00
|
|
|
this._norm = null;
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.GainToAudio;
|
|
|
|
});
|