Tone.js/Tone/component/Split.js

67 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-04-06 20:51:30 +00:00
define(["Tone/core/Tone"], function(Tone){
"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}
*/
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}
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-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
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
};
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(){
Tone.prototype.dispose.call(this);
2014-08-24 21:48:28 +00:00
this._splitter.disconnect();
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
};
return Tone.Split;
});