1 | import { StereoXFeedbackEffect, } from "./StereoXFeedbackEffect.js";
|
2 | import { optionsFromArguments } from "../core/util/Defaults.js";
|
3 | import { Delay } from "../core/context/Delay.js";
|
4 | import { Signal } from "../signal/Signal.js";
|
5 | import { readOnly } from "../core/util/Interface.js";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export class PingPongDelay extends StereoXFeedbackEffect {
|
21 | constructor() {
|
22 | const options = optionsFromArguments(PingPongDelay.getDefaults(), arguments, ["delayTime", "feedback"]);
|
23 | super(options);
|
24 | this.name = "PingPongDelay";
|
25 | this._leftDelay = new Delay({
|
26 | context: this.context,
|
27 | maxDelay: options.maxDelay,
|
28 | });
|
29 | this._rightDelay = new Delay({
|
30 | context: this.context,
|
31 | maxDelay: options.maxDelay,
|
32 | });
|
33 | this._rightPreDelay = new Delay({
|
34 | context: this.context,
|
35 | maxDelay: options.maxDelay,
|
36 | });
|
37 | this.delayTime = new Signal({
|
38 | context: this.context,
|
39 | units: "time",
|
40 | value: options.delayTime,
|
41 | });
|
42 |
|
43 | this.connectEffectLeft(this._leftDelay);
|
44 | this.connectEffectRight(this._rightPreDelay, this._rightDelay);
|
45 | this.delayTime.fan(this._leftDelay.delayTime, this._rightDelay.delayTime, this._rightPreDelay.delayTime);
|
46 |
|
47 | this._feedbackL.disconnect();
|
48 | this._feedbackL.connect(this._rightDelay);
|
49 | readOnly(this, ["delayTime"]);
|
50 | }
|
51 | static getDefaults() {
|
52 | return Object.assign(StereoXFeedbackEffect.getDefaults(), {
|
53 | delayTime: 0.25,
|
54 | maxDelay: 1,
|
55 | });
|
56 | }
|
57 | dispose() {
|
58 | super.dispose();
|
59 | this._leftDelay.dispose();
|
60 | this._rightDelay.dispose();
|
61 | this._rightPreDelay.dispose();
|
62 | this.delayTime.dispose();
|
63 | return this;
|
64 | }
|
65 | }
|
66 |
|
\ | No newline at end of file |