1 | import { ToneAudioNode, } from "../../core/context/ToneAudioNode.js";
|
2 | import { Compressor } from "./Compressor.js";
|
3 | import { optionsFromArguments } from "../../core/util/Defaults.js";
|
4 | import { MidSideSplit } from "../channel/MidSideSplit.js";
|
5 | import { MidSideMerge } from "../channel/MidSideMerge.js";
|
6 | import { readOnly } from "../../core/util/Interface.js";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export class MidSideCompressor extends ToneAudioNode {
|
14 | constructor() {
|
15 | const options = optionsFromArguments(MidSideCompressor.getDefaults(), arguments);
|
16 | super(options);
|
17 | this.name = "MidSideCompressor";
|
18 | this._midSideSplit = this.input = new MidSideSplit({
|
19 | context: this.context,
|
20 | });
|
21 | this._midSideMerge = this.output = new MidSideMerge({
|
22 | context: this.context,
|
23 | });
|
24 | this.mid = new Compressor(Object.assign(options.mid, { context: this.context }));
|
25 | this.side = new Compressor(Object.assign(options.side, { context: this.context }));
|
26 | this._midSideSplit.mid.chain(this.mid, this._midSideMerge.mid);
|
27 | this._midSideSplit.side.chain(this.side, this._midSideMerge.side);
|
28 | readOnly(this, ["mid", "side"]);
|
29 | }
|
30 | static getDefaults() {
|
31 | return Object.assign(ToneAudioNode.getDefaults(), {
|
32 | mid: {
|
33 | ratio: 3,
|
34 | threshold: -24,
|
35 | release: 0.03,
|
36 | attack: 0.02,
|
37 | knee: 16,
|
38 | },
|
39 | side: {
|
40 | ratio: 6,
|
41 | threshold: -30,
|
42 | release: 0.25,
|
43 | attack: 0.03,
|
44 | knee: 10,
|
45 | },
|
46 | });
|
47 | }
|
48 | dispose() {
|
49 | super.dispose();
|
50 | this.mid.dispose();
|
51 | this.side.dispose();
|
52 | this._midSideSplit.dispose();
|
53 | this._midSideMerge.dispose();
|
54 | return this;
|
55 | }
|
56 | }
|
57 |
|
\ | No newline at end of file |