@drincs/pixi-vn 1.6.4 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -53
- package/dist/{HistoryChoiceMenuOption-DM4wqiGt.d.ts → HistoryChoiceMenuOption-BP9Tsbyd.d.ts} +1 -2
- package/dist/{HistoryChoiceMenuOption-iazqoVVm.d.cts → HistoryChoiceMenuOption-DSSNUXEq.d.cts} +1 -2
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +56 -51
- package/dist/canvas.d.ts +56 -51
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-L4IHQ3VT.mjs → chunk-3SLELYPF.mjs} +1 -1
- package/dist/chunk-6HI66YQL.mjs +1 -0
- package/dist/chunk-XYO5SLSM.mjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +1 -1
- package/dist/history.d.ts +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -9
- package/dist/index.d.cts +289 -114
- package/dist/index.d.ts +289 -114
- package/dist/index.mjs +2 -9
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +3 -1
- package/dist/motion.d.ts +3 -1
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +2 -2
- package/dist/narration.d.cts +3 -3
- package/dist/narration.d.ts +3 -3
- package/dist/narration.mjs +2 -2
- package/dist/pixi/browser.js +183 -171
- package/dist/sound.cjs +1 -1
- package/dist/sound.d.cts +337 -132
- package/dist/sound.d.ts +337 -132
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +63 -12
- package/dist/storage.d.ts +63 -12
- package/dist/storage.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +10 -1
- package/dist/vite.d.ts +10 -1
- package/dist/vite.mjs +1 -1
- package/package.json +21 -13
- package/dist/chunk-D45QSSXG.mjs +0 -1
- package/dist/chunk-EWW7VYPM.mjs +0 -1
- package/dist/chunk-ZW3MIPMS.mjs +0 -1
- /package/dist/{chunk-XSN6P5JL.mjs → chunk-JMOSOAGB.mjs} +0 -0
package/dist/sound.d.cts
CHANGED
|
@@ -1,28 +1,95 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Player, PlayerOptions, ToneAudioNode, Param, ReverbOptions, FeedbackDelayOptions, FreeverbOptions, DelayOptions, PingPongDelayOptions, GateOptions, AutoFilterOptions, BiquadFilterOptions, OnePoleFilterOptions, FeedbackCombFilterOptions, FilterOptions, ChorusOptions, PhaserOptions, TremoloOptions, VibratoOptions, CompressorOptions, MidSideCompressorOptions, MultibandCompressorOptions, LimiterOptions, GreaterThanOptions, GreaterThanZeroOptions, DistortionOptions, BitCrusherOptions, Panner3DOptions, AutoPannerOptions, StereoWidenerOptions, ToneAudioBuffer } from 'tone';
|
|
2
|
+
import { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
|
|
3
|
+
import 'lru-cache';
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
interface MediaInterface extends Pick<Player, "blockTime" | "disposed" | "loaded" | "loop" | "loopEnd" | "loopStart" | "mute" | "now" | "playbackRate" | "reverse" | "restart" | "start" | "stop" | "chain" | "disconnect" | "volume" | "state"> {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the sound is currently paused.
|
|
8
|
+
*/
|
|
9
|
+
paused: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use {@link mute} instead.
|
|
12
|
+
*/
|
|
13
|
+
muted: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use {@link playbackRate} instead.
|
|
16
|
+
*/
|
|
17
|
+
speed: number;
|
|
18
|
+
}
|
|
19
|
+
interface MediaMemory extends Partial<Omit<PlayerOptions, "url" | "volume">> {
|
|
20
|
+
/**
|
|
21
|
+
* The volume of this sound in the linear range [0, 1], where 0 is silence
|
|
22
|
+
* and 1 is full volume. Stored and restored in linear form; converted
|
|
23
|
+
* to/from Tone.js decibels internally.
|
|
24
|
+
*/
|
|
25
|
+
volume?: number;
|
|
26
|
+
elapsed: number | undefined;
|
|
27
|
+
paused: boolean;
|
|
28
|
+
delay?: number;
|
|
29
|
+
}
|
|
4
30
|
|
|
5
|
-
interface SoundOptions extends
|
|
31
|
+
interface SoundOptions extends Pick<Partial<PlayerOptions>, "loop" | "autostart" | "fadeIn" | "fadeOut" | "mute" | "loopEnd" | "loopStart" | "reverse" | "playbackRate"> {
|
|
32
|
+
/**
|
|
33
|
+
* The volume of this sound in the linear range [0, 1], where 0 is silence
|
|
34
|
+
* and 1 is full volume. This is converted to decibels internally before
|
|
35
|
+
* being passed to the Tone.js Player.
|
|
36
|
+
*/
|
|
37
|
+
volume?: number;
|
|
38
|
+
/**
|
|
39
|
+
* A collection of audio filters/effects to apply to this sound.
|
|
40
|
+
*
|
|
41
|
+
* Install "tone" for the full list of available filters.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import * as Tone from "tone";
|
|
46
|
+
*
|
|
47
|
+
* const filters = [new Tone.FeedbackDelay("8n", 0.5)];
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
filters?: ToneAudioNode[];
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Use {@link playbackRate} instead.
|
|
53
|
+
*/
|
|
54
|
+
speed?: number;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Use {@link mute} instead.
|
|
57
|
+
*/
|
|
58
|
+
muted?: boolean;
|
|
6
59
|
}
|
|
7
|
-
interface SoundPlayOptions extends
|
|
60
|
+
interface SoundPlayOptions extends SoundOptions {
|
|
8
61
|
/**
|
|
9
|
-
* The delay in seconds before playback
|
|
62
|
+
* The delay in seconds before playback starts. If specified, playback is
|
|
63
|
+
* scheduled to begin after the delay has elapsed rather than starting
|
|
64
|
+
* immediately in a paused state.
|
|
10
65
|
*/
|
|
11
66
|
delay?: number;
|
|
67
|
+
/**
|
|
68
|
+
* The offset in seconds from the start of the sound at which to begin playback.
|
|
69
|
+
*/
|
|
70
|
+
elapsed?: number;
|
|
12
71
|
}
|
|
13
72
|
interface SoundPlayOptionsWithChannel extends SoundPlayOptions {
|
|
14
73
|
/**
|
|
15
|
-
* The alias of the audio channel to play the sound on. If the channel does
|
|
16
|
-
*
|
|
74
|
+
* The alias of the audio channel to play the sound on. If the channel does
|
|
75
|
+
* not exist it will be created automatically.
|
|
76
|
+
* Defaults to `SoundManagerInterface.defaultChannelAlias` ("general").
|
|
17
77
|
*/
|
|
18
78
|
channel?: string;
|
|
19
79
|
}
|
|
20
80
|
interface ChannelOptions extends Pick<SoundPlayOptions, "filters" | "muted" | "volume"> {
|
|
21
81
|
/**
|
|
22
82
|
* Whether this channel is a background channel.
|
|
23
|
-
* Background channels are special
|
|
83
|
+
* Background channels are special: media playing on them is not stopped
|
|
84
|
+
* when a scene changes, but continues in the background.
|
|
24
85
|
*/
|
|
25
86
|
background?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* The stereo pan position for this channel in the range [-1, 1].
|
|
89
|
+
* -1 is full left, 0 is centre, 1 is full right.
|
|
90
|
+
* Defaults to 0.
|
|
91
|
+
*/
|
|
92
|
+
pan?: number;
|
|
26
93
|
}
|
|
27
94
|
|
|
28
95
|
interface AudioChannelInterface {
|
|
@@ -38,7 +105,7 @@ interface AudioChannelInterface {
|
|
|
38
105
|
* this cannot be reused after it is done playing. Returns a Promise if the sound
|
|
39
106
|
* has not yet loaded.
|
|
40
107
|
*/
|
|
41
|
-
play(alias: string, options?: SoundPlayOptions): Promise<
|
|
108
|
+
play(alias: string, options?: SoundPlayOptions): Promise<MediaInterface>;
|
|
42
109
|
/**
|
|
43
110
|
* Plays a sound.
|
|
44
111
|
* @param mediaAlias The media alias reference.
|
|
@@ -48,7 +115,12 @@ interface AudioChannelInterface {
|
|
|
48
115
|
* this cannot be reused after it is done playing. Returns a Promise if the sound
|
|
49
116
|
* has not yet loaded.
|
|
50
117
|
*/
|
|
51
|
-
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptions): Promise<
|
|
118
|
+
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptions): Promise<MediaInterface>;
|
|
119
|
+
/**
|
|
120
|
+
* The stereo pan position for this channel in the range [-1, 1].
|
|
121
|
+
* -1 is full left, 0 is centre, 1 is full right.
|
|
122
|
+
*/
|
|
123
|
+
pan: number;
|
|
52
124
|
/**
|
|
53
125
|
* The volume of the audio channel, between 0 and 1. This is multiplied with the volume of each sound played through this channel.
|
|
54
126
|
*/
|
|
@@ -60,7 +132,7 @@ interface AudioChannelInterface {
|
|
|
60
132
|
/**
|
|
61
133
|
* The MediaInstances currently playing through this channel. This is read-only and cannot be modified directly. Use the play method to add new MediaInstances to this channel.
|
|
62
134
|
*/
|
|
63
|
-
readonly mediaInstances:
|
|
135
|
+
readonly mediaInstances: MediaInterface[];
|
|
64
136
|
/**
|
|
65
137
|
* Whether this channel is a background channel.
|
|
66
138
|
* Background channels are special channels. Unlike normal channels, media connected to a background channel does not stop when a scene changes, but continues to play in the background.
|
|
@@ -86,45 +158,128 @@ interface AudioChannelInterface {
|
|
|
86
158
|
* @return `true` if all sounds are muted.
|
|
87
159
|
*/
|
|
88
160
|
toggleMuteAll(): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Useful for inserting channel-wide audio effects such as reverb, delay or EQ.
|
|
163
|
+
*
|
|
164
|
+
* Install "tone" to use this method.
|
|
165
|
+
*
|
|
166
|
+
* @param nodes One or more Tone.js {@link ToneAudioNode} instances to chain in series.
|
|
167
|
+
* @return Instance for chaining.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* import * as Tone from "tone";
|
|
172
|
+
*
|
|
173
|
+
* const channel = sound.findChannel("music");
|
|
174
|
+
*
|
|
175
|
+
* // Create a reverb effect and wait for its impulse response to be ready.
|
|
176
|
+
* const reverb = new Tone.Reverb({ decay: 2.5 });
|
|
177
|
+
*
|
|
178
|
+
* // Route the channel through the reverb to the master output.
|
|
179
|
+
* channel.chain(reverb);
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
chain(...nodes: ToneAudioNode[]): this;
|
|
183
|
+
/**
|
|
184
|
+
* **Advanced** — the raw `Tone.Param<"decibels">` for this channel's volume.
|
|
185
|
+
*
|
|
186
|
+
* Unlike the {@link volume} property (which uses a linear 0–1 scale), this
|
|
187
|
+
* Param works directly in **decibels** and exposes all Tone.js automation
|
|
188
|
+
* methods such as `rampTo`, `linearRampTo`, and `exponentialRampTo`.
|
|
189
|
+
*
|
|
190
|
+
* Use this when you need to smoothly automate volume over time instead of
|
|
191
|
+
* setting it instantly.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const channel = sound.findChannel("music");
|
|
196
|
+
*
|
|
197
|
+
* // Fade the volume from its current level to -12 dB over 3 seconds.
|
|
198
|
+
* channel.volumeParam.rampTo(-12, 3);
|
|
199
|
+
*
|
|
200
|
+
* // Fade to silence over 2 seconds.
|
|
201
|
+
* channel.volumeParam.rampTo(-Infinity, 2);
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
readonly volumeParam: Param<"decibels">;
|
|
205
|
+
/**
|
|
206
|
+
* **Advanced** — the raw `Tone.Param<"audioRange">` for this channel's
|
|
207
|
+
* stereo pan position.
|
|
208
|
+
*
|
|
209
|
+
* Unlike the {@link pan} property (which sets the value instantly), this
|
|
210
|
+
* Param exposes all Tone.js automation methods such as `rampTo`,
|
|
211
|
+
* `linearRampTo`, and `exponentialRampTo`.
|
|
212
|
+
*
|
|
213
|
+
* Use this when you need to smoothly automate panning over time instead of
|
|
214
|
+
* setting it instantly. Values range from -1 (full left) to 1 (full right).
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* const channel = sound.findChannel("music");
|
|
219
|
+
*
|
|
220
|
+
* // Gradually pan to the left over 3 seconds.
|
|
221
|
+
* channel.panParam.rampTo(-1, 3);
|
|
222
|
+
*
|
|
223
|
+
* // Return to centre over 2 seconds.
|
|
224
|
+
* channel.panParam.rampTo(0, 2);
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
readonly panParam: Param<"audioRange">;
|
|
89
228
|
}
|
|
90
229
|
|
|
91
|
-
type
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
230
|
+
type SoundFilterMemory = ({
|
|
231
|
+
filterType: "ReverbFilter";
|
|
232
|
+
} & Omit<Partial<ReverbOptions>, "context">) | ({
|
|
233
|
+
filterType: "FeedbackDelayFilter";
|
|
234
|
+
} & Omit<Partial<FeedbackDelayOptions>, "context">) | ({
|
|
235
|
+
filterType: "FreeverbFilter";
|
|
236
|
+
} & Omit<Partial<FreeverbOptions>, "context">) | ({
|
|
237
|
+
filterType: "DelayFilter";
|
|
238
|
+
} & Omit<Partial<DelayOptions>, "context">) | ({
|
|
239
|
+
filterType: "PingPongDelayFilter";
|
|
240
|
+
} & Omit<Partial<PingPongDelayOptions>, "context">) | ({
|
|
241
|
+
filterType: "GateFilter";
|
|
242
|
+
} & Omit<Partial<GateOptions>, "context">) | ({
|
|
243
|
+
filterType: "AutoFilterFilter";
|
|
244
|
+
} & Omit<Partial<AutoFilterOptions>, "context">) | ({
|
|
245
|
+
filterType: "BiquadFilterFilter";
|
|
246
|
+
} & Omit<Partial<BiquadFilterOptions>, "context">) | ({
|
|
247
|
+
filterType: "OnePoleFilterFilter";
|
|
248
|
+
} & Omit<Partial<OnePoleFilterOptions>, "context" | "frequency">) | ({
|
|
249
|
+
filterType: "FeedbackCombFilterFilter";
|
|
250
|
+
} & Omit<Partial<FeedbackCombFilterOptions>, "context">) | ({
|
|
251
|
+
filterType: "CustomFilter";
|
|
252
|
+
} & Omit<Partial<FilterOptions>, "context">) | ({
|
|
253
|
+
filterType: "ChorusFilter";
|
|
254
|
+
} & Omit<Partial<ChorusOptions>, "context">) | ({
|
|
255
|
+
filterType: "PhaserFilter";
|
|
256
|
+
} & Omit<Partial<PhaserOptions>, "context">) | ({
|
|
257
|
+
filterType: "TremoloFilter";
|
|
258
|
+
} & Omit<Partial<TremoloOptions>, "context">) | ({
|
|
259
|
+
filterType: "VibratoFilter";
|
|
260
|
+
} & Omit<Partial<VibratoOptions>, "context">) | ({
|
|
261
|
+
filterType: "CompressorFilter";
|
|
262
|
+
} & Omit<Partial<CompressorOptions>, "context">) | ({
|
|
263
|
+
filterType: "MidSideCompressorFilter";
|
|
264
|
+
} & Omit<Partial<MidSideCompressorOptions>, "context">) | ({
|
|
265
|
+
filterType: "MultibandCompressorFilter";
|
|
266
|
+
} & Omit<Partial<MultibandCompressorOptions>, "context">) | ({
|
|
267
|
+
filterType: "LimiterFilter";
|
|
268
|
+
} & Omit<Partial<LimiterOptions>, "context">) | ({
|
|
269
|
+
filterType: "GreaterThanFilter";
|
|
270
|
+
} & Omit<Partial<GreaterThanOptions>, "context">) | ({
|
|
271
|
+
filterType: "GreaterThanZeroFilter";
|
|
272
|
+
} & Omit<Partial<GreaterThanZeroOptions>, "context">) | ({
|
|
273
|
+
filterType: "DistortionFilter";
|
|
274
|
+
} & Omit<Partial<DistortionOptions>, "context">) | ({
|
|
275
|
+
filterType: "BitCrusherFilter";
|
|
276
|
+
} & Omit<Partial<BitCrusherOptions>, "context">) | ({
|
|
277
|
+
filterType: "Panner3DFilter";
|
|
278
|
+
} & Omit<Partial<Panner3DOptions>, "context">) | ({
|
|
279
|
+
filterType: "AutoPannerFilter";
|
|
280
|
+
} & Omit<Partial<AutoPannerOptions>, "context">) | ({
|
|
281
|
+
filterType: "StereoWidenerFilter";
|
|
282
|
+
} & Omit<Partial<StereoWidenerOptions>, "context">);
|
|
128
283
|
|
|
129
284
|
interface ExportedSound {
|
|
130
285
|
options: SoundOptions;
|
|
@@ -142,7 +297,6 @@ interface ExportedSoundPlay extends SoundPlay {
|
|
|
142
297
|
* Interface exported sounds
|
|
143
298
|
*/
|
|
144
299
|
interface SoundGameState {
|
|
145
|
-
filters?: SoundFilterMemory[];
|
|
146
300
|
/**
|
|
147
301
|
* @deprecated
|
|
148
302
|
*/
|
|
@@ -154,138 +308,189 @@ interface SoundGameState {
|
|
|
154
308
|
channelAlias: string;
|
|
155
309
|
soundAlias: string;
|
|
156
310
|
stepCounter: number;
|
|
157
|
-
options:
|
|
311
|
+
options: MediaMemory & {
|
|
158
312
|
filters?: SoundFilterMemory[];
|
|
313
|
+
delay?: number;
|
|
159
314
|
};
|
|
160
|
-
|
|
315
|
+
/**
|
|
316
|
+
* @deprecated Use options.paused instead.
|
|
317
|
+
*/
|
|
318
|
+
paused?: boolean;
|
|
161
319
|
};
|
|
162
320
|
};
|
|
163
321
|
}
|
|
164
322
|
|
|
165
|
-
interface SoundManagerInterface
|
|
323
|
+
interface SoundManagerInterface {
|
|
324
|
+
/** Master volume in the range [0, 1]. */
|
|
325
|
+
volumeAll: number;
|
|
166
326
|
/**
|
|
167
|
-
* @deprecated
|
|
327
|
+
* @deprecated Global playback speed. This is not a well-supported feature and may be removed in a future release. Use individual sound speed options instead.
|
|
168
328
|
*/
|
|
169
|
-
|
|
329
|
+
speedAll: number;
|
|
330
|
+
/**
|
|
331
|
+
* The default channel alias used when playing a sound without specifying a
|
|
332
|
+
* channel. Defaults to `"general"`.
|
|
333
|
+
*/
|
|
334
|
+
defaultChannelAlias: string;
|
|
335
|
+
/**
|
|
336
|
+
* @deprecated Register sound assets directly via `PIXI.Assets` instead.
|
|
337
|
+
*/
|
|
338
|
+
add(alias: string, options: string): void;
|
|
170
339
|
/**
|
|
171
340
|
* Plays a sound.
|
|
172
341
|
* @param alias The media and sound (asset) alias reference.
|
|
173
|
-
* @param options The options
|
|
174
|
-
* @
|
|
175
|
-
* this cannot be reused after it is done playing. Returns a Promise if the sound
|
|
176
|
-
* has not yet loaded.
|
|
342
|
+
* @param options The options.
|
|
343
|
+
* @returns The media instance (resolves immediately if already loaded).
|
|
177
344
|
*/
|
|
178
|
-
play(alias: string, options?: SoundPlayOptionsWithChannel): Promise<
|
|
179
|
-
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptionsWithChannel): Promise<
|
|
345
|
+
play(alias: string, options?: SoundPlayOptionsWithChannel): Promise<MediaInterface>;
|
|
346
|
+
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptionsWithChannel): Promise<MediaInterface>;
|
|
180
347
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* @return Media object.
|
|
348
|
+
* Plays a non-persistent ("transient") sound (e.g. UI / menu sounds).
|
|
349
|
+
* Transient playback is not tracked in save/export state.
|
|
184
350
|
*/
|
|
185
|
-
|
|
351
|
+
playTransient(alias: string, options?: Partial<PlayerOptions>): Promise<Player>;
|
|
186
352
|
/**
|
|
187
|
-
*
|
|
188
|
-
* @param alias - The media alias reference.
|
|
353
|
+
* Find a tracked media instance by alias.
|
|
189
354
|
*/
|
|
190
|
-
|
|
355
|
+
find(alias: string): MediaInterface | undefined;
|
|
191
356
|
/**
|
|
192
|
-
*
|
|
193
|
-
* @param alias - The media alias reference.
|
|
194
|
-
* @return Media object.
|
|
357
|
+
* Stop a tracked media instance and remove it from the manager.
|
|
195
358
|
*/
|
|
196
|
-
|
|
359
|
+
stop(alias: string): void;
|
|
197
360
|
/**
|
|
198
|
-
*
|
|
199
|
-
* @param alias - The media alias reference.
|
|
200
|
-
* @return Media object.
|
|
361
|
+
* Pause a tracked media instance.
|
|
201
362
|
*/
|
|
202
|
-
|
|
363
|
+
pause(alias: string): MediaInterface | undefined;
|
|
203
364
|
/**
|
|
204
|
-
*
|
|
205
|
-
* If the asset is not yet loaded, it will be loaded with the new options.
|
|
365
|
+
* Resume a paused media instance.
|
|
206
366
|
*/
|
|
207
|
-
|
|
367
|
+
resume(alias: string): MediaInterface | undefined;
|
|
368
|
+
/** Duration in seconds of the loaded sound with the given alias. */
|
|
369
|
+
duration(alias: string): number;
|
|
370
|
+
/** Toggle mute on all sounds. Returns the new muted state. */
|
|
371
|
+
toggleMuteAll(): boolean;
|
|
208
372
|
/**
|
|
209
|
-
*
|
|
210
|
-
* @return Instance for chaining.
|
|
373
|
+
* Whether all sounds are currently muted. Note that individual channels or media instances may still be muted or unmuted; this is just the global master mute state.
|
|
211
374
|
*/
|
|
375
|
+
readonly muted: boolean;
|
|
376
|
+
/** Mute all sounds. */
|
|
377
|
+
muteAll(): this;
|
|
378
|
+
/** Unmute all sounds. */
|
|
379
|
+
unmuteAll(): this;
|
|
380
|
+
/** Stop all sounds. */
|
|
381
|
+
stopAll(): this;
|
|
382
|
+
/** Pause all sounds. */
|
|
212
383
|
pauseAll(): this;
|
|
213
|
-
/**
|
|
214
|
-
* Resumes any sounds.
|
|
215
|
-
* @return Instance for chaining.
|
|
216
|
-
*/
|
|
384
|
+
/** Resume all sounds. */
|
|
217
385
|
resumeAll(): this;
|
|
218
386
|
/**
|
|
219
|
-
*
|
|
220
|
-
*
|
|
387
|
+
* Temporarily pause all currently-playing sounds (or just those in the given
|
|
388
|
+
* channel) without persisting the paused state. Useful for overlays / pause
|
|
389
|
+
* menus.
|
|
390
|
+
*
|
|
391
|
+
* Only sounds that are **actively playing** at the time of the call are paused;
|
|
392
|
+
* sounds that were already paused beforehand are left untouched so that they
|
|
393
|
+
* remain paused when {@link resumeUnsavedAll} is called later.
|
|
394
|
+
*
|
|
395
|
+
* When called without a channel argument all transient players started with
|
|
396
|
+
* {@link playTransient} are also stopped.
|
|
221
397
|
*/
|
|
222
|
-
|
|
398
|
+
pauseUnsavedAll(channel?: string): this;
|
|
223
399
|
/**
|
|
224
|
-
*
|
|
225
|
-
* @
|
|
400
|
+
* Resume all sounds (or just those in the given channel) that were paused by
|
|
401
|
+
* the most recent call to {@link pauseUnsavedAll}. Sounds that were already
|
|
402
|
+
* paused before `pauseUnsavedAll` was called are **not** resumed.
|
|
226
403
|
*/
|
|
227
|
-
|
|
404
|
+
resumeUnsavedAll(channel?: string): this;
|
|
228
405
|
/**
|
|
229
|
-
*
|
|
230
|
-
* @return Instance for chaining.
|
|
406
|
+
* Stop all transient media instances started with {@link playTransient}.
|
|
231
407
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
408
|
+
stopTransientAll(): this;
|
|
409
|
+
/** Load one or more sound assets. */
|
|
410
|
+
load(...alias: string[]): Promise<void>;
|
|
411
|
+
/** Trigger background loading of one or more sound assets. */
|
|
412
|
+
backgroundLoad(...alias: string[]): Promise<void>;
|
|
413
|
+
/** Trigger background loading of a sound bundle. */
|
|
235
414
|
backgroundLoadBundle(alias: string): Promise<void>;
|
|
415
|
+
/** Stop all sounds and clear internal state. */
|
|
236
416
|
clear(): void;
|
|
237
417
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* @returns The created AudioChannelInterface instance, or undefined if a channel with the alias already exists.
|
|
418
|
+
* Add a new audio channel.
|
|
419
|
+
* Returns the created channel, or `undefined` if the alias already exists.
|
|
241
420
|
*/
|
|
242
421
|
addChannel(alias: string | string[], options?: ChannelOptions): AudioChannelInterface | undefined;
|
|
243
422
|
/**
|
|
244
|
-
*
|
|
245
|
-
* @param alias The alias of the audio channel to find.
|
|
246
|
-
* @returns The AudioChannelInterface instance associated with the alias.
|
|
423
|
+
* Find the channel for the given alias, creating it if it does not yet exist.
|
|
247
424
|
*/
|
|
248
425
|
findChannel(alias: string): AudioChannelInterface;
|
|
249
|
-
/**
|
|
250
|
-
* Returns an array of all existing audio channels.
|
|
251
|
-
*/
|
|
426
|
+
/** All registered audio channels. */
|
|
252
427
|
readonly channels: AudioChannelInterface[];
|
|
253
428
|
/**
|
|
254
|
-
*
|
|
255
|
-
* By default, this is set to `GENERAL_CHANNEL` ("general"), but it can be changed to any string; if the channel does not yet exist, it will be created on demand when used.
|
|
429
|
+
* Export the current sound state, including currently playing sounds and their options, for saving or debugging purposes. This is not guaranteed to be stable across versions and may contain implementation details; it is not intended for use in general application code.
|
|
256
430
|
*/
|
|
257
|
-
defaultChannelAlias: string;
|
|
258
431
|
export(): SoundGameState;
|
|
432
|
+
/**
|
|
433
|
+
* Restore a sound state exported by {@link export}. This will stop any currently playing sounds and replace them with the sounds specified in the exported state. This is not guaranteed to be stable across versions and may contain implementation details; it is not intended for use in general application code.
|
|
434
|
+
*/
|
|
259
435
|
restore(data: object): Promise<void>;
|
|
260
436
|
}
|
|
261
437
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
438
|
+
type Time = Parameters<Player["stop"]>[0];
|
|
439
|
+
declare class MediaInstance extends Player implements MediaInterface {
|
|
440
|
+
readonly alias: string;
|
|
441
|
+
readonly channelAlias: string;
|
|
442
|
+
readonly soundAlias: string;
|
|
443
|
+
readonly stepCounter: number;
|
|
444
|
+
readonly delay?: number | undefined;
|
|
445
|
+
constructor(alias: string, channelAlias: string, soundAlias: string, stepCounter: number, options?: Partial<PlayerOptions>, delay?: number | undefined);
|
|
446
|
+
readonly options: Partial<PlayerOptions>;
|
|
447
|
+
readonly filters: Set<ToneAudioNode>;
|
|
448
|
+
/**
|
|
449
|
+
* Set to `toneNow()` the moment playback is paused; cleared on resume.
|
|
450
|
+
* Used to compute how long the instance was paused so that
|
|
451
|
+
* `playStartTime` can be adjusted accordingly.
|
|
452
|
+
*/
|
|
453
|
+
private pausedAt;
|
|
454
|
+
/**
|
|
455
|
+
* Tracks the effective playback start time in Tone's clock, adjusted
|
|
456
|
+
* after each resume to exclude all time spent paused.
|
|
457
|
+
* Invariant: `toneNow() - playStartTime` equals actual playback position
|
|
458
|
+
* while the player is playing.
|
|
459
|
+
*/
|
|
460
|
+
private playStartTime;
|
|
461
|
+
get memory(): MediaMemory;
|
|
462
|
+
set memory(options: MediaMemory);
|
|
463
|
+
get paused(): boolean;
|
|
464
|
+
set paused(value: boolean);
|
|
465
|
+
get muted(): boolean;
|
|
466
|
+
set muted(value: boolean);
|
|
467
|
+
get speed(): number;
|
|
468
|
+
set speed(value: number);
|
|
469
|
+
stop(time?: Time): this;
|
|
470
|
+
chain(...nodes: ToneAudioNode[]): this;
|
|
471
|
+
disconnect(node: ToneAudioNode): this;
|
|
472
|
+
}
|
|
271
473
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
474
|
+
/**
|
|
475
|
+
* SoundRegistry is a singleton namespace that holds global state for the sound system.
|
|
476
|
+
* **DO NOT** import this module directly; use `sound`.
|
|
477
|
+
*/
|
|
478
|
+
declare namespace SoundRegistry {
|
|
479
|
+
const mediaInstances: Map<string, MediaInstance>;
|
|
480
|
+
const channels: Map<string, AudioChannelInterface>;
|
|
481
|
+
const transients: Set<Player>;
|
|
482
|
+
/**
|
|
483
|
+
* Aliases of {@link mediaInstances} that were paused by `pauseUnsavedAll`.
|
|
484
|
+
* Used by `resumeUnsavedAll` to only resume the instances it paused, leaving
|
|
485
|
+
* any previously-paused instances untouched.
|
|
486
|
+
*/
|
|
487
|
+
const systemPausedAliases: Set<string>;
|
|
488
|
+
const bufferRegistry: CachedMap<string, ToneAudioBuffer>;
|
|
287
489
|
}
|
|
288
490
|
|
|
491
|
+
/**
|
|
492
|
+
* The singleton sound manager instance. Use this to play and manage sounds in your game.
|
|
493
|
+
*/
|
|
289
494
|
declare const sound: SoundManagerInterface;
|
|
290
495
|
|
|
291
|
-
export { type AudioChannelInterface, type ChannelOptions, type ExportedSound, type ExportedSoundPlay, type
|
|
496
|
+
export { type AudioChannelInterface, type ChannelOptions, type ExportedSound, type ExportedSoundPlay, type MediaInterface, type SoundGameState, type SoundOptions, type SoundPlay, type SoundPlayOptions, type SoundPlayOptionsWithChannel, SoundRegistry, sound };
|