2014-04-06 20:51:30 +00:00
|
|
|
define(["Tone/core/Tone"], function(Tone){
|
2014-04-05 22:05:42 +00:00
|
|
|
|
2014-06-17 15:48:17 +00:00
|
|
|
/**
|
2014-07-04 17:47:56 +00:00
|
|
|
* @class Split the incoming signal into left and right channels
|
|
|
|
*
|
2014-06-17 15:48:17 +00:00
|
|
|
* @constructor
|
|
|
|
* @extends {Tone}
|
|
|
|
*/
|
2014-04-05 22:05:42 +00:00
|
|
|
Tone.Split = function(){
|
2014-08-20 21:09:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the input node
|
|
|
|
* @type {GainNode}
|
|
|
|
*/
|
|
|
|
this.input = this.context.createGain();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the output nodes
|
|
|
|
* @type {Array.<GainNode>}
|
|
|
|
*/
|
|
|
|
this.output = new Array(2);
|
2014-04-05 22:05:42 +00:00
|
|
|
|
2014-06-22 16:33:21 +00:00
|
|
|
/**
|
|
|
|
* @type {ChannelSplitterNode}
|
|
|
|
*/
|
2014-04-05 22:05:42 +00:00
|
|
|
this.splitter = this.context.createChannelSplitter(2);
|
2014-08-20 21:09:58 +00:00
|
|
|
|
2014-06-17 15:48:17 +00:00
|
|
|
/**
|
|
|
|
* left channel output
|
2014-08-20 21:09:58 +00:00
|
|
|
* alais for the first output
|
2014-06-17 15:48:17 +00:00
|
|
|
* @type {GainNode}
|
|
|
|
*/
|
2014-08-20 21:09:58 +00:00
|
|
|
this.left = this.output[0] = this.context.createGain();
|
|
|
|
|
2014-06-17 15:48:17 +00:00
|
|
|
/**
|
|
|
|
* the right channel output
|
2014-08-20 21:09:58 +00:00
|
|
|
* alais for the second output
|
2014-06-17 15:48:17 +00:00
|
|
|
* @type {GainNode}
|
|
|
|
*/
|
2014-08-20 21:09:58 +00:00
|
|
|
this.right = this.output[1] = this.context.createGain();
|
2014-04-05 22:05:42 +00:00
|
|
|
|
|
|
|
//connections
|
|
|
|
this.input.connect(this.splitter);
|
2014-06-18 19:39:10 +00:00
|
|
|
this.splitter.connect(this.left, 0, 0);
|
|
|
|
this.splitter.connect(this.right, 1, 0);
|
2014-06-17 15:48:17 +00:00
|
|
|
};
|
2014-04-05 22:05:42 +00:00
|
|
|
|
|
|
|
Tone.extend(Tone.Split);
|
|
|
|
|
2014-06-20 04:38:14 +00:00
|
|
|
/**
|
|
|
|
* dispose method
|
|
|
|
*/
|
2014-06-21 17:09:46 +00:00
|
|
|
Tone.Split.prototype.dispose = function(){
|
|
|
|
this.splitter.disconnect();
|
2014-06-20 04:38:14 +00:00
|
|
|
this.input.disconnect();
|
2014-08-20 21:09:58 +00:00
|
|
|
this.left.disconnect();
|
|
|
|
this.right.disconnect();
|
|
|
|
this.left = null;
|
|
|
|
this.right = null;
|
2014-06-21 17:09:46 +00:00
|
|
|
this.splitter = null;
|
2014-06-20 04:38:14 +00:00
|
|
|
this.input = null;
|
|
|
|
this.output = null;
|
|
|
|
};
|
|
|
|
|
2014-04-05 22:05:42 +00:00
|
|
|
return Tone.Split;
|
|
|
|
});
|