2014-04-06 20:51:30 +00:00
|
|
|
define(["Tone/core/Tone"], function(Tone){
|
2014-04-05 22:05:42 +00:00
|
|
|
|
2014-09-04 04:41:40 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-06-17 15:40:01 +00:00
|
|
|
/**
|
2015-02-27 21:53:10 +00:00
|
|
|
* @class Merge a left and a right channel into a single stereo channel.
|
2014-06-17 15:40:01 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone}
|
2015-02-27 21:53:10 +00:00
|
|
|
* @example
|
|
|
|
* var merge = new Tone.Merge();
|
|
|
|
* sigLeft.connect(merge.left);
|
|
|
|
* sigRight.connect(merge.right);
|
2014-06-17 15:40:01 +00:00
|
|
|
*/
|
2014-04-05 22:05:42 +00:00
|
|
|
Tone.Merge = function(){
|
2014-06-17 15:40:01 +00:00
|
|
|
|
2015-02-02 17:49:13 +00:00
|
|
|
Tone.call(this, 2, 1);
|
2014-04-05 22:05:42 +00:00
|
|
|
|
2014-06-17 15:40:01 +00:00
|
|
|
/**
|
2015-02-27 21:53:10 +00:00
|
|
|
* The left input channel.
|
|
|
|
* Alias for input 0
|
2014-06-17 15:40:01 +00:00
|
|
|
* @type {GainNode}
|
|
|
|
*/
|
2014-08-20 21:09:58 +00:00
|
|
|
this.left = this.input[0] = this.context.createGain();
|
|
|
|
|
2014-06-17 15:40:01 +00:00
|
|
|
/**
|
2015-02-27 21:53:10 +00:00
|
|
|
* The right input channel.
|
|
|
|
* Alias for input 1.
|
2014-06-17 15:40:01 +00:00
|
|
|
* @type {GainNode}
|
|
|
|
*/
|
2014-08-20 21:09:58 +00:00
|
|
|
this.right = this.input[1] = this.context.createGain();
|
|
|
|
|
2014-06-17 15:40:01 +00:00
|
|
|
/**
|
|
|
|
* the merger node for the two channels
|
|
|
|
* @type {ChannelMergerNode}
|
2014-08-24 21:48:28 +00:00
|
|
|
* @private
|
2014-06-17 15:40:01 +00:00
|
|
|
*/
|
2014-08-24 21:48:28 +00:00
|
|
|
this._merger = this.context.createChannelMerger(2);
|
2014-04-05 22:05:42 +00:00
|
|
|
|
|
|
|
//connections
|
2014-08-24 21:48:28 +00:00
|
|
|
this.left.connect(this._merger, 0, 0);
|
|
|
|
this.right.connect(this._merger, 0, 1);
|
|
|
|
this._merger.connect(this.output);
|
2014-06-17 15:40:01 +00:00
|
|
|
};
|
2014-04-05 22:05:42 +00:00
|
|
|
|
|
|
|
Tone.extend(Tone.Merge);
|
|
|
|
|
2014-06-20 04:38:14 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
2015-02-02 17:49:13 +00:00
|
|
|
* @returns {Tone.Merge} `this`
|
2014-06-20 04:38:14 +00:00
|
|
|
*/
|
|
|
|
Tone.Merge.prototype.dispose = function(){
|
2014-08-24 19:46:55 +00:00
|
|
|
Tone.prototype.dispose.call(this);
|
2014-08-20 21:09:58 +00:00
|
|
|
this.left.disconnect();
|
2014-06-20 04:38:14 +00:00
|
|
|
this.right.disconnect();
|
2014-08-24 21:48:28 +00:00
|
|
|
this._merger.disconnect();
|
2014-08-20 21:09:58 +00:00
|
|
|
this.left = null;
|
2014-06-20 04:38:14 +00:00
|
|
|
this.right = null;
|
2014-08-24 21:48:28 +00:00
|
|
|
this._merger = null;
|
2015-02-02 17:49:13 +00:00
|
|
|
return this;
|
2014-06-20 04:38:14 +00:00
|
|
|
};
|
|
|
|
|
2014-04-05 22:05:42 +00:00
|
|
|
return Tone.Merge;
|
2014-06-17 15:40:01 +00:00
|
|
|
});
|