Tone.js/Tone/component/PanVol.js

103 lines
2 KiB
JavaScript
Raw Normal View History

define(["../core/Tone", "../component/Panner", "../component/Volume", "../core/AudioNode"], function(Tone){
"use strict";
/**
2015-07-02 00:19:58 +00:00
* @class Tone.PanVol is a Tone.Panner and Tone.Volume in one.
*
* @extends {Tone.AudioNode}
* @constructor
2016-09-25 23:00:10 +00:00
* @param {AudioRange} pan the initial pan
2017-08-27 17:57:50 +00:00
* @param {number} volume The output volume.
2015-02-27 21:53:10 +00:00
* @example
2015-06-20 23:25:49 +00:00
* //pan the incoming signal left and drop the volume
2017-03-29 01:14:48 +00:00
* var panVol = new Tone.PanVol(-0.25, -12);
*/
2015-08-28 22:32:32 +00:00
Tone.PanVol = function(){
var options = Tone.defaults(arguments, ["pan", "volume"], Tone.PanVol);
Tone.AudioNode.call(this);
2017-08-27 17:57:50 +00:00
/**
2015-06-20 23:25:49 +00:00
* The panning node
* @type {Tone.Panner}
* @private
*/
2015-08-28 22:32:32 +00:00
this._panner = this.input = new Tone.Panner(options.pan);
/**
2015-06-20 23:25:49 +00:00
* The L/R panning control.
2016-09-25 23:00:10 +00:00
* @type {AudioRange}
2015-06-20 23:25:49 +00:00
* @signal
*/
2015-03-26 14:51:08 +00:00
this.pan = this._panner.pan;
2015-11-01 22:49:53 +00:00
/**
* The volume node
* @type {Tone.Volume}
2017-08-12 14:45:28 +00:00
* @private
2015-11-01 22:49:53 +00:00
*/
this._volume = this.output = new Tone.Volume(options.volume);
/**
2017-08-27 17:57:50 +00:00
* The volume control in decibels.
2015-06-13 23:50:39 +00:00
* @type {Decibels}
* @signal
*/
2015-11-01 22:49:53 +00:00
this.volume = this._volume.volume;
//connections
2015-11-01 22:49:53 +00:00
this._panner.connect(this._volume);
2017-08-27 17:57:50 +00:00
this.mute = options.mute;
2015-04-05 19:13:15 +00:00
this._readOnly(["pan", "volume"]);
};
Tone.extend(Tone.PanVol, Tone.AudioNode);
2015-08-28 22:32:32 +00:00
/**
* The defaults
* @type {Object}
* @const
* @static
*/
Tone.PanVol.defaults = {
2017-08-27 17:57:50 +00:00
"pan" : 0,
"volume" : 0,
"mute" : false
2015-08-28 22:32:32 +00:00
};
2017-08-27 17:57:50 +00:00
/**
* Mute/unmute the volume
* @memberOf Tone.PanVol#
* @name mute
* @type {Boolean}
*/
Object.defineProperty(Tone.PanVol.prototype, "mute", {
get : function(){
return this._volume.mute;
},
set : function(mute){
this._volume.mute = mute;
}
});
/**
* clean up
* @returns {Tone.PanVol} this
*/
Tone.PanVol.prototype.dispose = function(){
Tone.AudioNode.prototype.dispose.call(this);
2015-04-05 19:13:15 +00:00
this._writable(["pan", "volume"]);
this._panner.dispose();
this._panner = null;
this.pan = null;
2015-11-01 22:49:53 +00:00
this._volume.dispose();
this._volume = null;
2015-03-26 14:51:08 +00:00
this.volume = null;
2015-02-02 17:49:13 +00:00
return this;
};
return Tone.PanVol;
2017-08-27 17:57:50 +00:00
});