1 | import { Effect } from "../effect/Effect.js";
|
2 | import { LFO } from "../source/oscillator/LFO.js";
|
3 | import { readOnly } from "../core/util/Interface.js";
|
4 |
|
5 |
|
6 |
|
7 | export class LFOEffect extends Effect {
|
8 | constructor(options) {
|
9 | super(options);
|
10 | this.name = "LFOEffect";
|
11 | this._lfo = new LFO({
|
12 | context: this.context,
|
13 | frequency: options.frequency,
|
14 | amplitude: options.depth,
|
15 | });
|
16 | this.depth = this._lfo.amplitude;
|
17 | this.frequency = this._lfo.frequency;
|
18 | this.type = options.type;
|
19 | readOnly(this, ["frequency", "depth"]);
|
20 | }
|
21 | static getDefaults() {
|
22 | return Object.assign(Effect.getDefaults(), {
|
23 | frequency: 1,
|
24 | type: "sine",
|
25 | depth: 1,
|
26 | });
|
27 | }
|
28 | |
29 |
|
30 |
|
31 | start(time) {
|
32 | this._lfo.start(time);
|
33 | return this;
|
34 | }
|
35 | |
36 |
|
37 |
|
38 | stop(time) {
|
39 | this._lfo.stop(time);
|
40 | return this;
|
41 | }
|
42 | |
43 |
|
44 |
|
45 |
|
46 | sync() {
|
47 | this._lfo.sync();
|
48 | return this;
|
49 | }
|
50 | |
51 |
|
52 |
|
53 | unsync() {
|
54 | this._lfo.unsync();
|
55 | return this;
|
56 | }
|
57 | |
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | get type() {
|
66 | return this._lfo.type;
|
67 | }
|
68 | set type(type) {
|
69 | this._lfo.type = type;
|
70 | }
|
71 | dispose() {
|
72 | super.dispose();
|
73 | this._lfo.dispose();
|
74 | this.frequency.dispose();
|
75 | this.depth.dispose();
|
76 | return this;
|
77 | }
|
78 | }
|
79 |
|
\ | No newline at end of file |