1 | import { Effect, EffectOptions } from "./Effect.js";
|
2 | import { MidSideSplit } from "../component/channel/MidSideSplit.js";
|
3 | import { MidSideMerge } from "../component/channel/MidSideMerge.js";
|
4 | import { OutputNode, ToneAudioNode } from "../core/context/ToneAudioNode.js";
|
5 |
|
6 | export type MidSideEffectOptions = EffectOptions;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export abstract class MidSideEffect<
|
19 | Options extends MidSideEffectOptions,
|
20 | > extends Effect<Options> {
|
21 | readonly name: string = "MidSideEffect";
|
22 |
|
23 | |
24 |
|
25 |
|
26 | private _midSideSplit: MidSideSplit;
|
27 |
|
28 | |
29 |
|
30 |
|
31 | private _midSideMerge: MidSideMerge;
|
32 |
|
33 | |
34 |
|
35 |
|
36 | protected _midSend: ToneAudioNode;
|
37 |
|
38 | |
39 |
|
40 |
|
41 | protected _sideSend: ToneAudioNode;
|
42 |
|
43 | |
44 |
|
45 |
|
46 | protected _midReturn: ToneAudioNode;
|
47 |
|
48 | |
49 |
|
50 |
|
51 | protected _sideReturn: ToneAudioNode;
|
52 |
|
53 | constructor(options: MidSideEffectOptions) {
|
54 | super(options);
|
55 |
|
56 | this._midSideMerge = new MidSideMerge({ context: this.context });
|
57 | this._midSideSplit = new MidSideSplit({ context: this.context });
|
58 | this._midSend = this._midSideSplit.mid;
|
59 | this._sideSend = this._midSideSplit.side;
|
60 | this._midReturn = this._midSideMerge.mid;
|
61 | this._sideReturn = this._midSideMerge.side;
|
62 |
|
63 |
|
64 | this.effectSend.connect(this._midSideSplit);
|
65 | this._midSideMerge.connect(this.effectReturn);
|
66 | }
|
67 |
|
68 | |
69 |
|
70 |
|
71 | protected connectEffectMid(...nodes: OutputNode[]): void {
|
72 | this._midSend.chain(...nodes, this._midReturn);
|
73 | }
|
74 |
|
75 | |
76 |
|
77 |
|
78 | protected connectEffectSide(...nodes: OutputNode[]): void {
|
79 | this._sideSend.chain(...nodes, this._sideReturn);
|
80 | }
|
81 |
|
82 | dispose(): this {
|
83 | super.dispose();
|
84 | this._midSideSplit.dispose();
|
85 | this._midSideMerge.dispose();
|
86 | this._midSend.dispose();
|
87 | this._sideSend.dispose();
|
88 | this._midReturn.dispose();
|
89 | this._sideReturn.dispose();
|
90 | return this;
|
91 | }
|
92 | }
|