Tone.js/Tone/effect/FeedbackEffect.js

64 lines
1.5 KiB
JavaScript
Raw Normal View History

define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/signal/Signal",
"Tone/signal/Multiply", "Tone/core/Gain"], function(Tone){
"use strict";
/**
* @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.
*
* @constructor
* @extends {Tone.Effect}
2015-06-22 05:20:57 +00:00
* @param {NormalRange|Object} [feedback] The initial feedback value.
*/
Tone.FeedbackEffect = function(){
2017-04-26 03:18:08 +00:00
var options = Tone.defaults(arguments, ["feedback"], Tone.FeedbackEffect);
Tone.Effect.call(this, options);
/**
* the gain which controls the feedback
* @type {Tone.Gain}
* @private
*/
this._feedbackGain = new Tone.Gain(options.feedback, Tone.Type.NormalRange);
/**
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
*/
this.feedback = this._feedbackGain.gain;
//the feedback loop
2014-12-01 02:32:09 +00:00
this.effectReturn.chain(this._feedbackGain, this.effectSend);
2015-04-18 14:54:08 +00:00
this._readOnly(["feedback"]);
};
Tone.extend(Tone.FeedbackEffect, Tone.Effect);
/**
* @static
* @type {Object}
*/
Tone.FeedbackEffect.defaults = {
2014-11-30 22:17:50 +00:00
"feedback" : 0.125
};
/**
2015-06-22 05:20:57 +00:00
* Clean up.
* @returns {Tone.FeedbackEffect} this
*/
Tone.FeedbackEffect.prototype.dispose = function(){
Tone.Effect.prototype.dispose.call(this);
2015-04-18 14:54:08 +00:00
this._writable(["feedback"]);
this._feedbackGain.dispose();
this._feedbackGain = null;
this.feedback = null;
2015-02-02 18:22:16 +00:00
return this;
};
return Tone.FeedbackEffect;
});