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: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-08-24 21:48:28 +00:00
|
|
|
* @private
|
2014-06-22 16:33:21 +00:00
|
|
|
*/
|
2014-08-24 21:48:28 +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
|
2014-08-24 21:48:28 +00:00
|
|
|
this.input.connect(this._splitter);
|
|
|
|
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(){
|
2014-08-24 19:51:24 +00:00
|
|
|
Tone.prototype.dispose.call(this);
|
2014-08-24 21:48:28 +00:00
|
|
|
this._splitter.disconnect();
|
2014-08-20 21:09:58 +00:00
|
|
|
this.left.disconnect();
|
|
|
|
this.right.disconnect();
|
|
|
|
this.left = null;
|
|
|
|
this.right = null;
|
2014-08-24 21:48:28 +00:00
|
|
|
this._splitter = null;
|
2014-06-20 04:38:14 +00:00
|
|
|
};
|
|
|
|
|
2014-04-05 22:05:42 +00:00
|
|
|
return Tone.Split;
|
|
|
|
});
|