2015-02-02 17:48:04 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/component/CrossFade"], function(Tone){
|
2014-09-04 04:41:40 +00:00
|
|
|
|
|
|
|
"use strict";
|
2014-06-21 21:34:31 +00:00
|
|
|
|
|
|
|
/**
|
2015-07-04 16:40:33 +00:00
|
|
|
* @class Tone.Effect is the base class for effects. Connect the effect between
|
|
|
|
* the effectSend and effectReturn GainNodes, then control the amount of
|
2015-06-22 05:20:57 +00:00
|
|
|
* effect which goes to the output using the wet control.
|
2014-06-21 21:34:31 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone}
|
2015-06-22 05:20:57 +00:00
|
|
|
* @param {NormalRange|Object} [wet] The starting wet value.
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
2014-08-24 23:28:42 +00:00
|
|
|
Tone.Effect = function(){
|
|
|
|
|
2017-04-26 04:07:10 +00:00
|
|
|
var options = Tone.defaults(arguments, ["wet"], Tone.Effect);
|
2017-04-26 03:18:08 +00:00
|
|
|
Tone.call(this);
|
2016-09-20 03:02:42 +00:00
|
|
|
this.createInsOuts(1, 1);
|
2014-06-21 21:34:31 +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
|
2015-02-02 17:48:04 +00:00
|
|
|
*/
|
2015-02-25 05:57:00 +00:00
|
|
|
this._dryWet = new Tone.CrossFade(options.wet);
|
2015-02-02 17:48:04 +00:00
|
|
|
|
|
|
|
/**
|
2015-06-22 05:20:57 +00:00
|
|
|
* The wet control is how much of the effected
|
|
|
|
* will pass through to the output. 1 = 100% effected
|
|
|
|
* signal, 0 = 100% dry signal.
|
2015-06-13 23:50:39 +00:00
|
|
|
* @type {NormalRange}
|
|
|
|
* @signal
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
2015-02-25 05:57:00 +00:00
|
|
|
this.wet = this._dryWet.fade;
|
2014-08-21 00:46:57 +00:00
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
/**
|
|
|
|
* connect the effectSend to the input of hte effect
|
2016-09-20 03:53:07 +00:00
|
|
|
* @type {Tone.Gain}
|
2015-02-27 21:53:10 +00:00
|
|
|
* @private
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
2016-09-20 03:53:07 +00:00
|
|
|
this.effectSend = new Tone.Gain();
|
2014-08-21 00:46:57 +00:00
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
/**
|
|
|
|
* connect the output of the effect to the effectReturn
|
2016-09-20 03:53:07 +00:00
|
|
|
* @type {Tone.Gain}
|
2015-02-27 21:53:10 +00:00
|
|
|
* @private
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
2016-09-20 03:53:07 +00:00
|
|
|
this.effectReturn = new Tone.Gain();
|
2014-06-21 21:34:31 +00:00
|
|
|
|
|
|
|
//connections
|
2015-02-25 05:57:00 +00:00
|
|
|
this.input.connect(this._dryWet.a);
|
2014-06-21 21:34:31 +00:00
|
|
|
this.input.connect(this.effectSend);
|
2015-02-25 05:57:00 +00:00
|
|
|
this.effectReturn.connect(this._dryWet.b);
|
|
|
|
this._dryWet.connect(this.output);
|
2015-04-18 14:54:08 +00:00
|
|
|
this._readOnly(["wet"]);
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.Effect);
|
|
|
|
|
2014-08-24 23:28:42 +00:00
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
2014-08-25 14:23:37 +00:00
|
|
|
Tone.Effect.defaults = {
|
2015-02-02 17:48:04 +00:00
|
|
|
"wet" : 1
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* chains the effect in between the effectSend and effectReturn
|
|
|
|
* @param {Tone} effect
|
2015-02-25 21:19:43 +00:00
|
|
|
* @private
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.Effect} this
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
|
|
|
Tone.Effect.prototype.connectEffect = function(effect){
|
2014-12-01 02:32:09 +00:00
|
|
|
this.effectSend.chain(effect, this.effectReturn);
|
2015-02-02 17:48:04 +00:00
|
|
|
return this;
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2015-06-22 05:20:57 +00:00
|
|
|
* Clean up.
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.Effect} this
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
|
|
|
Tone.Effect.prototype.dispose = function(){
|
2014-08-23 19:51:21 +00:00
|
|
|
Tone.prototype.dispose.call(this);
|
2015-02-25 05:57:00 +00:00
|
|
|
this._dryWet.dispose();
|
|
|
|
this._dryWet = null;
|
2016-09-20 03:53:07 +00:00
|
|
|
this.effectSend.dispose();
|
2014-06-21 21:34:31 +00:00
|
|
|
this.effectSend = null;
|
2016-09-20 03:53:07 +00:00
|
|
|
this.effectReturn.dispose();
|
2014-06-21 21:34:31 +00:00
|
|
|
this.effectReturn = null;
|
2015-04-18 14:54:08 +00:00
|
|
|
this._writable(["wet"]);
|
2015-02-02 17:48:04 +00:00
|
|
|
this.wet = null;
|
|
|
|
return this;
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.Effect;
|
|
|
|
});
|