mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
62 lines
No EOL
1.2 KiB
JavaScript
62 lines
No EOL
1.2 KiB
JavaScript
define(["Tone/core/Tone", "Tone/signal/Signal", "Tone/core/Gain"], function(Tone){
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* @class Tone.Volume is a simple volume node, useful for creating a volume fader.
|
|
*
|
|
* @extends {Tone}
|
|
* @constructor
|
|
* @param {Decibels} [volume=0] the initial volume
|
|
* @example
|
|
* var vol = new Tone.Volume(-12);
|
|
* instrument.chain(vol, Tone.Master);
|
|
*/
|
|
Tone.Volume = function(){
|
|
|
|
var options = this.optionsObject(arguments, ["volume"], Tone.Volume.defaults);
|
|
|
|
/**
|
|
* the output node
|
|
* @type {GainNode}
|
|
* @private
|
|
*/
|
|
this.output = this.input = new Tone.Gain(options.volume, Tone.Type.Decibels);
|
|
|
|
/**
|
|
* The volume control in decibels.
|
|
* @type {Decibels}
|
|
* @signal
|
|
*/
|
|
this.volume = this.output.gain;
|
|
|
|
this._readOnly("volume");
|
|
};
|
|
|
|
Tone.extend(Tone.Volume);
|
|
|
|
/**
|
|
* Defaults
|
|
* @type {Object}
|
|
* @const
|
|
* @static
|
|
*/
|
|
Tone.Volume.defaults = {
|
|
"volume" : 0
|
|
};
|
|
|
|
/**
|
|
* clean up
|
|
* @returns {Tone.Volume} this
|
|
*/
|
|
Tone.Volume.prototype.dispose = function(){
|
|
this.input.dispose();
|
|
Tone.prototype.dispose.call(this);
|
|
this._writable("volume");
|
|
this.volume.dispose();
|
|
this.volume = null;
|
|
return this;
|
|
};
|
|
|
|
return Tone.Volume;
|
|
}); |