2014-08-25 14:23:37 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/signal/Signal", "Tone/signal/Multiply"], 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.FeedbackEffect provides a loop between an
|
2015-06-22 05:20:57 +00:00
|
|
|
* audio source and its own output. This is a base-class
|
|
|
|
* for feedback effects.
|
2014-06-21 21:34:31 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone.Effect}
|
2015-06-22 05:20:57 +00:00
|
|
|
* @param {NormalRange|Object} [feedback] The initial feedback value.
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
2014-08-24 23:28:42 +00:00
|
|
|
Tone.FeedbackEffect = function(){
|
|
|
|
|
|
|
|
var options = this.optionsObject(arguments, ["feedback"]);
|
2014-08-25 14:23:37 +00:00
|
|
|
options = this.defaultArg(options, Tone.FeedbackEffect.defaults);
|
2014-08-24 23:28:42 +00:00
|
|
|
|
|
|
|
Tone.Effect.call(this, options);
|
2014-06-21 21:34:31 +00:00
|
|
|
|
|
|
|
/**
|
2015-06-22 05:20:57 +00:00
|
|
|
* The amount of signal which is fed back into the effect input.
|
2015-06-13 23:50:39 +00:00
|
|
|
* @type {NormalRange}
|
|
|
|
* @signal
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
2015-05-24 13:45:15 +00:00
|
|
|
this.feedback = new Tone.Signal(options.feedback, Tone.Type.NormalRange);
|
2014-08-23 18:24:54 +00:00
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
/**
|
|
|
|
* the gain which controls the feedback
|
|
|
|
* @type {GainNode}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._feedbackGain = this.context.createGain();
|
|
|
|
|
|
|
|
//the feedback loop
|
2014-12-01 02:32:09 +00:00
|
|
|
this.effectReturn.chain(this._feedbackGain, this.effectSend);
|
2014-11-30 22:17:50 +00:00
|
|
|
this.feedback.connect(this._feedbackGain.gain);
|
2015-04-18 14:54:08 +00:00
|
|
|
this._readOnly(["feedback"]);
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.FeedbackEffect, Tone.Effect);
|
|
|
|
|
2014-08-24 23:28:42 +00:00
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
2014-08-25 14:23:37 +00:00
|
|
|
Tone.FeedbackEffect.defaults = {
|
2014-11-30 22:17:50 +00:00
|
|
|
"feedback" : 0.125
|
2014-08-24 23:28:42 +00:00
|
|
|
};
|
|
|
|
|
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.FeedbackEffect} this
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
|
|
|
Tone.FeedbackEffect.prototype.dispose = function(){
|
2014-08-23 19:51:21 +00:00
|
|
|
Tone.Effect.prototype.dispose.call(this);
|
2015-04-18 14:54:08 +00:00
|
|
|
this._writable(["feedback"]);
|
2014-06-21 21:34:31 +00:00
|
|
|
this.feedback.dispose();
|
|
|
|
this.feedback = null;
|
2014-11-30 22:17:50 +00:00
|
|
|
this._feedbackGain.disconnect();
|
2014-06-21 21:34:31 +00:00
|
|
|
this._feedbackGain = null;
|
2015-02-02 18:22:16 +00:00
|
|
|
return this;
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.FeedbackEffect;
|
|
|
|
});
|