Tone.js/Tone/component/Volume.js

62 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-08-31 20:59:36 +00:00
define(["Tone/core/Tone", "Tone/signal/Signal", "Tone/core/Gain"], 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-08-28 22:32:32 +00:00
Tone.Volume = function(){
2015-11-01 22:49:33 +00:00
var options = this.optionsObject(arguments, ["volume"], Tone.Volume.defaults);
2015-03-24 20:30:04 +00:00
2015-11-01 22:49:33 +00:00
/**
* 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");
2015-03-24 20:30:04 +00:00
};
2015-11-01 22:49:33 +00:00
Tone.extend(Tone.Volume);
2015-03-24 20:30:04 +00:00
2015-08-28 22:32:32 +00:00
/**
* Defaults
* @type {Object}
* @const
* @static
*/
Tone.Volume.defaults = {
2015-11-01 22:49:33 +00:00
"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;
2015-03-24 20:30:04 +00:00
};
return Tone.Volume;
});