Tone.js/Tone/component/Volume.js

46 lines
998 B
JavaScript
Raw Normal View History

2015-03-24 20:30:04 +00:00
define(["Tone/core/Tone", "Tone/component/Panner", "Tone/core/Master"], function(Tone){
"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(pan, volume){
/**
* 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);
};
Tone.extend(Tone.Volume);
/**
* clean up
* @returns {Tone.Volume} `this`
*/
Tone.Volume.prototype.dispose = function(){
Tone.prototype.dispose.call(this);
this.volume.dispose();
this.volume = null;
return this;
};
return Tone.Volume;
});