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-02-27 21:53:10 +00:00
|
|
|
* @class A Panner and volume in one.
|
2014-11-04 06:27:36 +00:00
|
|
|
*
|
|
|
|
* @extends {Tone}
|
|
|
|
* @constructor
|
2015-03-07 19:17:16 +00:00
|
|
|
* @param {number} pan the initial pan
|
|
|
|
* @param {number} volume the volume
|
2015-02-27 21:53:10 +00:00
|
|
|
* @example
|
|
|
|
* var panVol = new Tone.PanVol(0.25, -12);
|
2014-11-04 06:27:36 +00:00
|
|
|
*/
|
|
|
|
Tone.PanVol = function(pan, volume){
|
2015-03-26 14:51:08 +00:00
|
|
|
|
2014-11-04 06:27:36 +00:00
|
|
|
/**
|
|
|
|
* the panning node
|
|
|
|
* @type {Tone.Panner}
|
2015-02-06 22:49:04 +00:00
|
|
|
* @private
|
2014-11-04 06:27:36 +00:00
|
|
|
*/
|
2015-02-06 22:49:04 +00:00
|
|
|
this._panner = this.input = new Tone.Panner(pan);
|
|
|
|
|
|
|
|
/**
|
2015-03-26 14:51:08 +00:00
|
|
|
* the panning control
|
|
|
|
* @type {Tone.Panner}
|
|
|
|
* @private
|
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-03-26 14:51:08 +00:00
|
|
|
* the volume control
|
|
|
|
* @type {Tone.Volume}
|
|
|
|
* @private
|
2015-02-06 22:49:04 +00:00
|
|
|
*/
|
2015-03-26 14:51:08 +00:00
|
|
|
this._volume = this.output = new Tone.Volume(volume);
|
2015-02-06 22:49:04 +00:00
|
|
|
|
|
|
|
/**
|
2015-03-26 14:51:08 +00:00
|
|
|
* The volume control in decibels.
|
|
|
|
* @type {Tone.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);
|
2014-11-04 06:27:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.PanVol);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clean up
|
2015-02-02 17:49:13 +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-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;
|
|
|
|
});
|