1 | import { NormalRange, Positive, Seconds, Time, TransportTime } from "../core/type/Units.js";
|
2 | import { ToneWithContext, ToneWithContextOptions } from "../core/context/ToneWithContext.js";
|
3 | import { BasicPlaybackState } from "../core/util/StateTimeline.js";
|
4 | export interface LoopOptions extends ToneWithContextOptions {
|
5 | callback: (time: Seconds) => void;
|
6 | interval: Time;
|
7 | playbackRate: Positive;
|
8 | iterations: number;
|
9 | probability: NormalRange;
|
10 | mute: boolean;
|
11 | humanize: boolean | Time;
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | export declare class Loop<Options extends LoopOptions = LoopOptions> extends ToneWithContext<Options> {
|
27 | readonly name: string;
|
28 | |
29 |
|
30 |
|
31 | private _event;
|
32 | |
33 |
|
34 |
|
35 | callback: (time: Seconds) => void;
|
36 | |
37 |
|
38 |
|
39 |
|
40 | constructor(callback?: (time: Seconds) => void, interval?: Time);
|
41 | constructor(options?: Partial<LoopOptions>);
|
42 | static getDefaults(): LoopOptions;
|
43 | /**
|
44 | * Start the loop at the specified time along the Transport's timeline.
|
45 | * @param time When to start the Loop.
|
46 | */
|
47 | start(time?: TransportTime): this;
|
48 | /**
|
49 | * Stop the loop at the given time.
|
50 | * @param time When to stop the Loop.
|
51 | */
|
52 | stop(time?: TransportTime): this;
|
53 | /**
|
54 | * Cancel all scheduled events greater than or equal to the given time
|
55 | * @param time The time after which events will be cancel.
|
56 | */
|
57 | cancel(time?: TransportTime): this;
|
58 | /**
|
59 | * Internal function called when the notes should be called
|
60 | * @param time The time the event occurs
|
61 | */
|
62 | protected _tick(time: Seconds): void;
|
63 | /**
|
64 | * The state of the Loop, either started or stopped.
|
65 | */
|
66 | get state(): BasicPlaybackState;
|
67 | /**
|
68 | * The progress of the loop as a value between 0-1. 0, when the loop is stopped or done iterating.
|
69 | */
|
70 | get progress(): NormalRange;
|
71 | /**
|
72 | * The time between successive callbacks.
|
73 | * @example
|
74 | * const loop = new Tone.Loop();
|
75 | * loop.interval = "8n"; // loop every 8n
|
76 | */
|
77 | get interval(): Time;
|
78 | set interval(interval: Time);
|
79 | /**
|
80 | * The playback rate of the loop. The normal playback rate is 1 (no change).
|
81 | * A `playbackRate` of 2 would be twice as fast.
|
82 | */
|
83 | get playbackRate(): Positive;
|
84 | set playbackRate(rate: Positive);
|
85 | /**
|
86 | * Random variation +/-0.01s to the scheduled time.
|
87 | * Or give it a time value which it will randomize by.
|
88 | */
|
89 | get humanize(): boolean | Time;
|
90 | set humanize(variation: boolean | Time);
|
91 | /**
|
92 | * The probably of the callback being invoked.
|
93 | */
|
94 | get probability(): NormalRange;
|
95 | set probability(prob: NormalRange);
|
96 | /**
|
97 | * Muting the Loop means that no callbacks are invoked.
|
98 | */
|
99 | get mute(): boolean;
|
100 | set mute(mute: boolean);
|
101 | /**
|
102 | * The number of iterations of the loop. The default value is `Infinity` (loop forever).
|
103 | */
|
104 | get iterations(): number;
|
105 | set iterations(iters: number);
|
106 | dispose(): this;
|
107 | }
|