2014-12-19 21:27:50 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/component/Panner", "Tone/core/Master"], function(Tone){
|
2014-11-04 06:27:36 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class A Panner and volume in one
|
|
|
|
*
|
|
|
|
* @extends {Tone}
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
Tone.PanVol = function(pan, volume){
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the output node
|
|
|
|
* @type {GainNode}
|
|
|
|
*/
|
|
|
|
this.output = this.context.createGain();
|
2014-11-04 06:27:36 +00:00
|
|
|
|
|
|
|
/**
|
2015-02-12 04:10:14 +00:00
|
|
|
* The volume control in decibels.
|
|
|
|
* @type {Tone.Signal}
|
2015-02-06 22:49:04 +00:00
|
|
|
*/
|
2015-02-12 04:10:14 +00:00
|
|
|
this.volume = new Tone.Signal(this.output.gain, Tone.Signal.Units.Decibels);
|
|
|
|
this.volume.value = this.defaultArg(volume, 0);
|
2015-02-06 22:49:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the panning control
|
|
|
|
* @type {Tone.Panner}
|
|
|
|
* @private
|
2014-11-04 06:27:36 +00:00
|
|
|
*/
|
2015-02-06 22:49:04 +00:00
|
|
|
this.pan = this._panner.pan;
|
2014-11-04 06:27:36 +00:00
|
|
|
|
|
|
|
//connections
|
2015-02-06 22:49:04 +00:00
|
|
|
this._panner.connect(this.output);
|
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;
|
|
|
|
this.volume.dispose();
|
|
|
|
this.volume = null;
|
2014-11-04 06:27:36 +00:00
|
|
|
this.pan = null;
|
2015-02-02 17:49:13 +00:00
|
|
|
return this;
|
2014-11-04 06:27:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.PanVol;
|
|
|
|
});
|