2015-02-02 17:48:04 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/component/Split",
|
|
|
|
"Tone/component/Merge", "Tone/component/CrossFade"],
|
2014-09-01 16:52:13 +00:00
|
|
|
function(Tone){
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
2015-06-22 05:20:57 +00:00
|
|
|
* @class Base class for Stereo effects. Provides effectSendL/R and effectReturnL/R.
|
2014-09-01 16:52:13 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone.Effect}
|
|
|
|
*/
|
|
|
|
Tone.StereoEffect = function(){
|
|
|
|
|
|
|
|
Tone.call(this);
|
|
|
|
//get the defaults
|
2015-02-02 17:48:04 +00:00
|
|
|
var options = this.optionsObject(arguments, ["wet"], Tone.Effect.defaults);
|
2014-09-01 16:52:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the drywet knob to control the amount of effect
|
2015-02-02 17:48:04 +00:00
|
|
|
* @type {Tone.CrossFade}
|
2015-02-25 05:57:00 +00:00
|
|
|
* @private
|
2014-09-01 16:52:13 +00:00
|
|
|
*/
|
2015-02-25 05:57:00 +00:00
|
|
|
this._dryWet = new Tone.CrossFade(options.wet);
|
2015-02-10 16:40:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The wet control, i.e. how much of the effected
|
|
|
|
* will pass through to the output.
|
2015-06-13 23:50:39 +00:00
|
|
|
* @type {NormalRange}
|
|
|
|
* @signal
|
2015-02-10 16:40:27 +00:00
|
|
|
*/
|
2015-02-25 05:57:00 +00:00
|
|
|
this.wet = this._dryWet.fade;
|
2014-09-01 16:52:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* then split it
|
|
|
|
* @type {Tone.Split}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._split = new Tone.Split();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the effects send LEFT
|
|
|
|
* @type {GainNode}
|
2015-02-27 21:53:10 +00:00
|
|
|
* @private
|
2014-09-01 16:52:13 +00:00
|
|
|
*/
|
|
|
|
this.effectSendL = this._split.left;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the effects send RIGHT
|
|
|
|
* @type {GainNode}
|
2015-02-27 21:53:10 +00:00
|
|
|
* @private
|
2014-09-01 16:52:13 +00:00
|
|
|
*/
|
|
|
|
this.effectSendR = this._split.right;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the stereo effect merger
|
|
|
|
* @type {Tone.Merge}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._merge = new Tone.Merge();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the effect return LEFT
|
|
|
|
* @type {GainNode}
|
2015-06-14 03:56:32 +00:00
|
|
|
* @private
|
2014-09-01 16:52:13 +00:00
|
|
|
*/
|
|
|
|
this.effectReturnL = this._merge.left;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the effect return RIGHT
|
|
|
|
* @type {GainNode}
|
2015-06-14 03:56:32 +00:00
|
|
|
* @private
|
2014-09-01 16:52:13 +00:00
|
|
|
*/
|
|
|
|
this.effectReturnR = this._merge.right;
|
|
|
|
|
|
|
|
//connections
|
2014-11-03 16:45:33 +00:00
|
|
|
this.input.connect(this._split);
|
2014-09-01 16:52:13 +00:00
|
|
|
//dry wet connections
|
2015-02-25 05:57:00 +00:00
|
|
|
this.input.connect(this._dryWet, 0, 0);
|
|
|
|
this._merge.connect(this._dryWet, 0, 1);
|
|
|
|
this._dryWet.connect(this.output);
|
2015-04-18 14:54:08 +00:00
|
|
|
this._readOnly(["wet"]);
|
2014-09-01 16:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.StereoEffect, Tone.Effect);
|
|
|
|
|
|
|
|
/**
|
2015-06-22 05:20:57 +00:00
|
|
|
* Clean up.
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.StereoEffect} this
|
2014-09-01 16:52:13 +00:00
|
|
|
*/
|
|
|
|
Tone.StereoEffect.prototype.dispose = function(){
|
|
|
|
Tone.prototype.dispose.call(this);
|
2015-02-25 05:57:00 +00:00
|
|
|
this._dryWet.dispose();
|
|
|
|
this._dryWet = null;
|
2014-09-01 16:52:13 +00:00
|
|
|
this._split.dispose();
|
|
|
|
this._split = null;
|
2014-11-03 16:45:33 +00:00
|
|
|
this._merge.dispose();
|
2014-09-01 16:52:13 +00:00
|
|
|
this._merge = null;
|
|
|
|
this.effectSendL = null;
|
|
|
|
this.effectSendR = null;
|
|
|
|
this.effectReturnL = null;
|
|
|
|
this.effectReturnR = null;
|
2015-04-18 14:54:08 +00:00
|
|
|
this._writable(["wet"]);
|
2015-02-10 16:40:27 +00:00
|
|
|
this.wet = null;
|
2015-02-02 18:22:16 +00:00
|
|
|
return this;
|
2014-09-01 16:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.StereoEffect;
|
|
|
|
});
|