Tone.js/Tone/component/Panner.js

56 lines
1.4 KiB
JavaScript
Raw Normal View History

define(["../core/Tone", "../component/CrossFade", "../component/Merge", "../component/Split", "../shim/StereoPannerNode",
"../signal/Signal", "../signal/AudioToGain", "../signal/Zero", "../core/AudioNode"], function(Tone){
"use strict";
2014-06-21 17:06:27 +00:00
/**
2015-07-02 00:19:58 +00:00
* @class Tone.Panner is an equal power Left/Right Panner and does not
* support 3D. Panner uses the StereoPannerNode when available.
*
2014-06-21 17:06:27 +00:00
* @constructor
* @extends {Tone.AudioNode}
2017-04-30 18:11:44 +00:00
* @param {NormalRange} [initialPan=0] The initail panner value (center).
2015-02-27 21:53:10 +00:00
* @example
* //pan the input signal hard right.
2015-02-27 21:53:10 +00:00
* var panner = new Tone.Panner(1);
2014-06-21 17:06:27 +00:00
*/
Tone.Panner = function(initialPan){
Tone.AudioNode.call(this);
/**
* the panner node
* @type {StereoPannerNode}
* @private
*/
this._panner = this.input = this.output = this.context.createStereoPanner();
/**
* The pan control. -1 = hard left, 1 = hard right.
* @type {AudioRange}
* @signal
*/
this.pan = this._panner.pan;
2015-03-24 20:29:48 +00:00
2014-06-21 17:06:27 +00:00
//initial value
2017-04-30 19:03:49 +00:00
this.pan.value = Tone.defaultArg(initialPan, 0);
2015-04-05 19:13:15 +00:00
this._readOnly("pan");
2014-06-18 21:01:31 +00:00
};
Tone.extend(Tone.Panner, Tone.AudioNode);
2014-06-21 17:06:27 +00:00
/**
2015-06-20 23:25:49 +00:00
* Clean up.
* @returns {Tone.Panner} this
2014-06-21 17:06:27 +00:00
*/
Tone.Panner.prototype.dispose = function(){
Tone.AudioNode.prototype.dispose.call(this);
2015-04-05 19:13:15 +00:00
this._writable("pan");
this._panner.disconnect();
this._panner = null;
this.pan = null;
2015-02-02 17:48:04 +00:00
return this;
2014-06-18 21:01:31 +00:00
};
return Tone.Panner;
});