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