2019-01-27 18:05:20 +00:00
|
|
|
import Tone from "../core/Tone";
|
|
|
|
import "../effect/StereoEffect";
|
|
|
|
import "../effect/FeedbackEffect";
|
|
|
|
import "../core/Gain";
|
2014-09-01 16:52:13 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* @class Base class for stereo feedback effects where the effectReturn
|
|
|
|
* is fed back into the same channel.
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone.StereoEffect}
|
|
|
|
*/
|
|
|
|
Tone.StereoFeedbackEffect = function(){
|
|
|
|
|
|
|
|
var options = Tone.defaults(arguments, ["feedback"], Tone.FeedbackEffect);
|
|
|
|
Tone.StereoEffect.call(this, options);
|
2014-09-01 16:52:13 +00:00
|
|
|
|
|
|
|
/**
|
2019-01-27 18:05:20 +00:00
|
|
|
* controls the amount of feedback
|
|
|
|
* @type {NormalRange}
|
|
|
|
* @signal
|
2014-09-01 16:52:13 +00:00
|
|
|
*/
|
2019-01-27 18:05:20 +00:00
|
|
|
this.feedback = new Tone.Signal(options.feedback, Tone.Type.NormalRange);
|
2014-09-01 16:52:13 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* the left side feeback
|
|
|
|
* @type {Tone.Gain}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._feedbackL = new Tone.Gain();
|
2014-09-01 16:52:13 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* the right side feeback
|
|
|
|
* @type {Tone.Gain}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._feedbackR = new Tone.Gain();
|
2014-09-01 16:52:13 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
//connect it up
|
|
|
|
this.effectReturnL.chain(this._feedbackL, this.effectSendL);
|
|
|
|
this.effectReturnR.chain(this._feedbackR, this.effectSendR);
|
|
|
|
this.feedback.fan(this._feedbackL.gain, this._feedbackR.gain);
|
|
|
|
this._readOnly(["feedback"]);
|
|
|
|
};
|
2014-09-01 16:52:13 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Tone.extend(Tone.StereoFeedbackEffect, Tone.StereoEffect);
|
2014-09-01 16:52:13 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
|
|
|
* @returns {Tone.StereoFeedbackEffect} this
|
|
|
|
*/
|
|
|
|
Tone.StereoFeedbackEffect.prototype.dispose = function(){
|
|
|
|
Tone.StereoEffect.prototype.dispose.call(this);
|
|
|
|
this._writable(["feedback"]);
|
|
|
|
this.feedback.dispose();
|
|
|
|
this.feedback = null;
|
|
|
|
this._feedbackL.dispose();
|
|
|
|
this._feedbackL = null;
|
|
|
|
this._feedbackR.dispose();
|
|
|
|
this._feedbackR = null;
|
|
|
|
return this;
|
|
|
|
};
|
2014-09-01 16:52:13 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
export default Tone.StereoFeedbackEffect;
|
2014-09-01 16:52:13 +00:00
|
|
|
|