Tone.js/Tone/component/PanVol.js

85 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-03-26 14:51:08 +00:00
define(["Tone/core/Tone", "Tone/component/Panner", "Tone/component/Volume"], 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}
* @constructor
2015-06-20 23:25:49 +00:00
* @param {NormalRange} pan the initial pan
* @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
* var panVol = new Tone.PanVol(0.25, -12);
*/
2015-08-28 22:32:32 +00:00
Tone.PanVol = function(){
var options = this.optionsObject(arguments, ["pan", "volume"], Tone.PanVol.defaults);
2015-03-26 14:51:08 +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.
* @type {NormalRange}
* @signal
*/
2015-03-26 14:51:08 +00:00
this.pan = this._panner.pan;
/**
2015-06-20 23:25:49 +00:00
* The volume object.
2015-03-26 14:51:08 +00:00
* @type {Tone.Volume}
2015-06-20 23:25:49 +00:00
* @signal
2015-03-26 14:51:08 +00:00
* @private
*/
2015-08-28 22:32:32 +00:00
this._volume = this.output = new Tone.Volume(options.volume);
/**
2015-03-26 14:51:08 +00:00
* The volume control in decibels.
2015-06-13 23:50:39 +00:00
* @type {Decibels}
* @signal
*/
2015-03-26 14:51:08 +00:00
this.volume = this._volume.volume;
//connections
2015-03-26 14:51:08 +00:00
this._panner.connect(this._volume);
2015-04-05 19:13:15 +00:00
this._readOnly(["pan", "volume"]);
};
Tone.extend(Tone.PanVol);
2015-08-28 22:32:32 +00:00
/**
* The defaults
* @type {Object}
* @const
* @static
*/
Tone.PanVol.defaults = {
"pan" : 0.5,
"volume" : 0
};
/**
* clean up
* @returns {Tone.PanVol} this
*/
Tone.PanVol.prototype.dispose = function(){
Tone.prototype.dispose.call(this);
2015-04-05 19:13:15 +00:00
this._writable(["pan", "volume"]);
this._panner.dispose();
this._panner = null;
2015-03-26 14:51:08 +00:00
this._volume.dispose();
this._volume = null;
this.pan = 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;
});