2015-03-26 14:51:08 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/signal/Signal", "Tone/core/Master"], function(Tone){
|
2015-03-24 20:30:04 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
2015-07-02 00:19:58 +00:00
|
|
|
* @class Tone.Volume is a simple volume node, useful for creating a volume fader.
|
2015-03-24 20:30:04 +00:00
|
|
|
*
|
|
|
|
* @extends {Tone}
|
|
|
|
* @constructor
|
2015-06-20 19:50:57 +00:00
|
|
|
* @param {Decibels} [volume=0] the initial volume
|
2015-03-24 20:30:04 +00:00
|
|
|
* @example
|
2015-06-14 05:09:06 +00:00
|
|
|
* var vol = new Tone.Volume(-12);
|
|
|
|
* instrument.chain(vol, Tone.Master);
|
2015-03-24 20:30:04 +00:00
|
|
|
*/
|
2015-05-21 17:52:06 +00:00
|
|
|
Tone.Volume = function(volume){
|
2015-03-24 20:30:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the output node
|
|
|
|
* @type {GainNode}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this.output = this.input = this.context.createGain();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The volume control in decibels.
|
2015-06-20 19:50:57 +00:00
|
|
|
* @type {Decibels}
|
|
|
|
* @signal
|
2015-03-24 20:30:04 +00:00
|
|
|
*/
|
2015-05-23 22:57:05 +00:00
|
|
|
this.volume = new Tone.Signal(this.output.gain, Tone.Type.Decibels);
|
2015-03-24 20:30:04 +00:00
|
|
|
this.volume.value = this.defaultArg(volume, 0);
|
2015-04-05 19:13:15 +00:00
|
|
|
|
|
|
|
this._readOnly("volume");
|
2015-03-24 20:30:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.Volume);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clean up
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.Volume} this
|
2015-03-24 20:30:04 +00:00
|
|
|
*/
|
|
|
|
Tone.Volume.prototype.dispose = function(){
|
|
|
|
Tone.prototype.dispose.call(this);
|
2015-04-05 19:13:15 +00:00
|
|
|
this._writable("volume");
|
2015-03-24 20:30:04 +00:00
|
|
|
this.volume.dispose();
|
|
|
|
this.volume = null;
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.Volume;
|
|
|
|
});
|