@schmooky/zvuk 0.0.0-develop-20260503095453 → 0.0.0-feat-codec-network-fallback-20260505104144
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 +157 -40
- package/dist/index.d.ts +55 -19
- package/dist/index.js +143 -39
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @schmooky/zvuk
|
|
4
|
+
|
|
5
|
+
**Audio Engine for the Web** — Wwise-grade routing, audio sprites, sidechain ducking, snapshots, in a tiny ESM package.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@schmooky/zvuk)
|
|
8
|
+
[](https://bundlephobia.com/package/@schmooky/zvuk)
|
|
9
|
+
[](https://www.npmjs.com/package/@schmooky/zvuk)
|
|
10
|
+
[](./LICENSE)
|
|
11
|
+
[](https://github.com/schmooky/zvuk/actions/workflows/ci.yml)
|
|
12
|
+
|
|
13
|
+
[**Documentation**](https://zvuk.schmooky.dev/docs/) · [**Concepts**](https://zvuk.schmooky.dev/concepts/) · [**API**](https://zvuk.schmooky.dev/api/) · [**Roadmap**](https://zvuk.schmooky.dev/roadmap/) · [**llms.txt**](https://zvuk.schmooky.dev/llms.txt)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Install
|
|
4
20
|
|
|
5
21
|
```bash
|
|
6
22
|
pnpm add @schmooky/zvuk
|
|
@@ -14,72 +30,173 @@ const engine = createEngine({
|
|
|
14
30
|
music: { level: 0.8 },
|
|
15
31
|
sfx: { level: 1.0 },
|
|
16
32
|
},
|
|
17
|
-
master: { headroom: -3 },
|
|
33
|
+
master: { headroom: -3, limiter: { threshold: -1 } },
|
|
18
34
|
});
|
|
19
35
|
|
|
20
|
-
await engine.unlock();
|
|
21
|
-
await engine.loadSound('coin', '/sfx/coin.
|
|
36
|
+
await engine.unlock(); // call from a user gesture
|
|
37
|
+
await engine.loadSound('coin', '/sfx/coin.webm', { bus: 'sfx' });
|
|
22
38
|
|
|
23
39
|
const v = engine.sound('coin').play({ volume: { jitter: 0.05 } });
|
|
24
|
-
await v.fade({ to: 0,
|
|
40
|
+
await v.fade({ to: 0, duration: 0.8 });
|
|
41
|
+
|
|
42
|
+
engine.bus('music').fadeTo(0.1, 0.8);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
> All time-valued options in zvuk are **seconds** (matching the Web Audio API).
|
|
46
|
+
|
|
47
|
+
## Why zvuk?
|
|
48
|
+
|
|
49
|
+
`HTMLAudioElement` doesn't scale past one menu sound. The Web Audio API does, but you end up writing your own bus graph, your own scheduler, your own iOS unlock dance, your own codec ladder, your own sidechain envelope, your own snapshot crossfader — every time.
|
|
50
|
+
|
|
51
|
+
zvuk is the layer above. It gives you the routing primitives a real game audio team uses (Wwise / FMOD / RAD) without a 60 MB editor, behind an API surface small enough to fit in your head. ESM-only, type-safe, no dependencies beyond `eventemitter3`, ~16 KB min+gzip.
|
|
52
|
+
|
|
53
|
+
## Features
|
|
25
54
|
|
|
26
|
-
|
|
55
|
+
| Mixer | FX | Loading | DX |
|
|
56
|
+
| --- | --- | --- | --- |
|
|
57
|
+
| Named buses with FX inserts | Compressor (DynamicsCompressor + makeup) | Codec ladder (`['x.webm', 'x.m4a']`) | Lazy AudioContext (no constructor side-effects) |
|
|
58
|
+
| Master headroom + brick-wall limiter | Filter (BiquadFilter, all 6 modes) | Audio sprites (one buffer, N regions) | iOS Safari unlock + visibility resume |
|
|
59
|
+
| Voice concurrency + stealing | Reverb (convolution + synthetic IR) | Stream long media via MediaElementSource | Sample-accurate scheduler |
|
|
60
|
+
| Sidechain ducking (Ducker) | Time-stretch (offline SOLA + realtime Worklet) | Loudness normalization on load | Async cues iterator on every Voice |
|
|
61
|
+
| Snapshots — capture & crossfade the mix | Spatializer (2D pan + 3D HRTF) | AbortSignal cancellation | "Did you mean…" on bus/sound name typos |
|
|
62
|
+
|
|
63
|
+
## Examples
|
|
64
|
+
|
|
65
|
+
### Audio sprites — one buffer, many regions
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
await engine.loadSprite('cascade', '/sfx/cascade.webm', {
|
|
69
|
+
small: { start: 0, duration: 0.2 },
|
|
70
|
+
medium: { start: 0.25, duration: 0.4 },
|
|
71
|
+
big: { start: 0.7, duration: 0.6 },
|
|
72
|
+
}, { bus: 'sfx' });
|
|
73
|
+
|
|
74
|
+
engine.sprite('cascade').play('medium', { volume: { jitter: 0.05 } });
|
|
27
75
|
```
|
|
28
76
|
|
|
29
|
-
|
|
77
|
+
### Stream long media (don't decode 4 minutes into RAM)
|
|
30
78
|
|
|
79
|
+
```ts
|
|
80
|
+
const intro = engine.loadStream('intro', '/music/intro.m4a', { bus: 'music' });
|
|
81
|
+
await intro.play({ loop: true, volume: 0.6 });
|
|
31
82
|
```
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
83
|
+
|
|
84
|
+
### Crossfade music tracks (equal-power)
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
await engine.loadSound('intro', '/music/intro.webm', { bus: 'music' });
|
|
88
|
+
await engine.loadSound('main', '/music/main.webm', { bus: 'music' });
|
|
89
|
+
|
|
90
|
+
engine.sound('intro').play({ loop: true });
|
|
91
|
+
engine.crossfade('intro', 'main', { duration: 1.5 });
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Sidechain ducking — music breathes under VO
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { Ducker } from '@schmooky/zvuk';
|
|
98
|
+
|
|
99
|
+
const ducker = new Ducker(engine.context, {
|
|
100
|
+
source: engine.bus('voice').output,
|
|
101
|
+
target: engine.bus('music'),
|
|
102
|
+
amount: 0.7, attack: 0.08, release: 0.6,
|
|
103
|
+
});
|
|
104
|
+
engine.bus('music').addFx(ducker);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Live spatial audio — hold the Voice, steer it per-frame
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const v = engine.sound('engine-loop').play({
|
|
111
|
+
loop: true,
|
|
112
|
+
spatializer: { position: [0, 0, 0] },
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
requestAnimationFrame(function tick() {
|
|
116
|
+
v.spatializer?.setPosition(player.x, 0, player.z);
|
|
117
|
+
requestAnimationFrame(tick);
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Snapshots — capture the mix, crossfade back to it
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
const calm = engine.captureSnapshot('calm');
|
|
125
|
+
|
|
126
|
+
engine.bus('music').fadeTo(0.2, 0.2);
|
|
127
|
+
engine.bus('voice').fadeTo(1.5, 0.2);
|
|
128
|
+
|
|
129
|
+
await calm.apply({ fade: 0.6 }); // restore everything in one call
|
|
37
130
|
```
|
|
38
131
|
|
|
39
|
-
|
|
40
|
-
|
|
132
|
+
## Browser support
|
|
133
|
+
|
|
134
|
+
| Browser | Minimum | Notes |
|
|
135
|
+
| -------------------- | ------- | ----- |
|
|
136
|
+
| Chrome, Edge, Opera | 76+ | Opus + AAC, AudioWorklet, HRTF Spatializer |
|
|
137
|
+
| Firefox | 88+ | Opus + AAC |
|
|
138
|
+
| Safari macOS | 14.1+ | Opus from 14.5; pickSource falls back to AAC on older |
|
|
139
|
+
| Safari iOS | 14.5+ | Same — bundle a webm + m4a pair via the codec ladder |
|
|
140
|
+
|
|
141
|
+
zvuk is ESM-only and assumes a working `AudioContext`. No polyfills; no shims for IE.
|
|
142
|
+
|
|
143
|
+
## Documentation
|
|
144
|
+
|
|
145
|
+
- **[Quickstart](https://zvuk.schmooky.dev/docs/quickstart/)** — running in 30 lines
|
|
146
|
+
- **[Concepts](https://zvuk.schmooky.dev/concepts/)** — Engine, Bus, Sound, Voice, Snapshot, Spatializer, Concurrency
|
|
147
|
+
- **[FX](https://zvuk.schmooky.dev/fx/)** — Compressor, Filter, Reverb, Pitch & time-stretch, Ducker
|
|
148
|
+
- **[Guides](https://zvuk.schmooky.dev/guides/)** — asset formats, loading, mix building, ducking, migrating from Howler
|
|
149
|
+
- **[Recipes](https://zvuk.schmooky.dev/recipes/)** — short, copy-paste-ready solutions
|
|
150
|
+
- **[API reference](https://zvuk.schmooky.dev/api/)** — auto-generated TypeDoc, regenerated each build
|
|
151
|
+
- **[llms.txt](https://zvuk.schmooky.dev/llms.txt)** — agent-readable index of the entire site
|
|
41
152
|
|
|
42
153
|
## Working in this repo
|
|
43
154
|
|
|
44
155
|
```bash
|
|
45
156
|
pnpm install
|
|
46
|
-
pnpm test
|
|
47
|
-
pnpm typecheck
|
|
48
|
-
pnpm
|
|
49
|
-
pnpm
|
|
157
|
+
pnpm test # vitest, happy-dom + Web Audio mock
|
|
158
|
+
pnpm typecheck # tsc --noEmit across src/ and test/
|
|
159
|
+
pnpm lint # biome check
|
|
160
|
+
pnpm build # tsup → dist/index.js + dist/cli.js + dist/index.d.ts
|
|
161
|
+
pnpm docs:dev # astro dev at http://localhost:4321
|
|
162
|
+
pnpm docs:build # astro + pagefind index + OG cards + llms.txt
|
|
163
|
+
pnpm bench # vitest bench/
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The package's `exports` field resolves to `src/index.ts` for workspace consumers. `publishConfig` overrides it to `dist/...` at publish time so npm consumers get the compiled artifact. Concept pages embed live React-island demos that drive the real engine — no mocks.
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
zvuk/
|
|
170
|
+
├── src/ package source
|
|
171
|
+
├── test/ vitest suite
|
|
172
|
+
├── bench/ vitest bench/
|
|
173
|
+
├── examples/ vanilla deployable demos (slot-machine, match-3, fps-footsteps)
|
|
174
|
+
├── docs/ Astro site → zvuk.schmooky.dev
|
|
175
|
+
└── tsup.config.ts ESM build config
|
|
50
176
|
```
|
|
51
177
|
|
|
52
|
-
|
|
178
|
+
## Release flow
|
|
53
179
|
|
|
54
|
-
|
|
55
|
-
- `pnpm typecheck` — `tsc --noEmit` across `src/` and `test/`.
|
|
56
|
-
- `pnpm build` — tsup bundles `dist/index.js` + `dist/index.d.ts`.
|
|
57
|
-
- `pnpm docs:dev` — Astro dev server at http://localhost:4321. Reads the
|
|
58
|
-
package source directly via the `src/index.ts` exports — no prior `pnpm build` needed.
|
|
180
|
+
Releases are driven by [Changesets](https://github.com/changesets/changesets) on every push to `main`:
|
|
59
181
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
182
|
+
1. Add a changeset describing your change: `pnpm changeset`
|
|
183
|
+
2. Open a PR; CI gates on lint + typecheck + tests + lib build + docs build.
|
|
184
|
+
3. On merge to `main`, the release workflow opens (or updates) a `Version Packages` PR that bumps the version and regenerates `CHANGELOG.md`.
|
|
185
|
+
4. Merging that PR publishes to npm with provenance attestation and creates a GitHub Release.
|
|
63
186
|
|
|
64
|
-
|
|
187
|
+
For per-branch preview publishes on non-`main` branches, a snapshot workflow auto-publishes under a sanitized branch dist-tag — install with `pnpm add @schmooky/zvuk@<branch>`.
|
|
65
188
|
|
|
66
|
-
|
|
189
|
+
## CLI
|
|
67
190
|
|
|
68
191
|
```bash
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
git push # PR + merge to main
|
|
192
|
+
npx @schmooky/zvuk transcode raw/*.wav # ffmpeg ladder → webm/opus + m4a/aac
|
|
193
|
+
npx @schmooky/zvuk gen bank.json # typed sound-name module from a manifest
|
|
72
194
|
```
|
|
73
195
|
|
|
74
196
|
## Credits
|
|
75
197
|
|
|
76
|
-
The demo audio shipped under [docs/public/audio/](docs/public/audio/)
|
|
77
|
-
selections from [Kenney's "Digital Audio" pack](https://kenney.nl/assets/digital-audio),
|
|
78
|
-
released under [CC0](https://creativecommons.org/publicdomain/zero/1.0/) — used here
|
|
79
|
-
without modification. Kenney's full license file is preserved alongside those assets in
|
|
80
|
-
[docs/public/audio/KENNEY-LICENSE.txt](docs/public/audio/KENNEY-LICENSE.txt). All other
|
|
81
|
-
audio in the repo is original to this project.
|
|
198
|
+
The demo audio shipped under [`docs/public/audio/`](docs/public/audio/) includes selections from [Kenney's Digital Audio pack](https://kenney.nl/assets/digital-audio), released under [CC0](https://creativecommons.org/publicdomain/zero/1.0/) and used here without modification. Kenney's full license file is preserved at [`docs/public/audio/KENNEY-LICENSE.txt`](docs/public/audio/KENNEY-LICENSE.txt). All other audio is original to this project.
|
|
82
199
|
|
|
83
200
|
## License
|
|
84
201
|
|
|
85
|
-
MIT
|
|
202
|
+
[MIT](./LICENSE) © schmooky
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,19 @@ declare class BankNotLoadedError extends ZvukError {
|
|
|
16
16
|
declare class DecodeError extends ZvukError {
|
|
17
17
|
constructor(url: string, cause: unknown);
|
|
18
18
|
}
|
|
19
|
+
interface DecodeAttempt {
|
|
20
|
+
readonly url: string;
|
|
21
|
+
readonly cause: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Thrown when every URL in a fallback list fails to load. Subclass of
|
|
25
|
+
* DecodeError so existing `catch (e instanceof DecodeError)` paths still
|
|
26
|
+
* fire — `attempts` exposes the per-URL causes for diagnostics.
|
|
27
|
+
*/
|
|
28
|
+
declare class AggregateDecodeError extends DecodeError {
|
|
29
|
+
readonly attempts: readonly DecodeAttempt[];
|
|
30
|
+
constructor(urls: readonly string[], attempts: readonly DecodeAttempt[]);
|
|
31
|
+
}
|
|
19
32
|
|
|
20
33
|
/**
|
|
21
34
|
* Common FX insert contract. Every FX exposes a single input + a single
|
|
@@ -78,9 +91,9 @@ interface SidechainConfig {
|
|
|
78
91
|
from: string;
|
|
79
92
|
/** Amount of duck (0..1, where 1 = fully muted at peak source). */
|
|
80
93
|
amount: number;
|
|
81
|
-
/** Attack
|
|
94
|
+
/** Attack in seconds. */
|
|
82
95
|
attack?: number;
|
|
83
|
-
/** Release
|
|
96
|
+
/** Release in seconds. */
|
|
84
97
|
release?: number;
|
|
85
98
|
}
|
|
86
99
|
interface BusConfig {
|
|
@@ -111,7 +124,8 @@ interface EngineConfig {
|
|
|
111
124
|
}
|
|
112
125
|
interface FadeOptions {
|
|
113
126
|
to: number;
|
|
114
|
-
|
|
127
|
+
/** Fade duration in seconds. */
|
|
128
|
+
duration: number;
|
|
115
129
|
curve?: FadeCurve;
|
|
116
130
|
}
|
|
117
131
|
interface VoiceJitter {
|
|
@@ -247,7 +261,7 @@ declare class Voice {
|
|
|
247
261
|
* Setting while paused only updates the value used on the next start.
|
|
248
262
|
*/
|
|
249
263
|
setPlaybackRate(rate: number, opts?: {
|
|
250
|
-
|
|
264
|
+
duration?: number;
|
|
251
265
|
curve?: FadeOptions['curve'];
|
|
252
266
|
}): void;
|
|
253
267
|
get playbackRate(): number;
|
|
@@ -270,7 +284,8 @@ declare class Voice {
|
|
|
270
284
|
* Voices are connected to bus.input. The master receives bus.output.
|
|
271
285
|
*
|
|
272
286
|
* level/mute use 10ms ramps to avoid clicks; raw gain.value writes would
|
|
273
|
-
* pop audibly on browsers that don't smooth the parameter.
|
|
287
|
+
* pop audibly on browsers that don't smooth the parameter. Public time
|
|
288
|
+
* arguments (fadeTo) are seconds.
|
|
274
289
|
*/
|
|
275
290
|
declare class Bus {
|
|
276
291
|
readonly name: string;
|
|
@@ -291,7 +306,8 @@ declare class Bus {
|
|
|
291
306
|
set level(v: number);
|
|
292
307
|
get muted(): boolean;
|
|
293
308
|
set muted(v: boolean);
|
|
294
|
-
|
|
309
|
+
/** Fade the bus output to `target` over `duration` seconds. */
|
|
310
|
+
fadeTo(target: number, duration: number, curve?: FadeCurve): Promise<void>;
|
|
295
311
|
/** Active voice count on this bus. */
|
|
296
312
|
get voiceCount(): number;
|
|
297
313
|
/** Read-only iterator over active voices. */
|
|
@@ -323,9 +339,9 @@ declare class Bus {
|
|
|
323
339
|
interface DuckerConfig {
|
|
324
340
|
/** How much to attenuate when fully ducking (0..1). Default 0.5 = -6 dB. */
|
|
325
341
|
amount?: number;
|
|
326
|
-
/** Attack
|
|
342
|
+
/** Attack in seconds. Default 0.08. */
|
|
327
343
|
attack?: number;
|
|
328
|
-
/** Release
|
|
344
|
+
/** Release in seconds. Default 0.4. */
|
|
329
345
|
release?: number;
|
|
330
346
|
/** Threshold (linear amplitude) on the source bus's RMS to trigger ducking. Default 0.05. */
|
|
331
347
|
threshold?: number;
|
|
@@ -354,6 +370,7 @@ declare class Ducker implements FxInsert {
|
|
|
354
370
|
private ctx;
|
|
355
371
|
private cfg;
|
|
356
372
|
private _bypassed;
|
|
373
|
+
private sourceBus;
|
|
357
374
|
constructor(ctx: AudioContext, sourceBus: Bus, config?: DuckerConfig);
|
|
358
375
|
setAmount(a: number): void;
|
|
359
376
|
setThreshold(t: number): void;
|
|
@@ -510,7 +527,7 @@ declare class Parameter {
|
|
|
510
527
|
}): () => void;
|
|
511
528
|
}
|
|
512
529
|
|
|
513
|
-
type EngineState = 'cold' | 'unlocking' | 'live' | 'closed';
|
|
530
|
+
type EngineState = 'cold' | 'unlocking' | 'live' | 'interrupted' | 'closed';
|
|
514
531
|
|
|
515
532
|
interface SoundDeps {
|
|
516
533
|
ctx: AudioContext;
|
|
@@ -622,12 +639,12 @@ interface SnapshotState {
|
|
|
622
639
|
parameters: Record<string, number>;
|
|
623
640
|
}
|
|
624
641
|
interface ApplyOptions {
|
|
625
|
-
/** Crossfade duration in
|
|
626
|
-
|
|
642
|
+
/** Crossfade duration in seconds. Default 0 (snap). */
|
|
643
|
+
fade?: number;
|
|
627
644
|
}
|
|
628
645
|
/**
|
|
629
646
|
* A captured mix-state preset. Capture it once with the engine in a known
|
|
630
|
-
* good state ("menu mood"), then `apply({
|
|
647
|
+
* good state ("menu mood"), then `apply({ fade: 0.25 })` to crossfade the
|
|
631
648
|
* entire mix back to that snapshot — bus levels, mutes, parameter values,
|
|
632
649
|
* everything in one call.
|
|
633
650
|
*
|
|
@@ -654,8 +671,15 @@ interface Engine {
|
|
|
654
671
|
* Load and decode an audio asset.
|
|
655
672
|
*
|
|
656
673
|
* Pass an array of URLs to ship a codec ladder — e.g. ['coin.webm', 'coin.m4a'].
|
|
657
|
-
* The
|
|
658
|
-
*
|
|
674
|
+
* The list is walked in order (codecs the browser claims it can play
|
|
675
|
+
* float to the front), and the first URL that successfully fetches AND
|
|
676
|
+
* decodes wins. A 404, network error, or decode failure on one URL falls
|
|
677
|
+
* through to the next — so a broken CDN entry or under-reported codec
|
|
678
|
+
* doesn't bring the whole sound down.
|
|
679
|
+
*
|
|
680
|
+
* If every URL fails, throws AggregateDecodeError (a subclass of
|
|
681
|
+
* DecodeError) with per-URL causes attached. If only one URL was given,
|
|
682
|
+
* the underlying DecodeError is rethrown verbatim.
|
|
659
683
|
*/
|
|
660
684
|
loadSound(name: string, url: string | readonly string[], options?: LoadSoundOptions): Promise<Sound>;
|
|
661
685
|
/** Register a Sound from an AudioBuffer you constructed yourself (procedural, custom-decoded, time-stretched). */
|
|
@@ -686,8 +710,9 @@ interface Engine {
|
|
|
686
710
|
sound(name: string): Sound;
|
|
687
711
|
bus(name: string): Bus;
|
|
688
712
|
/**
|
|
689
|
-
* Crossfade helper. Stops `from` over `
|
|
690
|
-
* window with `equal-power` curves so the perceived loudness
|
|
713
|
+
* Crossfade helper. Stops `from` over `duration` seconds while playing `to`
|
|
714
|
+
* over the same window with `equal-power` curves so the perceived loudness
|
|
715
|
+
* stays flat.
|
|
691
716
|
*
|
|
692
717
|
* Returns the new Voice. If `to` is already playing, its level is faded up
|
|
693
718
|
* from 0 instead of starting fresh.
|
|
@@ -705,8 +730,8 @@ interface Engine {
|
|
|
705
730
|
snapshot(name: string, state: SnapshotState): Snapshot;
|
|
706
731
|
}
|
|
707
732
|
interface CrossfadeOptions {
|
|
708
|
-
/** Crossfade duration in
|
|
709
|
-
|
|
733
|
+
/** Crossfade duration in seconds. Default 1.5. */
|
|
734
|
+
duration?: number;
|
|
710
735
|
/** Bus to play `to` on (and to look up `from` on). Defaults to the sound's defaults. */
|
|
711
736
|
bus?: string;
|
|
712
737
|
/** Loop the new voice. Default true (music swap is the canonical use case). */
|
|
@@ -776,6 +801,17 @@ declare function mimeForUrl(url: string): AudioMimeType | null;
|
|
|
776
801
|
* during SSR — return the first URL and let decodeAudioData decide.
|
|
777
802
|
*/
|
|
778
803
|
declare function pickSource(urls: readonly string[]): string;
|
|
804
|
+
/**
|
|
805
|
+
* Return the URL list reordered for fallback loading: codecs the browser
|
|
806
|
+
* claims it can play first (in user-given order), unknowns/unsupported last.
|
|
807
|
+
*
|
|
808
|
+
* canPlayType is a hint, not a hard filter — some browsers under-report
|
|
809
|
+
* support, and decodeAudioData accepts a few extras. So we keep all URLs in
|
|
810
|
+
* the result; ordering merely biases the first attempts toward what's most
|
|
811
|
+
* likely to succeed. Pair with Decoder.loadFirst() to walk the list and fall
|
|
812
|
+
* through on per-URL fetch/decode failures.
|
|
813
|
+
*/
|
|
814
|
+
declare function pickSourceOrder(urls: readonly string[]): readonly string[];
|
|
779
815
|
|
|
780
816
|
/**
|
|
781
817
|
* RMS-based loudness normalization on a decoded AudioBuffer.
|
|
@@ -795,4 +831,4 @@ type NormalizeFlag = boolean | LoudnessOptions;
|
|
|
795
831
|
declare function applyLoudnessNormalization(buffer: AudioBuffer, flag: NormalizeFlag): AudioBuffer;
|
|
796
832
|
declare function computeNormalizationGain(buffer: AudioBuffer, opts: Required<LoudnessOptions>): number;
|
|
797
833
|
|
|
798
|
-
export { type ApplyOptions, type AudioMimeType, BankNotLoadedError, Bus, type BusConfig, BusNotFoundError, Compressor, type CompressorConfig, type ConcurrencyConfig, type CrossfadeOptions, DecodeError, Ducker, type DuckerConfig, type Engine, EngineClosedError, type EngineConfig, type EngineState, type FadeCurve, type FadeOptions, Filter, type FilterConfig, type FilterKind, type FxInsert, type LoadSoundOptions, type LoudnessOptions, Master, type MasterConfig, type MasterLimiterConfig, type NormalizeFlag, Parameter, type ParameterCurve, type PlayOptions, Reverb, type ReverbConfig, type SidechainConfig, Snapshot, type SnapshotState, Sound, SoundNotFoundError, type SpatialOptions, Spatializer, Sprite, type SpriteMap, type SpriteRegion, type SpriteRegionPlayOptions, StreamSound, StretchProcessor, type StretchWorkletNode, type StretchWorkletOptions, Voice, type VoiceJitter, ZvukError, applyLoudnessNormalization, canPlay, computeNormalizationGain, createEngine, createStretchWorkletNode, ensureStretchWorklet, mimeForUrl, pickSource };
|
|
834
|
+
export { AggregateDecodeError, type ApplyOptions, type AudioMimeType, BankNotLoadedError, Bus, type BusConfig, BusNotFoundError, Compressor, type CompressorConfig, type ConcurrencyConfig, type CrossfadeOptions, type DecodeAttempt, DecodeError, Ducker, type DuckerConfig, type Engine, EngineClosedError, type EngineConfig, type EngineState, type FadeCurve, type FadeOptions, Filter, type FilterConfig, type FilterKind, type FxInsert, type LoadSoundOptions, type LoudnessOptions, Master, type MasterConfig, type MasterLimiterConfig, type NormalizeFlag, Parameter, type ParameterCurve, type PlayOptions, Reverb, type ReverbConfig, type SidechainConfig, Snapshot, type SnapshotState, Sound, SoundNotFoundError, type SpatialOptions, Spatializer, Sprite, type SpriteMap, type SpriteRegion, type SpriteRegionPlayOptions, StreamSound, StretchProcessor, type StretchWorkletNode, type StretchWorkletOptions, Voice, type VoiceJitter, ZvukError, applyLoudnessNormalization, canPlay, computeNormalizationGain, createEngine, createStretchWorkletNode, ensureStretchWorklet, mimeForUrl, pickSource, pickSourceOrder };
|