@drincs/pixi-vn 1.7.2 → 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/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.mjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-X4NBVTSJ.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.d.cts +1 -1
- package/dist/history.d.ts +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +272 -166
- package/dist/index.d.ts +272 -166
- package/dist/index.mjs +2 -2
- 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/sound.cjs +1 -1
- package/dist/sound.d.cts +326 -181
- package/dist/sound.d.ts +326 -181
- package/dist/sound.mjs +1 -1
- package/dist/storage.mjs +1 -1
- package/package.json +11 -8
- package/dist/chunk-4KCAZKAJ.mjs +0 -1
- package/dist/chunk-HNGW4ITF.mjs +0 -1
- package/dist/chunk-YDNEIPJP.mjs +0 -1
package/dist/sound.d.ts
CHANGED
|
@@ -1,32 +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.js';
|
|
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;
|
|
12
67
|
/**
|
|
13
|
-
*
|
|
68
|
+
* The offset in seconds from the start of the sound at which to begin playback.
|
|
14
69
|
*/
|
|
15
|
-
|
|
70
|
+
elapsed?: number;
|
|
16
71
|
}
|
|
17
72
|
interface SoundPlayOptionsWithChannel extends SoundPlayOptions {
|
|
18
73
|
/**
|
|
19
|
-
* The alias of the audio channel to play the sound on. If the channel does
|
|
20
|
-
*
|
|
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").
|
|
21
77
|
*/
|
|
22
78
|
channel?: string;
|
|
23
79
|
}
|
|
24
|
-
interface ChannelOptions extends Pick<SoundPlayOptions, "filters" | "muted" | "volume"
|
|
80
|
+
interface ChannelOptions extends Pick<SoundPlayOptions, "filters" | "muted" | "volume"> {
|
|
25
81
|
/**
|
|
26
82
|
* Whether this channel is a background channel.
|
|
27
|
-
* 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.
|
|
28
85
|
*/
|
|
29
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;
|
|
30
93
|
}
|
|
31
94
|
|
|
32
95
|
interface AudioChannelInterface {
|
|
@@ -42,7 +105,7 @@ interface AudioChannelInterface {
|
|
|
42
105
|
* this cannot be reused after it is done playing. Returns a Promise if the sound
|
|
43
106
|
* has not yet loaded.
|
|
44
107
|
*/
|
|
45
|
-
play(alias: string, options?: SoundPlayOptions): Promise<
|
|
108
|
+
play(alias: string, options?: SoundPlayOptions): Promise<MediaInterface>;
|
|
46
109
|
/**
|
|
47
110
|
* Plays a sound.
|
|
48
111
|
* @param mediaAlias The media alias reference.
|
|
@@ -52,22 +115,12 @@ interface AudioChannelInterface {
|
|
|
52
115
|
* this cannot be reused after it is done playing. Returns a Promise if the sound
|
|
53
116
|
* has not yet loaded.
|
|
54
117
|
*/
|
|
55
|
-
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptions): Promise<
|
|
56
|
-
/**
|
|
57
|
-
* Plays a non-persistent sound on this channel.
|
|
58
|
-
* The returned media is not tracked by the sound manager and is therefore excluded from save/export state.
|
|
59
|
-
* @param soundAlias The sound (asset) alias reference.
|
|
60
|
-
* @param options The options.
|
|
61
|
-
* @return The sound instance.
|
|
62
|
-
*/
|
|
63
|
-
playTransient(soundAlias: string, options?: SoundPlayOptions): Promise<IMediaInstance>;
|
|
118
|
+
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptions): Promise<MediaInterface>;
|
|
64
119
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* those that are still playing or paused.
|
|
68
|
-
* @return Instance for chaining.
|
|
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.
|
|
69
122
|
*/
|
|
70
|
-
|
|
123
|
+
pan: number;
|
|
71
124
|
/**
|
|
72
125
|
* The volume of the audio channel, between 0 and 1. This is multiplied with the volume of each sound played through this channel.
|
|
73
126
|
*/
|
|
@@ -79,7 +132,7 @@ interface AudioChannelInterface {
|
|
|
79
132
|
/**
|
|
80
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.
|
|
81
134
|
*/
|
|
82
|
-
readonly mediaInstances:
|
|
135
|
+
readonly mediaInstances: MediaInterface[];
|
|
83
136
|
/**
|
|
84
137
|
* Whether this channel is a background channel.
|
|
85
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.
|
|
@@ -95,17 +148,6 @@ interface AudioChannelInterface {
|
|
|
95
148
|
* @return Instance for chaining.
|
|
96
149
|
*/
|
|
97
150
|
pauseAll(): this;
|
|
98
|
-
/**
|
|
99
|
-
* Temporarily pauses this channel without mutating each media instance's persisted paused option.
|
|
100
|
-
* Useful for overlays (for example settings/pause menus) where pause state must not be saved.
|
|
101
|
-
* @return Instance for chaining.
|
|
102
|
-
*/
|
|
103
|
-
pauseUnsavedAll(): this;
|
|
104
|
-
/**
|
|
105
|
-
* Restores this channel after `pauseUnsavedAll()`, reapplying each media instance's persisted paused option.
|
|
106
|
-
* @return Instance for chaining.
|
|
107
|
-
*/
|
|
108
|
-
resumeUnsavedAll(): this;
|
|
109
151
|
/**
|
|
110
152
|
* Resumes any sounds.
|
|
111
153
|
* @return Instance for chaining.
|
|
@@ -116,45 +158,128 @@ interface AudioChannelInterface {
|
|
|
116
158
|
* @return `true` if all sounds are muted.
|
|
117
159
|
*/
|
|
118
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">;
|
|
119
228
|
}
|
|
120
229
|
|
|
121
|
-
type
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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">);
|
|
158
283
|
|
|
159
284
|
interface ExportedSound {
|
|
160
285
|
options: SoundOptions;
|
|
@@ -172,7 +297,6 @@ interface ExportedSoundPlay extends SoundPlay {
|
|
|
172
297
|
* Interface exported sounds
|
|
173
298
|
*/
|
|
174
299
|
interface SoundGameState {
|
|
175
|
-
filters?: SoundFilterMemory[];
|
|
176
300
|
/**
|
|
177
301
|
* @deprecated
|
|
178
302
|
*/
|
|
@@ -184,8 +308,9 @@ interface SoundGameState {
|
|
|
184
308
|
channelAlias: string;
|
|
185
309
|
soundAlias: string;
|
|
186
310
|
stepCounter: number;
|
|
187
|
-
options:
|
|
311
|
+
options: MediaMemory & {
|
|
188
312
|
filters?: SoundFilterMemory[];
|
|
313
|
+
delay?: number;
|
|
189
314
|
};
|
|
190
315
|
/**
|
|
191
316
|
* @deprecated Use options.paused instead.
|
|
@@ -195,157 +320,177 @@ interface SoundGameState {
|
|
|
195
320
|
};
|
|
196
321
|
}
|
|
197
322
|
|
|
198
|
-
interface SoundManagerInterface
|
|
323
|
+
interface SoundManagerInterface {
|
|
324
|
+
/** Master volume in the range [0, 1]. */
|
|
325
|
+
volumeAll: number;
|
|
199
326
|
/**
|
|
200
|
-
* @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.
|
|
201
328
|
*/
|
|
202
|
-
|
|
329
|
+
speedAll: number;
|
|
203
330
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
*
|
|
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.
|
|
210
337
|
*/
|
|
211
|
-
|
|
212
|
-
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptionsWithChannel): Promise<IMediaInstance>;
|
|
338
|
+
add(alias: string, options: string): void;
|
|
213
339
|
/**
|
|
214
|
-
* Plays a
|
|
215
|
-
*
|
|
216
|
-
* @param alias The sound (asset) alias reference.
|
|
340
|
+
* Plays a sound.
|
|
341
|
+
* @param alias The media and sound (asset) alias reference.
|
|
217
342
|
* @param options The options.
|
|
218
|
-
* @
|
|
343
|
+
* @returns The media instance (resolves immediately if already loaded).
|
|
219
344
|
*/
|
|
220
|
-
|
|
345
|
+
play(alias: string, options?: SoundPlayOptionsWithChannel): Promise<MediaInterface>;
|
|
346
|
+
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptionsWithChannel): Promise<MediaInterface>;
|
|
221
347
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* otherwise all channels are affected.
|
|
225
|
-
* @param channel Optional channel alias to limit the operation to.
|
|
226
|
-
* @return Instance for chaining.
|
|
348
|
+
* Plays a non-persistent ("transient") sound (e.g. UI / menu sounds).
|
|
349
|
+
* Transient playback is not tracked in save/export state.
|
|
227
350
|
*/
|
|
228
|
-
|
|
351
|
+
playTransient(alias: string, options?: Partial<PlayerOptions>): Promise<Player>;
|
|
229
352
|
/**
|
|
230
|
-
* Find a media by alias.
|
|
231
|
-
* @param alias - The media alias reference.
|
|
232
|
-
* @return Media object.
|
|
353
|
+
* Find a tracked media instance by alias.
|
|
233
354
|
*/
|
|
234
|
-
find(alias: string):
|
|
355
|
+
find(alias: string): MediaInterface | undefined;
|
|
235
356
|
/**
|
|
236
|
-
*
|
|
237
|
-
* @param alias - The media alias reference.
|
|
357
|
+
* Stop a tracked media instance and remove it from the manager.
|
|
238
358
|
*/
|
|
239
359
|
stop(alias: string): void;
|
|
240
360
|
/**
|
|
241
|
-
*
|
|
242
|
-
* @param alias - The media alias reference.
|
|
243
|
-
* @return Media object.
|
|
361
|
+
* Pause a tracked media instance.
|
|
244
362
|
*/
|
|
245
|
-
pause(alias: string):
|
|
363
|
+
pause(alias: string): MediaInterface | undefined;
|
|
246
364
|
/**
|
|
247
|
-
*
|
|
248
|
-
* @param alias - The media alias reference.
|
|
249
|
-
* @return Media object.
|
|
365
|
+
* Resume a paused media instance.
|
|
250
366
|
*/
|
|
251
|
-
resume(alias: string):
|
|
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;
|
|
252
372
|
/**
|
|
253
|
-
*
|
|
254
|
-
* If the asset is not yet loaded, it will be loaded with the new options.
|
|
255
|
-
*/
|
|
256
|
-
edit(alias: string, options: SoundOptions): Promise<void>;
|
|
257
|
-
/**
|
|
258
|
-
* Pauses any playing sounds.
|
|
259
|
-
* @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.
|
|
260
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. */
|
|
261
383
|
pauseAll(): this;
|
|
262
|
-
/**
|
|
263
|
-
* Resumes any sounds.
|
|
264
|
-
* @return Instance for chaining.
|
|
265
|
-
*/
|
|
384
|
+
/** Resume all sounds. */
|
|
266
385
|
resumeAll(): this;
|
|
267
386
|
/**
|
|
268
|
-
* Temporarily
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
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.
|
|
273
397
|
*/
|
|
274
398
|
pauseUnsavedAll(channel?: string): this;
|
|
275
399
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
* @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.
|
|
280
403
|
*/
|
|
281
404
|
resumeUnsavedAll(channel?: string): this;
|
|
282
405
|
/**
|
|
283
|
-
*
|
|
284
|
-
* @return Instance for chaining.
|
|
285
|
-
*/
|
|
286
|
-
muteAll(): this;
|
|
287
|
-
/**
|
|
288
|
-
* Unmutes all playing sounds.
|
|
289
|
-
* @return Instance for chaining.
|
|
290
|
-
*/
|
|
291
|
-
unmuteAll(): this;
|
|
292
|
-
/**
|
|
293
|
-
* Stops all sounds.
|
|
294
|
-
* @return Instance for chaining.
|
|
406
|
+
* Stop all transient media instances started with {@link playTransient}.
|
|
295
407
|
*/
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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. */
|
|
299
414
|
backgroundLoadBundle(alias: string): Promise<void>;
|
|
415
|
+
/** Stop all sounds and clear internal state. */
|
|
300
416
|
clear(): void;
|
|
301
417
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* @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.
|
|
305
420
|
*/
|
|
306
421
|
addChannel(alias: string | string[], options?: ChannelOptions): AudioChannelInterface | undefined;
|
|
307
422
|
/**
|
|
308
|
-
*
|
|
309
|
-
* @param alias The alias of the audio channel to find.
|
|
310
|
-
* @returns The AudioChannelInterface instance associated with the alias.
|
|
423
|
+
* Find the channel for the given alias, creating it if it does not yet exist.
|
|
311
424
|
*/
|
|
312
425
|
findChannel(alias: string): AudioChannelInterface;
|
|
313
|
-
/**
|
|
314
|
-
* Returns an array of all existing audio channels.
|
|
315
|
-
*/
|
|
426
|
+
/** All registered audio channels. */
|
|
316
427
|
readonly channels: AudioChannelInterface[];
|
|
317
428
|
/**
|
|
318
|
-
*
|
|
319
|
-
* 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.
|
|
320
430
|
*/
|
|
321
|
-
defaultChannelAlias: string;
|
|
322
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
|
+
*/
|
|
323
435
|
restore(data: object): Promise<void>;
|
|
324
436
|
}
|
|
325
437
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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
|
+
}
|
|
335
473
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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>;
|
|
347
489
|
}
|
|
348
490
|
|
|
491
|
+
/**
|
|
492
|
+
* The singleton sound manager instance. Use this to play and manage sounds in your game.
|
|
493
|
+
*/
|
|
349
494
|
declare const sound: SoundManagerInterface;
|
|
350
495
|
|
|
351
|
-
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 };
|