Tone.js/Tone/component/Volume.js

49 lines
1 KiB
JavaScript
Raw Normal View History

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";
/**
* @class A simple volume node. Volume value in decibels.
*
* @extends {Tone}
* @constructor
* @param {number} [volume=0] the initial volume
* @example
* var vol = new Tone.Volume(-12);
* instrument.chain(vol, Tone.Master);
*/
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.
* @type {Tone.Signal}
*/
this.volume = new Tone.Signal(this.output.gain, Tone.Signal.Units.Decibels);
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
* @returns {Tone.Volume} `this`
*/
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;
});