Tone.js/Tone/component/Split.js

64 lines
1.3 KiB
JavaScript
Raw Normal View History

define(["Tone/core/Tone", "Tone/core/Gain"], function(Tone){
"use strict";
2014-06-17 15:48:17 +00:00
/**
2015-07-02 00:19:58 +00:00
* @class Tone.Split splits an incoming signal into left and right channels.
2014-07-04 17:47:56 +00:00
*
2014-06-17 15:48:17 +00:00
* @constructor
* @extends {Tone}
2015-02-27 21:53:10 +00:00
* @example
2015-06-14 05:09:06 +00:00
* var split = new Tone.Split();
* stereoSignal.connect(split);
2014-06-17 15:48:17 +00:00
*/
Tone.Split = function(){
Tone.call(this);
2016-09-20 03:02:42 +00:00
this.createInsOuts(0, 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
*/
2015-03-24 20:29:11 +00:00
this._splitter = this.input = this.context.createChannelSplitter(2);
this._splitter.channelCount = 2;
this._splitter.channelCountMode = "explicit";
2014-06-17 15:48:17 +00:00
/**
2015-06-20 23:25:49 +00:00
* Left channel output.
* Alias for <code>output[0]</code>
* @type {Tone.Gain}
2014-06-17 15:48:17 +00:00
*/
this.left = this.output[0] = new Tone.Gain();
2014-06-17 15:48:17 +00:00
/**
2015-06-20 23:25:49 +00:00
* Right channel output.
* Alias for <code>output[1]</code>
* @type {Tone.Gain}
2014-06-17 15:48:17 +00:00
*/
this.right = this.output[1] = new Tone.Gain();
//connections
2014-08-24 21:48:28 +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
/**
2015-06-20 23:25:49 +00:00
* Clean up.
* @returns {Tone.Split} this
2014-06-20 04:38:14 +00:00
*/
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.dispose();
this.left = null;
this.right.dispose();
this.right = null;
2014-08-24 21:48:28 +00:00
this._splitter = null;
2015-02-02 17:49:13 +00:00
return this;
2014-06-20 04:38:14 +00:00
};
return Tone.Split;
});