Tone.js/Tone/component/PanVol.js

66 lines
1.3 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-02-27 21:53:10 +00:00
* @class A Panner and volume in one.
*
* @extends {Tone}
* @constructor
* @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);
*/
Tone.PanVol = function(pan, volume){
2015-03-26 14:51:08 +00:00
/**
* the panning node
* @type {Tone.Panner}
* @private
*/
this._panner = this.input = new Tone.Panner(pan);
/**
2015-03-26 14:51:08 +00:00
* the panning control
* @type {Tone.Panner}
* @private
*/
2015-03-26 14:51:08 +00:00
this.pan = this._panner.pan;
/**
2015-03-26 14:51:08 +00:00
* the volume control
* @type {Tone.Volume}
* @private
*/
2015-03-26 14:51:08 +00:00
this._volume = this.output = new Tone.Volume(volume);
/**
2015-03-26 14:51:08 +00:00
* The volume control in decibels.
* @type {Tone.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);
};
Tone.extend(Tone.PanVol);
/**
* clean up
2015-02-02 17:49:13 +00:00
* @returns {Tone.PanVol} `this`
*/
Tone.PanVol.prototype.dispose = function(){
Tone.prototype.dispose.call(this);
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;
});