2015-03-26 14:51:08 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/component/Panner", "Tone/component/Volume"], function(Tone){
|
2014-11-04 06:27:36 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
2015-07-02 00:19:58 +00:00
|
|
|
* @class Tone.PanVol is a Tone.Panner and Tone.Volume in one.
|
2014-11-04 06:27:36 +00:00
|
|
|
*
|
|
|
|
* @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);
|
2014-11-04 06:27:36 +00:00
|
|
|
*/
|
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
|
|
|
|
2014-11-04 06:27:36 +00:00
|
|
|
/**
|
2015-06-20 23:25:49 +00:00
|
|
|
* The panning node
|
2014-11-04 06:27:36 +00:00
|
|
|
* @type {Tone.Panner}
|
2015-02-06 22:49:04 +00:00
|
|
|
* @private
|
2014-11-04 06:27:36 +00:00
|
|
|
*/
|
2015-08-28 22:32:32 +00:00
|
|
|
this._panner = this.input = new Tone.Panner(options.pan);
|
2015-02-06 22:49:04 +00:00
|
|
|
|
|
|
|
/**
|
2015-06-20 23:25:49 +00:00
|
|
|
* The L/R panning control.
|
|
|
|
* @type {NormalRange}
|
|
|
|
* @signal
|
2015-02-06 22:49:04 +00:00
|
|
|
*/
|
2015-03-26 14:51:08 +00:00
|
|
|
this.pan = this._panner.pan;
|
2014-11-04 06:27:36 +00:00
|
|
|
|
|
|
|
/**
|
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-02-06 22:49:04 +00:00
|
|
|
*/
|
2015-08-28 22:32:32 +00:00
|
|
|
this._volume = this.output = new Tone.Volume(options.volume);
|
2015-02-06 22:49:04 +00:00
|
|
|
|
|
|
|
/**
|
2015-03-26 14:51:08 +00:00
|
|
|
* The volume control in decibels.
|
2015-06-13 23:50:39 +00:00
|
|
|
* @type {Decibels}
|
|
|
|
* @signal
|
2014-11-04 06:27:36 +00:00
|
|
|
*/
|
2015-03-26 14:51:08 +00:00
|
|
|
this.volume = this._volume.volume;
|
2014-11-04 06:27:36 +00:00
|
|
|
|
|
|
|
//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"]);
|
2014-11-04 06:27:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2014-11-04 06:27:36 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.PanVol} this
|
2014-11-04 06:27:36 +00:00
|
|
|
*/
|
|
|
|
Tone.PanVol.prototype.dispose = function(){
|
|
|
|
Tone.prototype.dispose.call(this);
|
2015-04-05 19:13:15 +00:00
|
|
|
this._writable(["pan", "volume"]);
|
2015-02-06 22:49:04 +00:00
|
|
|
this._panner.dispose();
|
|
|
|
this._panner = null;
|
2015-03-26 14:51:08 +00:00
|
|
|
this._volume.dispose();
|
|
|
|
this._volume = null;
|
2014-11-04 06:27:36 +00:00
|
|
|
this.pan = null;
|
2015-03-26 14:51:08 +00:00
|
|
|
this.volume = null;
|
2015-02-02 17:49:13 +00:00
|
|
|
return this;
|
2014-11-04 06:27:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.PanVol;
|
|
|
|
});
|