2015-04-20 19:41:42 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/component/MidSideSplit", "Tone/component/MidSideMerge"],
|
|
|
|
function(Tone){
|
2014-11-01 22:17:03 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
2015-04-18 14:54:08 +00:00
|
|
|
* @class Mid/Side processing separates the the 'mid' signal
|
|
|
|
* (which comes out of both the left and the right channel)
|
|
|
|
* and the 'side' (which only comes out of the the side channels)
|
2015-06-22 05:20:57 +00:00
|
|
|
* and effects them separately before being recombined.
|
|
|
|
* Applies a Mid/Side seperation and recombination.
|
2015-07-04 19:25:37 +00:00
|
|
|
* Algorithm found in [kvraudio forums](http://www.kvraudio.com/forum/viewtopic.php?t=212587).
|
2015-06-22 05:20:57 +00:00
|
|
|
* <br><br>
|
|
|
|
* This is a base-class for Mid/Side Effects.
|
2014-11-01 22:17:03 +00:00
|
|
|
*
|
2015-04-20 19:41:42 +00:00
|
|
|
* @extends {Tone.Effect}
|
2014-11-01 22:17:03 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
2014-12-04 03:11:23 +00:00
|
|
|
Tone.MidSideEffect = function(){
|
2015-08-26 13:59:37 +00:00
|
|
|
|
|
|
|
Tone.Effect.apply(this, arguments);
|
2014-11-01 22:17:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-20 19:41:42 +00:00
|
|
|
* The mid/side split
|
|
|
|
* @type {Tone.MidSideSplit}
|
2014-11-01 22:17:03 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2015-04-20 19:41:42 +00:00
|
|
|
this._midSideSplit = new Tone.MidSideSplit();
|
2014-11-01 22:17:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-20 19:41:42 +00:00
|
|
|
* The mid/side merge
|
|
|
|
* @type {Tone.MidSideMerge}
|
|
|
|
* @private
|
2014-11-01 22:17:03 +00:00
|
|
|
*/
|
2015-04-20 19:41:42 +00:00
|
|
|
this._midSideMerge = new Tone.MidSideMerge();
|
2014-11-01 22:17:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-20 19:41:42 +00:00
|
|
|
* The mid send. Connect to mid processing
|
2014-11-01 22:17:03 +00:00
|
|
|
* @type {Tone.Expr}
|
2015-06-22 05:20:57 +00:00
|
|
|
* @private
|
2014-11-01 22:17:03 +00:00
|
|
|
*/
|
2015-04-20 19:41:42 +00:00
|
|
|
this.midSend = this._midSideSplit.mid;
|
2014-11-01 22:17:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-20 19:41:42 +00:00
|
|
|
* The side send. Connect to side processing
|
2014-11-01 22:17:03 +00:00
|
|
|
* @type {Tone.Expr}
|
2015-06-22 05:20:57 +00:00
|
|
|
* @private
|
2014-11-01 22:17:03 +00:00
|
|
|
*/
|
2015-04-20 19:41:42 +00:00
|
|
|
this.sideSend = this._midSideSplit.side;
|
2014-11-01 22:17:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-20 19:41:42 +00:00
|
|
|
* The mid return connection
|
2014-11-01 22:17:03 +00:00
|
|
|
* @type {GainNode}
|
2015-06-22 05:20:57 +00:00
|
|
|
* @private
|
2014-11-01 22:17:03 +00:00
|
|
|
*/
|
2015-04-20 19:41:42 +00:00
|
|
|
this.midReturn = this._midSideMerge.mid;
|
2014-11-01 22:17:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-20 19:41:42 +00:00
|
|
|
* The side return connection
|
2014-11-01 22:17:03 +00:00
|
|
|
* @type {GainNode}
|
2015-06-22 05:20:57 +00:00
|
|
|
* @private
|
2014-11-01 22:17:03 +00:00
|
|
|
*/
|
2015-04-20 19:41:42 +00:00
|
|
|
this.sideReturn = this._midSideMerge.side;
|
2014-11-01 22:17:03 +00:00
|
|
|
|
2015-04-20 19:41:42 +00:00
|
|
|
//the connections
|
|
|
|
this.effectSend.connect(this._midSideSplit);
|
|
|
|
this._midSideMerge.connect(this.effectReturn);
|
2014-11-01 22:17:03 +00:00
|
|
|
};
|
|
|
|
|
2015-04-20 19:41:42 +00:00
|
|
|
Tone.extend(Tone.MidSideEffect, Tone.Effect);
|
2014-11-01 22:17:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-06-22 05:20:57 +00:00
|
|
|
* Clean up.
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.MidSideEffect} this
|
2014-11-01 22:17:03 +00:00
|
|
|
*/
|
2014-12-04 03:11:23 +00:00
|
|
|
Tone.MidSideEffect.prototype.dispose = function(){
|
2015-04-20 19:41:42 +00:00
|
|
|
Tone.Effect.prototype.dispose.call(this);
|
|
|
|
this._midSideSplit.dispose();
|
|
|
|
this._midSideSplit = null;
|
|
|
|
this._midSideMerge.dispose();
|
|
|
|
this._midSideMerge = null;
|
2014-11-01 22:17:03 +00:00
|
|
|
this.midSend = null;
|
|
|
|
this.sideSend = null;
|
|
|
|
this.midReturn = null;
|
|
|
|
this.sideReturn = null;
|
2015-02-02 18:22:16 +00:00
|
|
|
return this;
|
2014-11-01 22:17:03 +00:00
|
|
|
};
|
|
|
|
|
2014-12-04 03:11:23 +00:00
|
|
|
return Tone.MidSideEffect;
|
2014-11-01 22:17:03 +00:00
|
|
|
});
|