1 | import { Param } from "../context/Param.js";
|
2 | import { optionsFromArguments } from "../util/Defaults.js";
|
3 | import { readOnly } from "../util/Interface.js";
|
4 | import { ToneAudioNode } from "./ToneAudioNode.js";
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export class Gain extends ToneAudioNode {
|
19 | constructor() {
|
20 | const options = optionsFromArguments(Gain.getDefaults(), arguments, [
|
21 | "gain",
|
22 | "units",
|
23 | ]);
|
24 | super(options);
|
25 | this.name = "Gain";
|
26 | |
27 |
|
28 |
|
29 | this._gainNode = this.context.createGain();
|
30 |
|
31 | this.input = this._gainNode;
|
32 | this.output = this._gainNode;
|
33 | this.gain = new Param({
|
34 | context: this.context,
|
35 | convert: options.convert,
|
36 | param: this._gainNode.gain,
|
37 | units: options.units,
|
38 | value: options.gain,
|
39 | minValue: options.minValue,
|
40 | maxValue: options.maxValue,
|
41 | });
|
42 | readOnly(this, "gain");
|
43 | }
|
44 | static getDefaults() {
|
45 | return Object.assign(ToneAudioNode.getDefaults(), {
|
46 | convert: true,
|
47 | gain: 1,
|
48 | units: "gain",
|
49 | });
|
50 | }
|
51 | |
52 |
|
53 |
|
54 | dispose() {
|
55 | super.dispose();
|
56 | this._gainNode.disconnect();
|
57 | this.gain.dispose();
|
58 | return this;
|
59 | }
|
60 | }
|
61 |
|
\ | No newline at end of file |