Tone.js/Tone/signal/AudioToGain.js

39 lines
836 B
JavaScript
Raw Normal View History

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
*
* @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
*/
this._norm = this.input = this.output = new Tone.WaveShaper(function(x){
return (x + 1) / 2;
});
2014-11-30 01:30:52 +00:00
};
Tone.extend(Tone.AudioToGain, Tone.SignalBase);
2014-11-30 01:30:52 +00:00
/**
* clean up
* @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;
});