Tone.js/Tone/effect/StereoEffect.js

101 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-02-02 17:48:04 +00:00
define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/component/Split",
"Tone/component/Merge", "Tone/component/CrossFade"],
function(Tone){
"use strict";
/**
* @class Creates an effect with an effectSendL/R and effectReturnL/R
*
* @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);
/**
* the drywet knob to control the amount of effect
2015-02-02 17:48:04 +00:00
* @type {Tone.CrossFade}
*/
2015-02-10 16:40:27 +00:00
this.dryWet = new Tone.CrossFade(options.wet);
/**
* The wet control, i.e. how much of the effected
* will pass through to the output.
* @type {Tone.Signal}
*/
this.wet = this.dryWet.fade;
/**
* then split it
* @type {Tone.Split}
* @private
*/
this._split = new Tone.Split();
/**
* the effects send LEFT
* @type {GainNode}
*/
this.effectSendL = this._split.left;
/**
* the effects send RIGHT
* @type {GainNode}
*/
this.effectSendR = this._split.right;
/**
* the stereo effect merger
* @type {Tone.Merge}
* @private
*/
this._merge = new Tone.Merge();
/**
* the effect return LEFT
* @type {GainNode}
*/
this.effectReturnL = this._merge.left;
/**
* the effect return RIGHT
* @type {GainNode}
*/
this.effectReturnR = this._merge.right;
//connections
this.input.connect(this._split);
//dry wet connections
2015-02-02 17:48:04 +00:00
this.input.connect(this.dryWet, 0, 0);
this._merge.connect(this.dryWet, 0, 1);
this.dryWet.connect(this.output);
};
Tone.extend(Tone.StereoEffect, Tone.Effect);
/**
* clean up
2015-02-02 18:22:16 +00:00
* @returns {Tone.StereoEffect} `this`
*/
Tone.StereoEffect.prototype.dispose = function(){
Tone.prototype.dispose.call(this);
this.dryWet.dispose();
this.dryWet = null;
this._split.dispose();
this._split = null;
this._merge.dispose();
this._merge = null;
this.effectSendL = null;
this.effectSendR = null;
this.effectReturnL = null;
this.effectReturnR = null;
2015-02-10 16:40:27 +00:00
this.wet = null;
2015-02-02 18:22:16 +00:00
return this;
};
return Tone.StereoEffect;
});