mirror of
https://github.com/Tonejs/Tone.js
synced 2025-01-21 16:23:53 +00:00
3d1202043a
simplifies deep references to individual files
41 lines
867 B
JavaScript
41 lines
867 B
JavaScript
define(["../core/Tone", "../signal/WaveShaper", "../signal/Signal"], function(Tone){
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* @class Maps a NormalRange [0, 1] to an AudioRange [-1, 1].
|
|
* See also Tone.AudioToGain.
|
|
*
|
|
* @extends {Tone.SignalBase}
|
|
* @constructor
|
|
* @example
|
|
* var g2a = new Tone.GainToAudio();
|
|
*/
|
|
Tone.GainToAudio = function(){
|
|
|
|
Tone.SignalBase.call(this);
|
|
|
|
/**
|
|
* @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.SignalBase.prototype.dispose.call(this);
|
|
this._norm.dispose();
|
|
this._norm = null;
|
|
return this;
|
|
};
|
|
|
|
return Tone.GainToAudio;
|
|
});
|