2014-11-30 18:20:35 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/signal/WaveShaper", "Tone/signal/Signal"], function(Tone){
|
2014-11-30 01:30:52 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
2015-06-19 04:52:04 +00:00
|
|
|
* @class AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1].
|
|
|
|
* See Tone.GainToAudio.
|
2014-11-30 01:30:52 +00:00
|
|
|
*
|
2014-12-01 04:26:06 +00:00
|
|
|
* @extends {Tone.SignalBase}
|
2014-11-30 01:30:52 +00:00
|
|
|
* @constructor
|
2015-02-27 18:40:35 +00:00
|
|
|
* @example
|
|
|
|
* var a2g = new Tone.AudioToGain();
|
2014-11-30 01:30:52 +00:00
|
|
|
*/
|
|
|
|
Tone.AudioToGain = function(){
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {WaveShaperNode}
|
|
|
|
* @private
|
|
|
|
*/
|
2015-04-05 16:12:32 +00:00
|
|
|
this._norm = this.input = this.output = new Tone.WaveShaper(function(x){
|
|
|
|
return (x + 1) / 2;
|
|
|
|
});
|
2014-11-30 01:30:52 +00:00
|
|
|
};
|
|
|
|
|
2014-12-01 04:26:06 +00:00
|
|
|
Tone.extend(Tone.AudioToGain, Tone.SignalBase);
|
2014-11-30 18:20:35 +00:00
|
|
|
|
2014-11-30 01:30:52 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.AudioToGain} this
|
2014-11-30 01:30:52 +00:00
|
|
|
*/
|
|
|
|
Tone.AudioToGain.prototype.dispose = function(){
|
|
|
|
Tone.prototype.dispose.call(this);
|
2015-04-05 18:42:14 +00:00
|
|
|
this._norm.dispose();
|
2014-11-30 01:30:52 +00:00
|
|
|
this._norm = null;
|
2015-02-02 03:56:33 +00:00
|
|
|
return this;
|
2014-11-30 01:30:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.AudioToGain;
|
|
|
|
});
|