UNPKG

1.06 kBJavaScriptView Raw
1import { Gain } from "../core/context/Gain.js";
2import { readOnly } from "../core/util/Interface.js";
3import { Effect } from "./Effect.js";
4/**
5 * FeedbackEffect provides a loop between an audio source and its own output.
6 * This is a base-class for feedback effects.
7 */
8export class FeedbackEffect extends Effect {
9 constructor(options) {
10 super(options);
11 this.name = "FeedbackEffect";
12 this._feedbackGain = new Gain({
13 context: this.context,
14 gain: options.feedback,
15 units: "normalRange",
16 });
17 this.feedback = this._feedbackGain.gain;
18 readOnly(this, "feedback");
19 // the feedback loop
20 this.effectReturn.chain(this._feedbackGain, this.effectSend);
21 }
22 static getDefaults() {
23 return Object.assign(Effect.getDefaults(), {
24 feedback: 0.125,
25 });
26 }
27 dispose() {
28 super.dispose();
29 this._feedbackGain.dispose();
30 this.feedback.dispose();
31 return this;
32 }
33}
34//# sourceMappingURL=FeedbackEffect.js.map
\No newline at end of file