2019-01-27 18:05:20 +00:00
|
|
|
import Tone from "../core/Tone";
|
|
|
|
import "../signal/WaveShaper";
|
|
|
|
import "../signal/Signal";
|
2014-11-30 01:30:52 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* @class AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1].
|
|
|
|
* See Tone.GainToAudio.
|
|
|
|
*
|
|
|
|
* @extends {Tone.SignalBase}
|
|
|
|
* @constructor
|
|
|
|
* @example
|
|
|
|
* var a2g = new Tone.AudioToGain();
|
|
|
|
*/
|
|
|
|
Tone.AudioToGain = function(){
|
2014-11-30 01:30:52 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Tone.SignalBase.call(this);
|
2014-11-30 01:30:52 +00:00
|
|
|
/**
|
2019-01-27 18:05:20 +00:00
|
|
|
* @type {WaveShaperNode}
|
|
|
|
* @private
|
2014-11-30 01:30:52 +00:00
|
|
|
*/
|
2019-01-27 18:05:20 +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
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Tone.extend(Tone.AudioToGain, Tone.SignalBase);
|
2014-11-30 01:30:52 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
|
|
|
* @returns {Tone.AudioToGain} this
|
|
|
|
*/
|
|
|
|
Tone.AudioToGain.prototype.dispose = function(){
|
|
|
|
Tone.SignalBase.prototype.dispose.call(this);
|
|
|
|
this._norm.dispose();
|
|
|
|
this._norm = null;
|
|
|
|
return this;
|
|
|
|
};
|
2014-11-30 18:20:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
export default Tone.AudioToGain;
|
2014-11-30 01:30:52 +00:00
|
|
|
|