mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
38 lines
No EOL
787 B
JavaScript
38 lines
No EOL
787 B
JavaScript
define(["Tone/core/Tone", "Tone/signal/WaveShaper", "Tone/signal/Signal"], function(Tone){
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* @class Maps a gain value [0, 1] to an audio value [-1, 1]
|
|
*
|
|
* @extends {Tone.SignalBase}
|
|
* @constructor
|
|
* @example
|
|
* var g2a = new Tone.GainToAudio();
|
|
*/
|
|
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
|
|
* @returns {Tone.GainToAudio} this
|
|
*/
|
|
Tone.GainToAudio.prototype.dispose = function(){
|
|
Tone.prototype.dispose.call(this);
|
|
this._norm.dispose();
|
|
this._norm = null;
|
|
return this;
|
|
};
|
|
|
|
return Tone.GainToAudio;
|
|
}); |