Tone.js/Tone/signal/Split.js

66 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-04-06 20:51:30 +00:00
define(["Tone/core/Tone"], function(Tone){
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}
*/
Tone.Split = function(){
/**
* the input node
* @type {GainNode}
*/
this.input = this.context.createGain();
/**
* the output nodes
* @type {Array.<GainNode>}
*/
this.output = new Array(2);
2014-06-22 16:33:21 +00:00
/**
* @type {ChannelSplitterNode}
*/
this.splitter = this.context.createChannelSplitter(2);
2014-06-17 15:48:17 +00:00
/**
* left channel output
* alais for the first output
2014-06-17 15:48:17 +00:00
* @type {GainNode}
*/
this.left = this.output[0] = this.context.createGain();
2014-06-17 15:48:17 +00:00
/**
* the right channel output
* alais for the second output
2014-06-17 15:48:17 +00:00
* @type {GainNode}
*/
this.right = this.output[1] = this.context.createGain();
//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
};
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();
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;
};
return Tone.Split;
});