@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.
Files changed (48) hide show
  1. package/README.md +47 -53
  2. package/dist/{HistoryChoiceMenuOption-DM4wqiGt.d.ts → HistoryChoiceMenuOption-BP9Tsbyd.d.ts} +1 -2
  3. package/dist/{HistoryChoiceMenuOption-iazqoVVm.d.cts → HistoryChoiceMenuOption-DSSNUXEq.d.cts} +1 -2
  4. package/dist/canvas.cjs +2 -2
  5. package/dist/canvas.d.cts +56 -51
  6. package/dist/canvas.d.ts +56 -51
  7. package/dist/canvas.mjs +2 -2
  8. package/dist/characters.cjs +1 -1
  9. package/dist/characters.mjs +1 -1
  10. package/dist/{chunk-L4IHQ3VT.mjs → chunk-3SLELYPF.mjs} +1 -1
  11. package/dist/chunk-6HI66YQL.mjs +1 -0
  12. package/dist/chunk-XYO5SLSM.mjs +1 -0
  13. package/dist/core.cjs +1 -1
  14. package/dist/core.mjs +1 -1
  15. package/dist/history.cjs +1 -1
  16. package/dist/history.d.cts +1 -1
  17. package/dist/history.d.ts +1 -1
  18. package/dist/history.mjs +1 -1
  19. package/dist/index.cjs +2 -9
  20. package/dist/index.d.cts +289 -114
  21. package/dist/index.d.ts +289 -114
  22. package/dist/index.mjs +2 -9
  23. package/dist/motion.cjs +1 -1
  24. package/dist/motion.d.cts +3 -1
  25. package/dist/motion.d.ts +3 -1
  26. package/dist/motion.mjs +1 -1
  27. package/dist/narration.cjs +2 -2
  28. package/dist/narration.d.cts +3 -3
  29. package/dist/narration.d.ts +3 -3
  30. package/dist/narration.mjs +2 -2
  31. package/dist/pixi/browser.js +183 -171
  32. package/dist/sound.cjs +1 -1
  33. package/dist/sound.d.cts +337 -132
  34. package/dist/sound.d.ts +337 -132
  35. package/dist/sound.mjs +1 -1
  36. package/dist/storage.cjs +1 -1
  37. package/dist/storage.d.cts +63 -12
  38. package/dist/storage.d.ts +63 -12
  39. package/dist/storage.mjs +1 -1
  40. package/dist/vite.cjs +1 -1
  41. package/dist/vite.d.cts +10 -1
  42. package/dist/vite.d.ts +10 -1
  43. package/dist/vite.mjs +1 -1
  44. package/package.json +21 -13
  45. package/dist/chunk-D45QSSXG.mjs +0 -1
  46. package/dist/chunk-EWW7VYPM.mjs +0 -1
  47. package/dist/chunk-ZW3MIPMS.mjs +0 -1
  48. /package/dist/{chunk-XSN6P5JL.mjs → chunk-JMOSOAGB.mjs} +0 -0
package/dist/sound.d.ts CHANGED
@@ -1,28 +1,95 @@
1
- import { IMediaInstance as IMediaInstance$1, PlayOptions, Options, SoundLibrary, Sound, filters as filters$1 } from '@pixi/sound';
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.js';
3
+ import 'lru-cache';
2
4
 
3
- type IMediaInstance = Omit<IMediaInstance$1, "on" | "destroy" | "init" | "off" | "once" | "toString">;
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 Omit<Options, "complete" | "loaded" | "sprites" | "source"> {
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 Omit<PlayOptions, "complete" | "loaded"> {
60
+ interface SoundPlayOptions extends SoundOptions {
8
61
  /**
9
- * The delay in seconds before playback becomes audible or resumes. If specified, the sound will be started immediately but delayed (for example, via pause/unpause) so that it is effectively heard only after the delay. If not specified, the sound will play without any additional delay.
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 not exist, it will be created.
16
- * If not specified, the sound will be played on the default channel (see `SoundManagerInterface.defaultChannelAlias`).
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 channels. Unlike normal channels, media connected to a background channel does not stop when a scene changes, but continues to play in the background.
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<IMediaInstance>;
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<IMediaInstance>;
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: IMediaInstance[];
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 DistortionFilter = {
92
- type: "DistortionFilter";
93
- amount?: number;
94
- };
95
- type EqualizerFilter = {
96
- type: "EqualizerFilter";
97
- f32?: number;
98
- f64?: number;
99
- f125?: number;
100
- f250?: number;
101
- f500?: number;
102
- f1k?: number;
103
- f2k?: number;
104
- f4k?: number;
105
- f8k?: number;
106
- f16k?: number;
107
- };
108
- type MonoFilter = {
109
- type: "MonoFilter";
110
- };
111
- type ReverbFilter = {
112
- type: "ReverbFilter";
113
- seconds?: number;
114
- decay?: number;
115
- reverse?: boolean;
116
- };
117
- type StereoFilter = {
118
- type: "StereoFilter";
119
- pan?: number;
120
- };
121
- type StreamFilter = {
122
- type: "StreamFilter";
123
- };
124
- type TelephoneFilter = {
125
- type: "TelephoneFilter";
126
- };
127
- type SoundFilterMemory = DistortionFilter | EqualizerFilter | MonoFilter | ReverbFilter | StereoFilter | StreamFilter | TelephoneFilter;
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: Omit<SoundPlayOptions, "filters"> & {
311
+ options: MediaMemory & {
158
312
  filters?: SoundFilterMemory[];
313
+ delay?: number;
159
314
  };
160
- paused: boolean;
315
+ /**
316
+ * @deprecated Use options.paused instead.
317
+ */
318
+ paused?: boolean;
161
319
  };
162
320
  };
163
321
  }
164
322
 
165
- interface SoundManagerInterface extends Omit<SoundLibrary, "init" | "close" | "add" | "play" | "volume" | "speed" | "remove" | "exists" | "find" | "stop" | "pause" | "resume" | "pauseAll" | "resumeAll" | "muteAll" | "unmuteAll" | "stopAll" | "removeAll" | "togglePauseAll"> {
323
+ interface SoundManagerInterface {
324
+ /** Master volume in the range [0, 1]. */
325
+ volumeAll: number;
166
326
  /**
167
- * @deprecated You can define sound assets directly in `PIXI.Assets`
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
- add(alias: string, options: string): Sound;
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
- * @return The sound instance,
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<IMediaInstance>;
179
- play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptionsWithChannel): Promise<IMediaInstance>;
345
+ play(alias: string, options?: SoundPlayOptionsWithChannel): Promise<MediaInterface>;
346
+ play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptionsWithChannel): Promise<MediaInterface>;
180
347
  /**
181
- * Find a media by alias.
182
- * @param alias - The media alias reference.
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
- find(alias: string): IMediaInstance | undefined;
351
+ playTransient(alias: string, options?: Partial<PlayerOptions>): Promise<Player>;
186
352
  /**
187
- * Stops a media and removes it from the manager.
188
- * @param alias - The media alias reference.
353
+ * Find a tracked media instance by alias.
189
354
  */
190
- stop(alias: string): void;
355
+ find(alias: string): MediaInterface | undefined;
191
356
  /**
192
- * Pauses a media.
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
- pause(alias: string): IMediaInstance | undefined;
359
+ stop(alias: string): void;
197
360
  /**
198
- * Resumes a media.
199
- * @param alias - The media alias reference.
200
- * @return Media object.
361
+ * Pause a tracked media instance.
201
362
  */
202
- resume(alias: string): IMediaInstance | undefined;
363
+ pause(alias: string): MediaInterface | undefined;
203
364
  /**
204
- * Edits the options of an existing sound (asset).
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
- edit(alias: string, options: SoundOptions): Promise<void>;
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
- * Pauses any playing sounds.
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
- * Mutes all playing sounds.
220
- * @return Instance for chaining.
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
- muteAll(): this;
398
+ pauseUnsavedAll(channel?: string): this;
223
399
  /**
224
- * Unmutes all playing sounds.
225
- * @return Instance for chaining.
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
- unmuteAll(): this;
404
+ resumeUnsavedAll(channel?: string): this;
228
405
  /**
229
- * Stops all sounds.
230
- * @return Instance for chaining.
406
+ * Stop all transient media instances started with {@link playTransient}.
231
407
  */
232
- stopAll(): this;
233
- load(alias: string | string[]): Promise<Sound[]>;
234
- backgroundLoad(alias: string | string[]): Promise<void>;
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
- * Adds a new audio channel with the specified alias(es).
239
- * @param alias The alias or aliases for the new channel.
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
- * Finds and returns the audio channel associated with the given alias. If the channel does not exist, it will be created.
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
- * The default channel alias to use when playing a sound without specifying a channel.
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
- declare const filters: {
263
- DistortionFilter: typeof filters$1.DistortionFilter;
264
- EqualizerFilter: typeof filters$1.EqualizerFilter;
265
- MonoFilter: typeof filters$1.MonoFilter;
266
- ReverbFilter: typeof filters$1.ReverbFilter;
267
- StereoFilter: typeof filters$1.StereoFilter;
268
- StreamFilter: typeof filters$1.StreamFilter;
269
- TelephoneFilter: typeof filters$1.TelephoneFilter;
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
- declare class SoundManagerStatic {
273
- private constructor();
274
- static mediaInstances: {
275
- [alias: string]: {
276
- channelAlias: string;
277
- soundAlias: string;
278
- instance: IMediaInstance;
279
- stepCounter: number;
280
- options: SoundPlayOptions;
281
- };
282
- };
283
- static channels: {
284
- [alias: string]: AudioChannelInterface;
285
- };
286
- static delayTimeoutInstances: [number | NodeJS.Timeout, string][];
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 IMediaInstance, type SoundFilterMemory, type SoundGameState, SoundManagerStatic, type SoundOptions, type SoundPlay, type SoundPlayOptions, type SoundPlayOptionsWithChannel, filters, sound };
496
+ export { type AudioChannelInterface, type ChannelOptions, type ExportedSound, type ExportedSoundPlay, type MediaInterface, type SoundGameState, type SoundOptions, type SoundPlay, type SoundPlayOptions, type SoundPlayOptionsWithChannel, SoundRegistry, sound };