1 | import { Panner } from "../component/channel/Panner.js";
|
2 | import { optionsFromArguments } from "../core/util/Defaults.js";
|
3 | import { LFOEffect, LFOEffectOptions } from "./LFOEffect.js";
|
4 | import { Frequency } from "../core/type/Units.js";
|
5 |
|
6 | export interface AutoPannerOptions extends LFOEffectOptions {
|
7 | channelCount: number;
|
8 | }
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | export class AutoPanner extends LFOEffect<AutoPannerOptions> {
|
22 | readonly name: string = "AutoPanner";
|
23 |
|
24 | |
25 |
|
26 |
|
27 | readonly _panner: Panner;
|
28 |
|
29 | |
30 |
|
31 |
|
32 | constructor(frequency?: Frequency);
|
33 | constructor(options?: Partial<AutoPannerOptions>);
|
34 | constructor() {
|
35 | const options = optionsFromArguments(
|
36 | AutoPanner.getDefaults(),
|
37 | arguments,
|
38 | ["frequency"]
|
39 | );
|
40 | super(options);
|
41 |
|
42 | this._panner = new Panner({
|
43 | context: this.context,
|
44 | channelCount: options.channelCount,
|
45 | });
|
46 | // connections
|
47 | this.connectEffect(this._panner);
|
48 | this._lfo.connect(this._panner.pan);
|
49 | this._lfo.min = -1;
|
50 | this._lfo.max = 1;
|
51 | }
|
52 |
|
53 | static getDefaults(): AutoPannerOptions {
|
54 | return Object.assign(LFOEffect.getDefaults(), {
|
55 | channelCount: 1,
|
56 | });
|
57 | }
|
58 |
|
59 | dispose(): this {
|
60 | super.dispose();
|
61 | this._panner.dispose();
|
62 | return this;
|
63 | }
|
64 | }
|