1 | import { Param } from "../../core/context/Param.js";
|
2 | import { ToneAudioBuffer } from "../../core/context/ToneAudioBuffer.js";
|
3 | import { ToneAudioBuffersUrlMap } from "../../core/context/ToneAudioBuffers.js";
|
4 | import { OutputNode, ToneAudioNode } from "../../core/context/ToneAudioNode.js";
|
5 | import { Decibels, Time } from "../../core/type/Units.js";
|
6 | import { BasicPlaybackState } from "../../core/util/StateTimeline.js";
|
7 | import { SourceOptions } from "../Source.js";
|
8 | import { Player } from "./Player.js";
|
9 | export interface PlayersOptions extends SourceOptions {
|
10 | urls: ToneAudioBuffersUrlMap;
|
11 | volume: Decibels;
|
12 | mute: boolean;
|
13 | onload: () => void;
|
14 | onerror: (error: Error) => void;
|
15 | baseUrl: string;
|
16 | fadeIn: Time;
|
17 | fadeOut: Time;
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | export declare class Players extends ToneAudioNode<PlayersOptions> {
|
24 | readonly name: string;
|
25 | |
26 |
|
27 |
|
28 | private _volume;
|
29 | |
30 |
|
31 |
|
32 | readonly volume: Param<"decibels">;
|
33 | |
34 |
|
35 |
|
36 | readonly output: OutputNode;
|
37 | |
38 |
|
39 |
|
40 | readonly input: undefined;
|
41 | |
42 |
|
43 |
|
44 | private _players;
|
45 | |
46 |
|
47 |
|
48 | private _buffers;
|
49 | |
50 |
|
51 |
|
52 | private _fadeIn;
|
53 | |
54 |
|
55 |
|
56 | private _fadeOut;
|
57 | |
58 |
|
59 |
|
60 |
|
61 | constructor(urls?: ToneAudioBuffersUrlMap, onload?: () => void);
|
62 | /**
|
63 | * @param urls An object mapping a name to a url.
|
64 | * @param options The remaining options associated with the players
|
65 | */
|
66 | constructor(urls?: ToneAudioBuffersUrlMap, options?: Partial<Omit<PlayersOptions, "urls">>);
|
67 | constructor(options?: Partial<PlayersOptions>);
|
68 | static getDefaults(): PlayersOptions;
|
69 | /**
|
70 | * Mute the output.
|
71 | */
|
72 | get mute(): boolean;
|
73 | set mute(mute: boolean);
|
74 | /**
|
75 | * The fadeIn time of the envelope applied to the source.
|
76 | */
|
77 | get fadeIn(): Time;
|
78 | set fadeIn(fadeIn: Time);
|
79 | /**
|
80 | * The fadeOut time of the each of the sources.
|
81 | */
|
82 | get fadeOut(): Time;
|
83 | set fadeOut(fadeOut: Time);
|
84 | /**
|
85 | * The state of the players object. Returns "started" if any of the players are playing.
|
86 | */
|
87 | get state(): BasicPlaybackState;
|
88 | /**
|
89 | * True if the buffers object has a buffer by that name.
|
90 | * @param name The key or index of the buffer.
|
91 | */
|
92 | has(name: string): boolean;
|
93 | /**
|
94 | * Get a player by name.
|
95 | * @param name The players name as defined in the constructor object or `add` method.
|
96 | */
|
97 | player(name: string): Player;
|
98 | /**
|
99 | * If all the buffers are loaded or not
|
100 | */
|
101 | get loaded(): boolean;
|
102 | /**
|
103 | * Add a player by name and url to the Players
|
104 | * @param name A unique name to give the player
|
105 | * @param url Either the url of the bufer or a buffer which will be added with the given name.
|
106 | * @param callback The callback to invoke when the url is loaded.
|
107 | * @example
|
108 | * const players = new Tone.Players();
|
109 | * players.add("gong", "https:
|
110 | * console.log("gong loaded");
|
111 | * players.player("gong").start();
|
112 | * });
|
113 | */
|
114 | add(name: string, url: string | ToneAudioBuffer | AudioBuffer, callback?: () => void): this;
|
115 | /**
|
116 | * Stop all of the players at the given time
|
117 | * @param time The time to stop all of the players.
|
118 | */
|
119 | stopAll(time?: Time): this;
|
120 | dispose(): this;
|
121 | }
|