Tone.js/Tone/effect/FeedbackEffect.js

67 lines
1.6 KiB
JavaScript
Raw Normal View History

define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/signal/Signal", "Tone/signal/Multiply"], 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(){
var options = this.optionsObject(arguments, ["feedback"]);
options = this.defaultArg(options, Tone.FeedbackEffect.defaults);
Tone.Effect.call(this, options);
/**
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
*/
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
/**
* 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"]);
};
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.feedback.dispose();
this.feedback = null;
2014-11-30 22:17:50 +00:00
this._feedbackGain.disconnect();
this._feedbackGain = null;
2015-02-02 18:22:16 +00:00
return this;
};
return Tone.FeedbackEffect;
});