UNPKG

2.11 kBJavaScriptView Raw
1import { ToneAudioNode, } from "../../core/context/ToneAudioNode.js";
2import { Compressor } from "./Compressor.js";
3import { optionsFromArguments } from "../../core/util/Defaults.js";
4import { MidSideSplit } from "../channel/MidSideSplit.js";
5import { MidSideMerge } from "../channel/MidSideMerge.js";
6import { readOnly } from "../../core/util/Interface.js";
7/**
8 * MidSideCompressor applies two different compressors to the {@link mid}
9 * and {@link side} signal components of the input.
10 * @see {@link MidSideSplit} and {@link MidSideMerge}.
11 * @category Component
12 */
13export 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//# sourceMappingURL=MidSideCompressor.js.map
\No newline at end of file