1 | import { Gain } from "../core/context/Gain.js";
|
2 | import { ToneAudioNode, ToneAudioNodeOptions } from "../core/context/ToneAudioNode.js";
|
3 | import { GainFactor, Seconds, Time } from "../core/type/Units.js";
|
4 | import { BasicPlaybackState } from "../core/util/StateTimeline.js";
|
5 | export type OneShotSourceCurve = "linear" | "exponential";
|
6 | type onEndedCallback = (source: OneShotSource<any>) => void;
|
7 | export interface OneShotSourceOptions extends ToneAudioNodeOptions {
|
8 | onended: onEndedCallback;
|
9 | fadeIn: Time;
|
10 | fadeOut: Time;
|
11 | curve: OneShotSourceCurve;
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 | export declare abstract class OneShotSource<Options extends ToneAudioNodeOptions> extends ToneAudioNode<Options> {
|
17 | |
18 |
|
19 |
|
20 |
|
21 | onended: onEndedCallback;
|
22 | |
23 |
|
24 |
|
25 | input: undefined;
|
26 | |
27 |
|
28 |
|
29 | protected _startTime: number;
|
30 | |
31 |
|
32 |
|
33 | protected _stopTime: number;
|
34 | |
35 |
|
36 |
|
37 | private _timeout;
|
38 | |
39 |
|
40 |
|
41 | output: Gain;
|
42 | |
43 |
|
44 |
|
45 | protected _gainNode: Gain<"gain">;
|
46 | |
47 |
|
48 |
|
49 | protected _fadeIn: Time;
|
50 | |
51 |
|
52 |
|
53 | protected _fadeOut: Time;
|
54 | |
55 |
|
56 |
|
57 | protected _curve: OneShotSourceCurve;
|
58 | constructor(options: OneShotSourceOptions);
|
59 | static getDefaults(): OneShotSourceOptions;
|
60 | /**
|
61 | * Stop the source node
|
62 | */
|
63 | protected abstract _stopSource(time: Seconds): void;
|
64 | /**
|
65 | * Start the source node at the given time
|
66 | * @param time When to start the node
|
67 | */
|
68 | protected abstract start(time?: Time): this;
|
69 | /**
|
70 | * Start the source at the given time
|
71 | * @param time When to start the source
|
72 | */
|
73 | protected _startGain(time: Seconds, gain?: GainFactor): this;
|
74 | /**
|
75 | * Stop the source node at the given time.
|
76 | * @param time When to stop the source
|
77 | */
|
78 | stop(time?: Time): this;
|
79 | /**
|
80 | * Stop the source at the given time
|
81 | * @param time When to stop the source
|
82 | */
|
83 | protected _stopGain(time: Seconds): this;
|
84 | /**
|
85 | * Invoke the onended callback
|
86 | */
|
87 | protected _onended(): void;
|
88 | /**
|
89 | * Get the playback state at the given time
|
90 | */
|
91 | getStateAtTime: (time: Time) => BasicPlaybackState;
|
92 | /**
|
93 | * Get the playback state at the current time
|
94 | */
|
95 | get state(): BasicPlaybackState;
|
96 | /**
|
97 | * Cancel a scheduled stop event
|
98 | */
|
99 | cancelStop(): this;
|
100 | dispose(): this;
|
101 | }
|
102 | export {};
|