@schmooky/zvuk 1.14.1 → 2.0.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/MIGRATION.md +134 -0
- package/README.md +53 -11
- package/dist/cli.js +12 -11
- package/dist/index.d.ts +621 -84
- package/dist/index.js +5 -6
- package/package.json +14 -8
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ declare class BusNotFoundError extends ZvukError {
|
|
|
10
10
|
declare class SoundNotFoundError extends ZvukError {
|
|
11
11
|
constructor(name: string, hint?: string | null);
|
|
12
12
|
}
|
|
13
|
+
declare class SpriteRegionNotFoundError extends ZvukError {
|
|
14
|
+
readonly sprite: string;
|
|
15
|
+
readonly region: string;
|
|
16
|
+
constructor(sprite: string, region: string, regions: readonly string[]);
|
|
17
|
+
}
|
|
13
18
|
/**
|
|
14
19
|
* A fetch or decode failure for one URL. The underlying failure is kept on
|
|
15
20
|
* `cause` as well as summarised into the message, so a logger that walks
|
|
@@ -74,9 +79,8 @@ interface CompressorConfig {
|
|
|
74
79
|
/**
|
|
75
80
|
* Dynamics compressor as a bus FX insert. Wraps DynamicsCompressorNode and a
|
|
76
81
|
* make-up gain node, and exposes `input`/`output` so the Bus can wire it into
|
|
77
|
-
* its FX chain. Bypass
|
|
78
|
-
*
|
|
79
|
-
* non-zero look-ahead latency leaking into the dry signal).
|
|
82
|
+
* its FX chain. Bypass crossfades to the dry signal over ~10 ms instead of
|
|
83
|
+
* swapping the graph, which clicked.
|
|
80
84
|
*/
|
|
81
85
|
declare class Compressor implements FxInsert {
|
|
82
86
|
readonly input: GainNode;
|
|
@@ -84,7 +88,7 @@ declare class Compressor implements FxInsert {
|
|
|
84
88
|
private compressor;
|
|
85
89
|
private makeup;
|
|
86
90
|
private ctx;
|
|
87
|
-
private
|
|
91
|
+
private bypass;
|
|
88
92
|
constructor(ctx: AudioContext, config?: CompressorConfig);
|
|
89
93
|
applyConfig(c: CompressorConfig): void;
|
|
90
94
|
/** Live gain reduction in dB (read-only, negative when compressing). */
|
|
@@ -92,7 +96,6 @@ declare class Compressor implements FxInsert {
|
|
|
92
96
|
get bypassed(): boolean;
|
|
93
97
|
set bypassed(v: boolean);
|
|
94
98
|
dispose(): void;
|
|
95
|
-
private wire;
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
type FadeCurve = 'linear' | 'equal-power' | 'easeIn' | 'easeOut' | 'easeInOut';
|
|
@@ -113,11 +116,42 @@ interface AudioLevel {
|
|
|
113
116
|
rms: number;
|
|
114
117
|
peak: number;
|
|
115
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* What to do when a voice limit is full:
|
|
121
|
+
*
|
|
122
|
+
* - `'oldest'` (default) — stop the voice that started first.
|
|
123
|
+
* - `'lowest-priority'` — stop the lowest-priority voice. When the new voice
|
|
124
|
+
* ranks lower than every playing one, the new voice is rejected instead.
|
|
125
|
+
* - `'quietest'` — stop the voice with the lowest level.
|
|
126
|
+
* - `'none'` — reject the new voice.
|
|
127
|
+
*
|
|
128
|
+
* A rejected voice never starts: `voice.rejected` is true, it emits only the
|
|
129
|
+
* `'ended'` cue, and its `ended` promise is already resolved.
|
|
130
|
+
*/
|
|
131
|
+
type StealStrategy = 'oldest' | 'lowest-priority' | 'quietest' | 'none';
|
|
116
132
|
interface ConcurrencyConfig {
|
|
117
133
|
/** Max simultaneous voices on this bus. */
|
|
118
134
|
max: number;
|
|
119
135
|
/** Voice-stealing strategy when max is reached. Default: 'oldest'. */
|
|
120
|
-
steal?:
|
|
136
|
+
steal?: StealStrategy;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Per-sound playback limit. Set it on `loadSound`, `loadSprite` or
|
|
140
|
+
* `loadVariants` options, or later with `sound.setLimit()`. A variants
|
|
141
|
+
* bundle shares one limit across all of its variants, so "at most 3 coins"
|
|
142
|
+
* means 3 in total, not 3 of each.
|
|
143
|
+
*/
|
|
144
|
+
interface SoundLimit {
|
|
145
|
+
/** Max simultaneous voices of this sound. Default: unlimited. */
|
|
146
|
+
max?: number;
|
|
147
|
+
/** What to do when `max` is reached. Default `'oldest'`. */
|
|
148
|
+
steal?: StealStrategy;
|
|
149
|
+
/**
|
|
150
|
+
* Minimum seconds between two starts of this sound. A play inside the
|
|
151
|
+
* window is rejected. Use it to stop a coin from machine-gunning when 40
|
|
152
|
+
* win lines land on the same frame. Default 0.
|
|
153
|
+
*/
|
|
154
|
+
cooldown?: number;
|
|
121
155
|
}
|
|
122
156
|
interface SidechainConfig {
|
|
123
157
|
/** Bus name to listen to. When that bus is loud, this bus is ducked. */
|
|
@@ -128,11 +162,20 @@ interface SidechainConfig {
|
|
|
128
162
|
attack?: number;
|
|
129
163
|
/** Release in seconds. */
|
|
130
164
|
release?: number;
|
|
165
|
+
/** Level on the `from` bus (linear RMS) above which ducking starts. Default 0.05. */
|
|
166
|
+
threshold?: number;
|
|
131
167
|
}
|
|
132
168
|
interface BusConfig {
|
|
133
169
|
level?: number;
|
|
134
170
|
mute?: boolean;
|
|
135
171
|
concurrency?: ConcurrencyConfig;
|
|
172
|
+
/**
|
|
173
|
+
* Duck this bus while another bus is loud. The engine inserts a `Ducker`
|
|
174
|
+
* at the end of this bus's FX chain when the graph is built. It follows
|
|
175
|
+
* the `from` bus's level on the main thread, which suits dialogue over
|
|
176
|
+
* music. For ducking that starts on the exact sample a sound starts, use
|
|
177
|
+
* `play({ duck })` instead.
|
|
178
|
+
*/
|
|
136
179
|
sidechain?: SidechainConfig;
|
|
137
180
|
}
|
|
138
181
|
interface SendOptions {
|
|
@@ -158,6 +201,10 @@ interface MasterLimiterConfig {
|
|
|
158
201
|
release?: number;
|
|
159
202
|
}
|
|
160
203
|
interface MasterConfig {
|
|
204
|
+
/** Master volume (0..1). Default 1. Separate from headroom. */
|
|
205
|
+
volume?: number;
|
|
206
|
+
/** Start with the master muted. Default false. */
|
|
207
|
+
mute?: boolean;
|
|
161
208
|
/** Headroom in dB applied to the master gain (negative). Default: 0. */
|
|
162
209
|
headroom?: number;
|
|
163
210
|
/** Optional fast-attack soft limiter on the master output (best-effort peak control). */
|
|
@@ -173,10 +220,24 @@ interface MasterConfig {
|
|
|
173
220
|
* the URL list passed to `loadSound` (or throws if none was given).
|
|
174
221
|
*/
|
|
175
222
|
type ResolvedAsset = AudioBuffer | ArrayBuffer | string;
|
|
223
|
+
/** Which loader asked the resolver. */
|
|
224
|
+
type AssetKind = 'sound' | 'sprite' | 'variants' | 'music';
|
|
176
225
|
interface ResolveAssetContext {
|
|
177
|
-
/**
|
|
226
|
+
/**
|
|
227
|
+
* The public name the asset was loaded under: the name passed to
|
|
228
|
+
* `loadSound`, `loadSprite`, `loadVariants` or `loadMusic`. In v1 sprites,
|
|
229
|
+
* variants and music parts arrived here under internal keys such as
|
|
230
|
+
* `__sprite:x`; v2 passes the public name and says which part in `part`.
|
|
231
|
+
*/
|
|
178
232
|
readonly name: string;
|
|
179
|
-
/**
|
|
233
|
+
/** Which loader the request came from. */
|
|
234
|
+
readonly kind: AssetKind;
|
|
235
|
+
/**
|
|
236
|
+
* Which part of a multi-part asset: the variant index for `'variants'`,
|
|
237
|
+
* `'intro' | 'loop' | 'outro'` for `'music'`. Undefined for sounds and sprites.
|
|
238
|
+
*/
|
|
239
|
+
readonly part?: number | 'intro' | 'loop' | 'outro';
|
|
240
|
+
/** The URL or URL list passed to the loader for this part. */
|
|
180
241
|
readonly url: string | readonly string[];
|
|
181
242
|
/** Forwarded from `LoadSoundOptions.signal`. */
|
|
182
243
|
readonly signal?: AbortSignal;
|
|
@@ -382,8 +443,46 @@ interface SpatialOptions {
|
|
|
382
443
|
* 3D only; ignored when `pan` is used.
|
|
383
444
|
*/
|
|
384
445
|
occlusion?: number;
|
|
446
|
+
/**
|
|
447
|
+
* 3D panning algorithm. `'HRTF'` (default) sounds best on headphones and
|
|
448
|
+
* costs the most; `'equalpower'` is cheap and fine for speakers or for
|
|
449
|
+
* dozens of simultaneous positioned voices. 3D only.
|
|
450
|
+
*/
|
|
451
|
+
panningModel?: PanningModelType;
|
|
452
|
+
/**
|
|
453
|
+
* Time constant (seconds) for live `setPan` / `setPosition` /
|
|
454
|
+
* `setOcclusion` changes: about 95 % of the way after three of them.
|
|
455
|
+
* Moving a source by jumping its position every frame crackles. Default
|
|
456
|
+
* 0.02. Pass 0 for instant jumps.
|
|
457
|
+
*/
|
|
458
|
+
glide?: number;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Duck another bus for as long as this voice plays. The attack is stamped on
|
|
462
|
+
* the audio clock at the voice's start time, so it lands on the voice's first
|
|
463
|
+
* sample, scheduled starts included. The release starts when the voice ends.
|
|
464
|
+
* Overlapping ducks on one bus don't stack: the deepest one wins, and the
|
|
465
|
+
* bus only comes back up when the last of them has ended.
|
|
466
|
+
*/
|
|
467
|
+
interface DuckOptions {
|
|
468
|
+
/** The bus to duck. */
|
|
469
|
+
bus: string;
|
|
470
|
+
/** How far to pull the bus down (0..1). 0.5 is about -6 dB. Default 0.5. */
|
|
471
|
+
amount?: number;
|
|
472
|
+
/** Attack in seconds. Default 0.05. */
|
|
473
|
+
attack?: number;
|
|
474
|
+
/** Release in seconds. Default 0.3. */
|
|
475
|
+
release?: number;
|
|
385
476
|
}
|
|
386
477
|
interface PlayOptions {
|
|
478
|
+
/**
|
|
479
|
+
* Audio-clock time (seconds, the `engine.now` timebase) to start at. Past
|
|
480
|
+
* or omitted means now. Schedule against a music grid with
|
|
481
|
+
* `musicVoice.nextBar()` for a stinger that lands on the downbeat.
|
|
482
|
+
*/
|
|
483
|
+
at?: number;
|
|
484
|
+
/** Duck another bus while this voice plays. */
|
|
485
|
+
duck?: DuckOptions;
|
|
387
486
|
/** Initial volume (0..1). Default 1. */
|
|
388
487
|
volume?: number | VoiceJitter;
|
|
389
488
|
/**
|
|
@@ -440,6 +539,15 @@ interface LoadSoundOptions {
|
|
|
440
539
|
bus?: string;
|
|
441
540
|
/** AbortSignal for the fetch. */
|
|
442
541
|
signal?: AbortSignal;
|
|
542
|
+
/**
|
|
543
|
+
* Byte-level download progress, called as chunks arrive. `totalBytes` is
|
|
544
|
+
* null when the server sends no Content-Length. Not called for cache hits
|
|
545
|
+
* or for buffers a `resolveAsset` hook returns directly. When two loads
|
|
546
|
+
* share one download, only the first gets progress.
|
|
547
|
+
*/
|
|
548
|
+
onProgress?: (loadedBytes: number, totalBytes: number | null) => void;
|
|
549
|
+
/** Per-sound concurrency limit and retrigger cooldown. */
|
|
550
|
+
limit?: SoundLimit;
|
|
443
551
|
/**
|
|
444
552
|
* Run RMS-based loudness normalization on the decoded buffer so it sits at
|
|
445
553
|
* the same RMS level as other normalized sounds. (Full-band RMS, not
|
|
@@ -461,7 +569,20 @@ interface MusicParts {
|
|
|
461
569
|
loop: string | readonly string[];
|
|
462
570
|
outro?: string | readonly string[];
|
|
463
571
|
}
|
|
464
|
-
interface MusicLoadOptions extends LoadSoundOptions {
|
|
572
|
+
interface MusicLoadOptions extends Omit<LoadSoundOptions, 'limit'> {
|
|
573
|
+
/**
|
|
574
|
+
* Tempo in beats per minute. Turns on the musical grid: `nextBeat()`,
|
|
575
|
+
* `nextBar()`, `onBeat()` and `skipToOutro({ at: 'bar' | 'beat' })` on
|
|
576
|
+
* every `MusicVoice`.
|
|
577
|
+
*/
|
|
578
|
+
bpm?: number;
|
|
579
|
+
/** Beats per bar. Default 4. */
|
|
580
|
+
beatsPerBar?: number;
|
|
581
|
+
/**
|
|
582
|
+
* Seconds from the start of playback to the grid's first downbeat.
|
|
583
|
+
* Default: the intro's length, so beat 1 is the loop's first sample.
|
|
584
|
+
*/
|
|
585
|
+
gridOffset?: number;
|
|
465
586
|
/**
|
|
466
587
|
* Equal-power crossfade (seconds) at the loop boundary. Mirrors
|
|
467
588
|
* `PlayOptions.loopCrossfade`. Masks the click that would otherwise
|
|
@@ -470,6 +591,8 @@ interface MusicLoadOptions extends LoadSoundOptions {
|
|
|
470
591
|
loopCrossfade?: number;
|
|
471
592
|
}
|
|
472
593
|
interface MusicPlayOptions {
|
|
594
|
+
/** Audio-clock time to start at. Past or omitted means now. */
|
|
595
|
+
at?: number;
|
|
473
596
|
/** Initial volume (0..1). Default 1. */
|
|
474
597
|
volume?: number;
|
|
475
598
|
/**
|
|
@@ -485,15 +608,21 @@ interface SkipToOutroOptions {
|
|
|
485
608
|
* - `'now'` — fade out whatever's playing right now (~50 ms equal-power)
|
|
486
609
|
* and start the outro immediately. Right call for "user pressed Stop"
|
|
487
610
|
* where waiting feels unresponsive.
|
|
611
|
+
* - `'bar'` / `'beat'` — start the outro on the next bar or beat of the
|
|
612
|
+
* musical grid. Needs `bpm` on `loadMusic`; without it this falls back
|
|
613
|
+
* to `'loop-end'`.
|
|
488
614
|
*/
|
|
489
|
-
at?: 'loop-end' | 'now';
|
|
615
|
+
at?: 'loop-end' | 'now' | 'bar' | 'beat';
|
|
490
616
|
}
|
|
491
617
|
type MusicState = 'intro' | 'loop' | 'outro' | 'ended';
|
|
492
618
|
/**
|
|
493
|
-
* One entry in a `engine.preload(...)` batch.
|
|
494
|
-
* signature so callers can hand the same data to
|
|
619
|
+
* One entry in a `engine.preload(...)` batch. Without `kind` it mirrors
|
|
620
|
+
* `engine.loadSound`'s signature, so callers can hand the same data to
|
|
621
|
+
* either path. With `kind` it loads a sprite, a variants bundle or music.
|
|
495
622
|
*/
|
|
496
|
-
|
|
623
|
+
type PreloadItem = PreloadSoundItem | PreloadSpriteItem | PreloadVariantsItem | PreloadMusicItem;
|
|
624
|
+
interface PreloadSoundItem {
|
|
625
|
+
kind?: 'sound';
|
|
497
626
|
/** Sound name, registered on `engine.sound(name)` after preload completes. */
|
|
498
627
|
name: string;
|
|
499
628
|
/** URL or codec ladder, the same shape as `engine.loadSound`. */
|
|
@@ -501,6 +630,39 @@ interface PreloadItem {
|
|
|
501
630
|
/** Per-item options (bus, normalize, etc.). Forwarded to `loadSound`. */
|
|
502
631
|
options?: LoadSoundOptions;
|
|
503
632
|
}
|
|
633
|
+
interface PreloadSpriteItem {
|
|
634
|
+
kind: 'sprite';
|
|
635
|
+
name: string;
|
|
636
|
+
url: string | readonly string[];
|
|
637
|
+
regions: Record<string, {
|
|
638
|
+
start: number;
|
|
639
|
+
duration: number;
|
|
640
|
+
loop?: boolean;
|
|
641
|
+
}>;
|
|
642
|
+
options?: LoadSoundOptions;
|
|
643
|
+
}
|
|
644
|
+
interface PreloadVariantsItem {
|
|
645
|
+
kind: 'variants';
|
|
646
|
+
name: string;
|
|
647
|
+
urls: readonly (string | readonly string[])[];
|
|
648
|
+
options?: LoadSoundOptions & {
|
|
649
|
+
strategy?: 'random' | 'no-repeat' | 'shuffle-bag';
|
|
650
|
+
weights?: readonly number[];
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
interface PreloadMusicItem {
|
|
654
|
+
kind: 'music';
|
|
655
|
+
name: string;
|
|
656
|
+
parts: MusicParts;
|
|
657
|
+
options?: MusicLoadOptions;
|
|
658
|
+
}
|
|
659
|
+
/** Byte progress of one preload item. */
|
|
660
|
+
interface PreloadBytesEvent {
|
|
661
|
+
readonly name: string;
|
|
662
|
+
readonly loadedBytes: number;
|
|
663
|
+
/** Null when the server sent no Content-Length. */
|
|
664
|
+
readonly totalBytes: number | null;
|
|
665
|
+
}
|
|
504
666
|
interface PreloadProgressEvent {
|
|
505
667
|
/** Name of the item that just completed (success or failure). */
|
|
506
668
|
readonly name: string;
|
|
@@ -532,6 +694,12 @@ interface PreloadOptions {
|
|
|
532
694
|
* is a fraction in [0..1].
|
|
533
695
|
*/
|
|
534
696
|
onProgress?: (event: PreloadProgressEvent) => void;
|
|
697
|
+
/**
|
|
698
|
+
* Byte-level progress per item, as chunks arrive. Use it for a smooth bar
|
|
699
|
+
* when a batch holds a few large files. Items served from the cache or a
|
|
700
|
+
* `resolveAsset` buffer report nothing here.
|
|
701
|
+
*/
|
|
702
|
+
onBytes?: (event: PreloadBytesEvent) => void;
|
|
535
703
|
}
|
|
536
704
|
|
|
537
705
|
/**
|
|
@@ -552,6 +720,7 @@ interface PreloadOptions {
|
|
|
552
720
|
declare class Spatializer {
|
|
553
721
|
private ctx;
|
|
554
722
|
private kind;
|
|
723
|
+
private glide;
|
|
555
724
|
private input;
|
|
556
725
|
private output;
|
|
557
726
|
private stereoPan;
|
|
@@ -559,8 +728,14 @@ declare class Spatializer {
|
|
|
559
728
|
private occlusionFilter;
|
|
560
729
|
private occlusionGain;
|
|
561
730
|
constructor(ctx: AudioContext, opts: SpatialOptions);
|
|
731
|
+
/** 2D pan (-1..1). Glides over the `glide` time constant. */
|
|
562
732
|
setPan(pan: number): void;
|
|
733
|
+
/** 3D position. Glides over the `glide` time constant. */
|
|
563
734
|
setPosition(x: number, y: number, z: number): void;
|
|
735
|
+
/** Change the glide time constant for later moves. 0 jumps. */
|
|
736
|
+
setGlide(seconds: number): void;
|
|
737
|
+
/** Switch the 3D panning algorithm live. No-op on 2D spatializers. */
|
|
738
|
+
setPanningModel(model: PanningModelType): void;
|
|
564
739
|
setRefDistance(d: number): void;
|
|
565
740
|
setMaxDistance(d: number): void;
|
|
566
741
|
setRolloffFactor(f: number): void;
|
|
@@ -571,12 +746,14 @@ declare class Spatializer {
|
|
|
571
746
|
* No-op on 2D spatializers.
|
|
572
747
|
*/
|
|
573
748
|
setOcclusion(amount: number): void;
|
|
749
|
+
private applyOcclusion;
|
|
574
750
|
/** Connects the spatializer's output into `dest` and returns the input the Voice should use. */
|
|
575
751
|
connectInto(dest: AudioNode): AudioNode;
|
|
576
752
|
dispose(): void;
|
|
577
753
|
private setPanner3D;
|
|
578
754
|
}
|
|
579
755
|
|
|
756
|
+
/** Lifecycle cues a voice emits on `voice.cues()`. */
|
|
580
757
|
type VoiceCue = 'started' | 'paused' | 'resumed' | 'ended';
|
|
581
758
|
interface VoiceDeps {
|
|
582
759
|
ctx: AudioContext;
|
|
@@ -588,6 +765,11 @@ interface VoiceDeps {
|
|
|
588
765
|
sourceName?: string;
|
|
589
766
|
/** Engine-level default click-free fade for stop() (seconds). */
|
|
590
767
|
defaultStopFade?: number;
|
|
768
|
+
/**
|
|
769
|
+
* A concurrency limit refused this voice. It is built already finished:
|
|
770
|
+
* no source node starts, no `started` cue fires, `ended` is resolved.
|
|
771
|
+
*/
|
|
772
|
+
rejected?: boolean;
|
|
591
773
|
}
|
|
592
774
|
/**
|
|
593
775
|
* One playback instance, returned from sound.play(). Owns its source node
|
|
@@ -600,9 +782,18 @@ declare class Voice {
|
|
|
600
782
|
readonly id: number;
|
|
601
783
|
readonly priority: number;
|
|
602
784
|
readonly bus: string | undefined;
|
|
785
|
+
/**
|
|
786
|
+
* Audio time the voice starts (or started) sounding. Equal to the time of
|
|
787
|
+
* the `play()` call unless `play({ at })` scheduled it later.
|
|
788
|
+
*/
|
|
603
789
|
readonly startedAt: number;
|
|
604
790
|
/** Name of the Sound that spawned this voice (if any). Used for crossfade. */
|
|
605
791
|
readonly sourceName: string | undefined;
|
|
792
|
+
/**
|
|
793
|
+
* True when a concurrency limit or cooldown refused this voice. A rejected
|
|
794
|
+
* voice never made a sound; every method on it is a no-op.
|
|
795
|
+
*/
|
|
796
|
+
readonly rejected: boolean;
|
|
606
797
|
/** Resolves when playback finishes (natural end, stop(), or abort). */
|
|
607
798
|
readonly ended: Promise<void>;
|
|
608
799
|
private ctx;
|
|
@@ -625,7 +816,10 @@ declare class Voice {
|
|
|
625
816
|
private loopStart;
|
|
626
817
|
private loopEnd;
|
|
627
818
|
private regionTimer;
|
|
819
|
+
private startTimer;
|
|
628
820
|
private stopFade;
|
|
821
|
+
private signal;
|
|
822
|
+
private onAbort;
|
|
629
823
|
private crossfadeSec;
|
|
630
824
|
private crossfadeRegionStart;
|
|
631
825
|
private crossfadeRegionLen;
|
|
@@ -660,9 +854,15 @@ declare class Voice {
|
|
|
660
854
|
resume(): void;
|
|
661
855
|
/** Whether the voice is currently paused (and thus retaining its offset). */
|
|
662
856
|
get isPaused(): boolean;
|
|
857
|
+
/** True once the voice has finished (or was rejected). */
|
|
858
|
+
get isDone(): boolean;
|
|
663
859
|
/**
|
|
664
860
|
* Live playback-rate setter. Optional ramp via curve.
|
|
665
861
|
* Setting while paused only updates the value used on the next start.
|
|
862
|
+
*
|
|
863
|
+
* A voice in `loopCrossfade` mode re-seams its loop at the new rate with a
|
|
864
|
+
* short equal-power crossfade, because every seam of the chain is stamped
|
|
865
|
+
* against the rate the segment started at. `duration` is ignored there.
|
|
666
866
|
*/
|
|
667
867
|
setPlaybackRate(rate: number, opts?: {
|
|
668
868
|
duration?: number;
|
|
@@ -694,13 +894,19 @@ declare class Voice {
|
|
|
694
894
|
cues(): AsyncIterableIterator<VoiceCue>;
|
|
695
895
|
private finish;
|
|
696
896
|
private emit;
|
|
897
|
+
private clearArmTimer;
|
|
697
898
|
private createSourceNode;
|
|
899
|
+
/**
|
|
900
|
+
* Arm the region bound. `remainingSec` is in buffer seconds; `leadSec` is
|
|
901
|
+
* output time before the region starts counting (a scheduled start).
|
|
902
|
+
*/
|
|
698
903
|
private armRegionTimer;
|
|
699
904
|
private bindSourceLifecycle;
|
|
700
905
|
/**
|
|
701
|
-
* Begin the loop-crossfade chain
|
|
702
|
-
* full level, then arms a
|
|
703
|
-
*
|
|
906
|
+
* Begin the loop-crossfade chain at `regionOffset` into the loop region.
|
|
907
|
+
* Spawns the first segment immediately at full level, then arms a
|
|
908
|
+
* setTimeout to spawn the next one shortly before the boundary. Each
|
|
909
|
+
* subsequent spawn re-arms its own follow-up.
|
|
704
910
|
*
|
|
705
911
|
* Audio scheduling uses absolute `ctx.currentTime` values so drift between
|
|
706
912
|
* setTimeout (wall clock) and the audio thread doesn't cause click-y
|
|
@@ -708,13 +914,37 @@ declare class Voice {
|
|
|
708
914
|
* `source.start(when, ...)` before `when`.
|
|
709
915
|
*/
|
|
710
916
|
private startCrossfadeChain;
|
|
917
|
+
/**
|
|
918
|
+
* Crossfade window for a segment at `rate`, in output seconds. At high
|
|
919
|
+
* pitch a region can be shorter than two windows of output; the window
|
|
920
|
+
* shrinks with it instead of letting the two legs overlap.
|
|
921
|
+
*/
|
|
922
|
+
private segmentXf;
|
|
711
923
|
private spawnCrossfadeSegment;
|
|
712
924
|
private armNextCrossfadeSegment;
|
|
925
|
+
/**
|
|
926
|
+
* Move a crossfading loop to a new rate: fade the live segments out over
|
|
927
|
+
* a short window and start a fresh chain at the new rate from the same
|
|
928
|
+
* position, fading in over that window.
|
|
929
|
+
*/
|
|
930
|
+
private reseamCrossfade;
|
|
713
931
|
private releaseCrossfadeSegment;
|
|
714
932
|
private get inCrossfadeMode();
|
|
933
|
+
/** Playback position in buffer seconds. */
|
|
715
934
|
private computeOffset;
|
|
716
935
|
}
|
|
717
936
|
|
|
937
|
+
/** What a would-be voice looks like before it exists. */
|
|
938
|
+
interface VoiceCandidate {
|
|
939
|
+
readonly priority: number;
|
|
940
|
+
}
|
|
941
|
+
interface StealPlan {
|
|
942
|
+
/** The new voice may not play. Nothing was stolen. */
|
|
943
|
+
readonly reject: boolean;
|
|
944
|
+
/** A voice to stop to make room, or null when there is room already. */
|
|
945
|
+
readonly victim: Voice | null;
|
|
946
|
+
}
|
|
947
|
+
|
|
718
948
|
/**
|
|
719
949
|
* One configured send from a source bus to a target bus. Returned by
|
|
720
950
|
* `bus.send(target, ...)`; held by callers so the level can be adjusted
|
|
@@ -748,7 +978,7 @@ declare class Send {
|
|
|
748
978
|
declare class Bus {
|
|
749
979
|
readonly name: string;
|
|
750
980
|
readonly input: GainNode;
|
|
751
|
-
/** Sub-bus the FX chain splices into: input → fxInput → (fx…) → output. */
|
|
981
|
+
/** Sub-bus the FX chain splices into: input → fxInput → (fx…) → duck → output. */
|
|
752
982
|
readonly fxInput: GainNode;
|
|
753
983
|
/** Output node — connect to master.input or another bus.input for sends. */
|
|
754
984
|
readonly output: GainNode;
|
|
@@ -762,6 +992,9 @@ declare class Bus {
|
|
|
762
992
|
private _voices;
|
|
763
993
|
private _fxChain;
|
|
764
994
|
private _sends;
|
|
995
|
+
private readonly duckNode;
|
|
996
|
+
private ducks;
|
|
997
|
+
private duckSeq;
|
|
765
998
|
private _meterAnalyser;
|
|
766
999
|
private _meterBuf;
|
|
767
1000
|
/**
|
|
@@ -786,18 +1019,37 @@ declare class Bus {
|
|
|
786
1019
|
get concurrency(): ConcurrencyConfig | null;
|
|
787
1020
|
setConcurrency(c: ConcurrencyConfig | null): void;
|
|
788
1021
|
/**
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
1022
|
+
* Decide whether a voice that doesn't exist yet may play on this bus, and
|
|
1023
|
+
* which voice it displaces. Pure: stops nothing. The caller stops the
|
|
1024
|
+
* victim and only then starts the new voice, so a rejected voice never
|
|
1025
|
+
* makes a sound.
|
|
1026
|
+
*
|
|
1027
|
+
* @internal
|
|
793
1028
|
*/
|
|
794
|
-
|
|
1029
|
+
planConcurrency(candidate: VoiceCandidate): StealPlan;
|
|
1030
|
+
/**
|
|
1031
|
+
* Pull this bus down by `amount` from audio time `at` until the returned
|
|
1032
|
+
* release function is called. Overlapping ducks take the deepest; the bus
|
|
1033
|
+
* comes back up when the last one releases. Used by `play({ duck })`.
|
|
1034
|
+
*
|
|
1035
|
+
* @returns a release function. Idempotent.
|
|
1036
|
+
*/
|
|
1037
|
+
duck(opts: Omit<DuckOptions, 'bus'>, at?: number): () => void;
|
|
1038
|
+
/** Current duck gain (1 = not ducked). */
|
|
1039
|
+
get duckLevel(): number;
|
|
1040
|
+
private scheduleDucks;
|
|
795
1041
|
/** Engine-only: register an active voice. */
|
|
796
1042
|
trackVoice(v: Voice): void;
|
|
797
1043
|
/** Engine-only: deregister a finished voice. */
|
|
798
1044
|
releaseVoice(v: Voice): void;
|
|
799
1045
|
/** Add an FX insert to the bus's FX chain (post-input, pre-output). */
|
|
800
1046
|
addFx(fx: FxInsert): void;
|
|
1047
|
+
/**
|
|
1048
|
+
* Take an insert out of the chain. The insert is disconnected but not
|
|
1049
|
+
* disposed, so it can be added to another bus. Before v2 its output stayed
|
|
1050
|
+
* connected to this bus, so a reverb tail kept sounding and re-adding the
|
|
1051
|
+
* insert elsewhere routed it into both buses.
|
|
1052
|
+
*/
|
|
801
1053
|
removeFx(fx: FxInsert): void;
|
|
802
1054
|
fx(): readonly FxInsert[];
|
|
803
1055
|
/**
|
|
@@ -930,17 +1182,16 @@ interface FilterConfig {
|
|
|
930
1182
|
gain?: number;
|
|
931
1183
|
}
|
|
932
1184
|
/**
|
|
933
|
-
* Biquad filter as a bus FX insert.
|
|
934
|
-
*
|
|
935
|
-
*
|
|
936
|
-
* signal.
|
|
1185
|
+
* Biquad filter as a bus FX insert. Frequency, Q and gain changes glide over
|
|
1186
|
+
* ~10 ms, and bypass crossfades to the dry signal, so a sweep driven from a
|
|
1187
|
+
* slider or a `Parameter` doesn't zipper or click.
|
|
937
1188
|
*/
|
|
938
1189
|
declare class Filter implements FxInsert {
|
|
939
1190
|
readonly input: GainNode;
|
|
940
1191
|
readonly output: GainNode;
|
|
941
1192
|
private filter;
|
|
942
1193
|
private ctx;
|
|
943
|
-
private
|
|
1194
|
+
private bypass;
|
|
944
1195
|
constructor(ctx: AudioContext, config?: FilterConfig);
|
|
945
1196
|
setFrequency(hz: number): void;
|
|
946
1197
|
setQ(q: number): void;
|
|
@@ -950,7 +1201,6 @@ declare class Filter implements FxInsert {
|
|
|
950
1201
|
get bypassed(): boolean;
|
|
951
1202
|
set bypassed(v: boolean);
|
|
952
1203
|
dispose(): void;
|
|
953
|
-
private wire;
|
|
954
1204
|
}
|
|
955
1205
|
|
|
956
1206
|
interface ReverbConfig {
|
|
@@ -984,6 +1234,7 @@ declare class Reverb implements FxInsert {
|
|
|
984
1234
|
private _wet;
|
|
985
1235
|
constructor(ctx: AudioContext, config?: ReverbConfig);
|
|
986
1236
|
setWet(mix: number): void;
|
|
1237
|
+
private glideMix;
|
|
987
1238
|
setImpulse(buffer: AudioBuffer): void;
|
|
988
1239
|
get bypassed(): boolean;
|
|
989
1240
|
set bypassed(v: boolean);
|
|
@@ -1057,8 +1308,8 @@ declare function createStretchWorkletNode(ctx: AudioContext, options?: StretchWo
|
|
|
1057
1308
|
* voice = dialogue + effort sounds; etc.
|
|
1058
1309
|
*
|
|
1059
1310
|
* Construct via `engine.busGroup(name, members)`; look up via
|
|
1060
|
-
* `engine.busGroup(name)`. Snapshots
|
|
1061
|
-
*
|
|
1311
|
+
* `engine.busGroup(name)`. Snapshots address buses, not groups: a snapshot
|
|
1312
|
+
* of a mix with a group in it records each member bus.
|
|
1062
1313
|
*/
|
|
1063
1314
|
declare class BusGroup {
|
|
1064
1315
|
readonly name: string;
|
|
@@ -1102,9 +1353,27 @@ declare class Parameter {
|
|
|
1102
1353
|
readonly name: string;
|
|
1103
1354
|
private _value;
|
|
1104
1355
|
private subs;
|
|
1356
|
+
private glide;
|
|
1105
1357
|
constructor(name: string, initial: number);
|
|
1106
1358
|
get value(): number;
|
|
1359
|
+
/** Set the value now. Cancels a running `rampTo` glide. */
|
|
1107
1360
|
set(v: number): void;
|
|
1361
|
+
/** True while a `rampTo` glide is running. */
|
|
1362
|
+
get gliding(): boolean;
|
|
1363
|
+
/**
|
|
1364
|
+
* Glide to `target` over `seconds`, calling subscribers on every frame
|
|
1365
|
+
* along the way. Resolves when the glide lands, or when `set()` or
|
|
1366
|
+
* another `rampTo()` interrupts it. An RTPC-style "intensity" knob moved
|
|
1367
|
+
* with `rampTo` drives everything bound to it smoothly, without each
|
|
1368
|
+
* binding scheduling its own fade.
|
|
1369
|
+
*
|
|
1370
|
+
* Frames come from `requestAnimationFrame`, falling back to 16 ms timers
|
|
1371
|
+
* where there is none (a hidden tab, a worker, SSR). The glide runs on
|
|
1372
|
+
* wall time, so a hidden tab still lands on time, just in coarser steps.
|
|
1373
|
+
*/
|
|
1374
|
+
rampTo(target: number, seconds: number, curve?: ParameterCurve): Promise<void>;
|
|
1375
|
+
private cancelGlide;
|
|
1376
|
+
private write;
|
|
1108
1377
|
subscribe(fn: Subscriber): () => void;
|
|
1109
1378
|
/**
|
|
1110
1379
|
* Bind a setter to this parameter. The parameter's [0..1] value (clamped)
|
|
@@ -1137,12 +1406,35 @@ interface MusicBuffers {
|
|
|
1137
1406
|
loop: AudioBuffer;
|
|
1138
1407
|
outro?: AudioBuffer;
|
|
1139
1408
|
}
|
|
1409
|
+
/** Tempo grid of a music asset. */
|
|
1410
|
+
interface MusicGrid {
|
|
1411
|
+
bpm: number;
|
|
1412
|
+
beatsPerBar: number;
|
|
1413
|
+
/** Seconds from the start of playback to the first downbeat. */
|
|
1414
|
+
offset: number;
|
|
1415
|
+
}
|
|
1140
1416
|
interface MusicDeps {
|
|
1141
1417
|
ctx: AudioContext;
|
|
1142
1418
|
buffers: MusicBuffers;
|
|
1143
1419
|
destination: AudioNode;
|
|
1144
1420
|
loopCrossfade: number;
|
|
1145
1421
|
defaultStopFade?: number;
|
|
1422
|
+
grid?: {
|
|
1423
|
+
bpm: number;
|
|
1424
|
+
beatsPerBar?: number;
|
|
1425
|
+
offset?: number;
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
/** One beat of a music grid, passed to `onBeat` listeners. */
|
|
1429
|
+
interface BeatEvent {
|
|
1430
|
+
/** Audio time of the beat. Schedule on it: `sound.play({ at: e.time })`. */
|
|
1431
|
+
readonly time: number;
|
|
1432
|
+
/** Beats since the grid's first downbeat, from 0. */
|
|
1433
|
+
readonly beat: number;
|
|
1434
|
+
/** Bar number, from 0. */
|
|
1435
|
+
readonly bar: number;
|
|
1436
|
+
/** Beat within the bar, from 0. 0 is the downbeat. */
|
|
1437
|
+
readonly beatInBar: number;
|
|
1146
1438
|
}
|
|
1147
1439
|
/**
|
|
1148
1440
|
* Stinger → loop → outro music asset. The pattern every casino slot,
|
|
@@ -1163,6 +1455,8 @@ declare class Music {
|
|
|
1163
1455
|
get loopDuration(): number;
|
|
1164
1456
|
get hasIntro(): boolean;
|
|
1165
1457
|
get hasOutro(): boolean;
|
|
1458
|
+
/** The tempo grid, or undefined when the asset was loaded without `bpm`. */
|
|
1459
|
+
get grid(): Readonly<MusicGrid> | undefined;
|
|
1166
1460
|
play(options?: MusicPlayOptions): MusicVoice;
|
|
1167
1461
|
/** Live playback instances spawned from this asset. */
|
|
1168
1462
|
voices(): readonly MusicVoice[];
|
|
@@ -1179,17 +1473,22 @@ interface MusicVoiceDeps {
|
|
|
1179
1473
|
destination: AudioNode;
|
|
1180
1474
|
loopCrossfade: number;
|
|
1181
1475
|
defaultStopFade?: number;
|
|
1476
|
+
grid?: MusicGrid;
|
|
1182
1477
|
options: MusicPlayOptions;
|
|
1183
1478
|
}
|
|
1184
1479
|
/**
|
|
1185
1480
|
* One live playback instance of a `Music` asset. Tracks which part is
|
|
1186
1481
|
* currently sounding (`'intro' | 'loop' | 'outro' | 'ended'`), exposes
|
|
1187
|
-
* `fade`/`pause`/`resume`/`stop`, and adds
|
|
1482
|
+
* `fade`/`pause`/`resume`/`stop`, and adds the music-specific operations:
|
|
1188
1483
|
*
|
|
1189
1484
|
* - `skipToOutro({ at: 'loop-end' })` — wait for the current loop iteration
|
|
1190
1485
|
* to complete, then play the outro at the natural loop boundary.
|
|
1486
|
+
* - `skipToOutro({ at: 'bar' | 'beat' })` — the outro takes over on the next
|
|
1487
|
+
* bar or beat of the tempo grid (needs `bpm` on `loadMusic`).
|
|
1191
1488
|
* - `skipToOutro({ at: 'now' })` — fade the loop out (~50 ms) and start
|
|
1192
1489
|
* the outro immediately. Right call for "user pressed Stop."
|
|
1490
|
+
* - `nextBeat()` / `nextBar()` / `onBeat()` — the tempo grid, for stingers
|
|
1491
|
+
* and animations that land on the music.
|
|
1193
1492
|
*
|
|
1194
1493
|
* `stop()` is the click-free cut — no outro. Use `skipToOutro` if you want
|
|
1195
1494
|
* the music to end musically.
|
|
@@ -1205,17 +1504,34 @@ declare class MusicVoice {
|
|
|
1205
1504
|
private resolveEnded;
|
|
1206
1505
|
private stopFade;
|
|
1207
1506
|
private loopCrossfadeSec;
|
|
1507
|
+
private grid;
|
|
1208
1508
|
private introSource;
|
|
1209
1509
|
private outroSource;
|
|
1210
1510
|
private loopChain;
|
|
1211
1511
|
private loopArmTimer;
|
|
1212
1512
|
private outroTimer;
|
|
1513
|
+
private flipTimer;
|
|
1213
1514
|
private nextLoopBoundaryAt;
|
|
1214
1515
|
private loopAnchorAt;
|
|
1516
|
+
private introStartAt;
|
|
1215
1517
|
private introEndsAt;
|
|
1518
|
+
private outroStartAt;
|
|
1519
|
+
private outroMode;
|
|
1520
|
+
private loopDeadline;
|
|
1521
|
+
private gridZero;
|
|
1522
|
+
private paused;
|
|
1523
|
+
private pausedAt;
|
|
1524
|
+
private pausedPart;
|
|
1525
|
+
private pausedOffset;
|
|
1526
|
+
private beatListeners;
|
|
1527
|
+
private beatTimer;
|
|
1216
1528
|
constructor(deps: MusicVoiceDeps);
|
|
1217
1529
|
/** Currently-sounding part. Transitions automatically as parts hand off. */
|
|
1218
1530
|
get currentPart(): MusicState;
|
|
1531
|
+
/** True while paused. */
|
|
1532
|
+
get isPaused(): boolean;
|
|
1533
|
+
/** The tempo grid, or undefined without `bpm`. */
|
|
1534
|
+
get tempo(): Readonly<MusicGrid> | undefined;
|
|
1219
1535
|
fade(opts: FadeOptions): Promise<void>;
|
|
1220
1536
|
/**
|
|
1221
1537
|
* Stop the music with the same click-free fade-out semantics as
|
|
@@ -1223,22 +1539,65 @@ declare class MusicVoice {
|
|
|
1223
1539
|
* want the music to end musically.
|
|
1224
1540
|
*/
|
|
1225
1541
|
stop(opts?: StopOptions): void;
|
|
1542
|
+
/**
|
|
1543
|
+
* Pause playback. `resume()` picks up in the same part at the same offset,
|
|
1544
|
+
* and a `skipToOutro` that was waiting for its boundary is re-issued on
|
|
1545
|
+
* resume. The tempo grid shifts by the length of the pause, so beats keep
|
|
1546
|
+
* lining up with the music.
|
|
1547
|
+
*/
|
|
1548
|
+
pause(): void;
|
|
1549
|
+
/** Resume from where `pause()` left off. No-op when not paused. */
|
|
1550
|
+
resume(): void;
|
|
1226
1551
|
/**
|
|
1227
1552
|
* Schedule the outro. With `at: 'loop-end'` (default) the outro starts
|
|
1228
1553
|
* at the next natural loop boundary so the music ends musically. With
|
|
1229
|
-
* `
|
|
1554
|
+
* `'bar'` or `'beat'` it starts on the next bar or beat of the tempo grid.
|
|
1555
|
+
* With `at: 'now'` the loop fades out (~50 ms) and the outro starts
|
|
1230
1556
|
* immediately — useful when responsiveness matters more than musicality
|
|
1231
1557
|
* (e.g. user pressed Stop).
|
|
1232
1558
|
*
|
|
1233
|
-
* No-op if
|
|
1234
|
-
*
|
|
1235
|
-
* the
|
|
1559
|
+
* No-op if the music is already past the loop part, and calling
|
|
1560
|
+
* `skipToOutro` more than once is a no-op too — the first call wins.
|
|
1561
|
+
* Without an outro buffer this stops the music instead, so calling code
|
|
1562
|
+
* doesn't need to branch on `hasOutro`. While paused the request is kept
|
|
1563
|
+
* and runs on resume.
|
|
1236
1564
|
*/
|
|
1237
1565
|
skipToOutro(opts?: SkipToOutroOptions): void;
|
|
1566
|
+
/**
|
|
1567
|
+
* Audio time of the next beat strictly after `from` (default now), or
|
|
1568
|
+
* undefined without `bpm`. Feed it straight to `play({ at })`.
|
|
1569
|
+
*/
|
|
1570
|
+
nextBeat(from?: number): number | undefined;
|
|
1571
|
+
/** Audio time of the next downbeat strictly after `from`, or undefined without `bpm`. */
|
|
1572
|
+
nextBar(from?: number): number | undefined;
|
|
1573
|
+
/**
|
|
1574
|
+
* Where `time` (default now) falls on the grid, or undefined without
|
|
1575
|
+
* `bpm`. Fractional beats count up between beats.
|
|
1576
|
+
*/
|
|
1577
|
+
beatAt(time?: number): {
|
|
1578
|
+
beat: number;
|
|
1579
|
+
bar: number;
|
|
1580
|
+
beatInBar: number;
|
|
1581
|
+
} | undefined;
|
|
1582
|
+
/**
|
|
1583
|
+
* Call `fn` for every beat while the music plays. It runs about 50 ms
|
|
1584
|
+
* ahead of each beat with the beat's exact audio time, so work scheduled
|
|
1585
|
+
* on `e.time` lands on the beat. Timers can still run late when the main
|
|
1586
|
+
* thread stalls; a beat that was missed by more than the lookahead is
|
|
1587
|
+
* delivered late, not skipped. Returns an unsubscribe function. No-op
|
|
1588
|
+
* without `bpm`.
|
|
1589
|
+
*/
|
|
1590
|
+
onBeat(fn: (e: BeatEvent) => void): () => void;
|
|
1591
|
+
private nextGridPoint;
|
|
1592
|
+
private armBeat;
|
|
1593
|
+
private fireBeat;
|
|
1594
|
+
private clearBeatTimer;
|
|
1238
1595
|
private start;
|
|
1239
1596
|
private scheduleIntro;
|
|
1597
|
+
/** Start the loop part at audio time `when`, `offset` seconds into the loop buffer. */
|
|
1240
1598
|
private scheduleLoopStart;
|
|
1241
1599
|
private spawnLoopSegment;
|
|
1600
|
+
/** `lapStart` is the audio time the current lap's buffer offset 0 plays. */
|
|
1242
1601
|
private armNextLoopSegment;
|
|
1243
1602
|
private crossfadeViable;
|
|
1244
1603
|
private releaseLoopSegment;
|
|
@@ -1250,21 +1609,48 @@ declare class MusicVoice {
|
|
|
1250
1609
|
* native-loop path has no chain — one source loops itself for the whole
|
|
1251
1610
|
* playback — so its boundaries are a grid off the loop's start, and the
|
|
1252
1611
|
* answer has to be computed against the clock each time it's asked for.
|
|
1253
|
-
* Reading a marker that was written once, at the first boundary, is how
|
|
1254
|
-
* `skipToOutro({ at: 'loop-end' })` came to fire instantly on every
|
|
1255
|
-
* iteration but the first.
|
|
1256
1612
|
*/
|
|
1257
1613
|
private nextLoopBoundary;
|
|
1614
|
+
/** Which part plays at audio time `t`, and how far into it. */
|
|
1615
|
+
private position;
|
|
1258
1616
|
private skipToOutroAtLoopEnd;
|
|
1617
|
+
/**
|
|
1618
|
+
* The outro takes over on a grid point. That point can sit mid-buffer, so
|
|
1619
|
+
* the loop gets a 10 ms fade into it; and it can lie beyond the segment
|
|
1620
|
+
* that is playing now, so the crossfade chain keeps running up to it.
|
|
1621
|
+
*/
|
|
1622
|
+
private skipToOutroOnGrid;
|
|
1259
1623
|
private skipToOutroNow;
|
|
1260
1624
|
private cancelLoopArm;
|
|
1261
1625
|
private stopLoopSourcesAt;
|
|
1262
1626
|
private scheduleOutro;
|
|
1627
|
+
private playOutroFrom;
|
|
1263
1628
|
private cancelTimers;
|
|
1264
1629
|
private stopAllSources;
|
|
1630
|
+
private disconnectSources;
|
|
1265
1631
|
private finish;
|
|
1266
1632
|
}
|
|
1267
1633
|
|
|
1634
|
+
/**
|
|
1635
|
+
* Per-sound voice limit and retrigger cooldown. One instance can be shared:
|
|
1636
|
+
* a variants bundle hands the same limit to every variant, so `max: 3` caps
|
|
1637
|
+
* the bundle, not each take.
|
|
1638
|
+
*
|
|
1639
|
+
* @internal
|
|
1640
|
+
*/
|
|
1641
|
+
declare class VoiceLimit {
|
|
1642
|
+
private config;
|
|
1643
|
+
private voices;
|
|
1644
|
+
private lastStart;
|
|
1645
|
+
constructor(config?: SoundLimit);
|
|
1646
|
+
get current(): Readonly<SoundLimit>;
|
|
1647
|
+
set(config: SoundLimit | null): void;
|
|
1648
|
+
get count(): number;
|
|
1649
|
+
/** Plan a start at audio time `at`. Pure: stops nothing. */
|
|
1650
|
+
plan(at: number, candidate: VoiceCandidate): StealPlan;
|
|
1651
|
+
admit(v: Voice, at: number): void;
|
|
1652
|
+
release(v: Voice): void;
|
|
1653
|
+
}
|
|
1268
1654
|
interface SoundDeps {
|
|
1269
1655
|
ctx: AudioContext;
|
|
1270
1656
|
buffer: AudioBuffer;
|
|
@@ -1273,7 +1659,12 @@ interface SoundDeps {
|
|
|
1273
1659
|
resolveSpatializer?: (busName: string, options: PlayOptions['spatializer']) => Spatializer | undefined;
|
|
1274
1660
|
trackVoice: (v: Voice, bus: string) => void;
|
|
1275
1661
|
releaseVoice: (v: Voice, bus: string) => void;
|
|
1276
|
-
|
|
1662
|
+
/** Bus concurrency decision for a voice that doesn't exist yet. */
|
|
1663
|
+
planBus?: (bus: string, candidate: VoiceCandidate) => StealPlan;
|
|
1664
|
+
/** Look up the bus a `duck` option names. */
|
|
1665
|
+
resolveBus?: (name: string) => Bus;
|
|
1666
|
+
/** Shared per-sound limit. */
|
|
1667
|
+
limit?: VoiceLimit;
|
|
1277
1668
|
/** Engine-level default click-free fade for voice.stop() (seconds). */
|
|
1278
1669
|
defaultStopFade?: number;
|
|
1279
1670
|
/**
|
|
@@ -1293,8 +1684,19 @@ interface SoundDeps {
|
|
|
1293
1684
|
declare class Sound {
|
|
1294
1685
|
readonly name: string;
|
|
1295
1686
|
private deps;
|
|
1687
|
+
private limit;
|
|
1296
1688
|
constructor(name: string, deps: SoundDeps);
|
|
1297
1689
|
get duration(): number;
|
|
1690
|
+
/** The decoded buffer every voice of this sound plays. */
|
|
1691
|
+
get buffer(): AudioBuffer;
|
|
1692
|
+
/**
|
|
1693
|
+
* Cap simultaneous voices of this sound and/or set a retrigger cooldown.
|
|
1694
|
+
* Pass `null` to remove the limit. On a sound that belongs to a variants
|
|
1695
|
+
* bundle this changes the bundle's shared limit.
|
|
1696
|
+
*/
|
|
1697
|
+
setLimit(limit: SoundLimit | null): void;
|
|
1698
|
+
/** The current limit (empty object when unlimited). */
|
|
1699
|
+
get soundLimit(): Readonly<SoundLimit>;
|
|
1298
1700
|
play(options?: PlayOptions): Voice;
|
|
1299
1701
|
}
|
|
1300
1702
|
|
|
@@ -1322,6 +1724,10 @@ declare class Sprite {
|
|
|
1322
1724
|
private regions;
|
|
1323
1725
|
private sound;
|
|
1324
1726
|
constructor(name: string, sound: Sound, regions: SpriteMap);
|
|
1727
|
+
/** Cap simultaneous voices of this sprite (all regions) and/or set a cooldown. */
|
|
1728
|
+
setLimit(limit: SoundLimit | null): void;
|
|
1729
|
+
/** Duration of the sprite's whole buffer in seconds. */
|
|
1730
|
+
get duration(): number;
|
|
1325
1731
|
/** Region names defined on this sprite. */
|
|
1326
1732
|
list(): readonly string[];
|
|
1327
1733
|
has(region: string): boolean;
|
|
@@ -1352,19 +1758,43 @@ type SpriteRegionPlayOptions = Omit<PlayOptions, 'loop'> & {
|
|
|
1352
1758
|
declare class StreamSound {
|
|
1353
1759
|
readonly name: string;
|
|
1354
1760
|
private ctx;
|
|
1355
|
-
private
|
|
1761
|
+
private urls;
|
|
1762
|
+
private urlIndex;
|
|
1356
1763
|
private destination;
|
|
1357
1764
|
private el;
|
|
1358
1765
|
private node;
|
|
1359
1766
|
private gain;
|
|
1360
1767
|
private disposed;
|
|
1361
|
-
|
|
1768
|
+
private wantPlaying;
|
|
1769
|
+
private resolveEnded;
|
|
1770
|
+
private _ended;
|
|
1771
|
+
/**
|
|
1772
|
+
* `urls` is a codec ladder in preference order. When the element reports
|
|
1773
|
+
* a media error on one, the next is tried, and playback resumes if it was
|
|
1774
|
+
* playing.
|
|
1775
|
+
*/
|
|
1776
|
+
constructor(name: string, ctx: AudioContext, urls: string | readonly string[], destination: AudioNode);
|
|
1777
|
+
/** The URL the element is using now. */
|
|
1778
|
+
get url(): string;
|
|
1779
|
+
/**
|
|
1780
|
+
* Resolves when the current playback ends: the media reached its end
|
|
1781
|
+
* (never, while `loop` is on), `stop()` ran, or the stream was disposed.
|
|
1782
|
+
* Each `play()` from a stopped state starts a new one.
|
|
1783
|
+
*/
|
|
1784
|
+
get ended(): Promise<void>;
|
|
1362
1785
|
/** Lazily construct the <audio> element + media-element source on first use. */
|
|
1363
1786
|
private ensure;
|
|
1787
|
+
/**
|
|
1788
|
+
* Start or resume playback. Resolves `true` once the element is playing,
|
|
1789
|
+
* `false` when the browser refused (autoplay policy before a user gesture,
|
|
1790
|
+
* or no playable source). v1 resolved `void` either way, so a blocked play
|
|
1791
|
+
* was indistinguishable from a working one; retry from a gesture handler
|
|
1792
|
+
* on `false`.
|
|
1793
|
+
*/
|
|
1364
1794
|
play(options?: {
|
|
1365
1795
|
volume?: number;
|
|
1366
1796
|
loop?: boolean;
|
|
1367
|
-
}): Promise<
|
|
1797
|
+
}): Promise<boolean>;
|
|
1368
1798
|
pause(): void;
|
|
1369
1799
|
stop(): void;
|
|
1370
1800
|
seek(seconds: number): void;
|
|
@@ -1373,6 +1803,9 @@ declare class StreamSound {
|
|
|
1373
1803
|
get paused(): boolean;
|
|
1374
1804
|
setVolume(v: number): void;
|
|
1375
1805
|
fade(opts: FadeOptions): Promise<void>;
|
|
1806
|
+
private settleEnded;
|
|
1807
|
+
/** Move to the next URL of the ladder on a media error. */
|
|
1808
|
+
private handleError;
|
|
1376
1809
|
dispose(): void;
|
|
1377
1810
|
}
|
|
1378
1811
|
|
|
@@ -1390,6 +1823,14 @@ declare class StreamSound {
|
|
|
1390
1823
|
type VariantStrategy = 'random' | 'no-repeat' | 'shuffle-bag';
|
|
1391
1824
|
interface VariantsOptions {
|
|
1392
1825
|
strategy?: VariantStrategy;
|
|
1826
|
+
/**
|
|
1827
|
+
* Relative weight per variant, in load order. `[3, 1, 1]` makes the first
|
|
1828
|
+
* take three times as likely as each of the others. Missing entries
|
|
1829
|
+
* default to 1; a weight of 0 never plays (unless every weight is 0).
|
|
1830
|
+
* `'no-repeat'` still never repeats; `'shuffle-bag'` puts
|
|
1831
|
+
* `round(weight)` copies of each take in the bag.
|
|
1832
|
+
*/
|
|
1833
|
+
weights?: readonly number[];
|
|
1393
1834
|
}
|
|
1394
1835
|
/**
|
|
1395
1836
|
* A bundle of N alternate sounds that play one at a time. The classic
|
|
@@ -1405,9 +1846,19 @@ declare class Variants {
|
|
|
1405
1846
|
readonly count: number;
|
|
1406
1847
|
private sounds;
|
|
1407
1848
|
private strategy;
|
|
1849
|
+
private weights;
|
|
1408
1850
|
private lastIndex;
|
|
1409
1851
|
private bag;
|
|
1410
1852
|
constructor(name: string, sounds: Sound[], options?: VariantsOptions);
|
|
1853
|
+
/**
|
|
1854
|
+
* Cap simultaneous voices across the whole bundle and/or set a retrigger
|
|
1855
|
+
* cooldown. Every variant shares this one limit.
|
|
1856
|
+
*/
|
|
1857
|
+
setLimit(limit: SoundLimit | null): void;
|
|
1858
|
+
/** The bundle's current limit (empty object when unlimited). */
|
|
1859
|
+
get soundLimit(): Readonly<SoundLimit>;
|
|
1860
|
+
/** Change the pick weights. Same rules as `VariantsOptions.weights`. */
|
|
1861
|
+
setWeights(weights: readonly number[] | null): void;
|
|
1411
1862
|
/**
|
|
1412
1863
|
* Index of the variant the most recent `play()` picked, or `-1` before the
|
|
1413
1864
|
* first one. Read it when something outside the mix has to follow the
|
|
@@ -1420,6 +1871,87 @@ declare class Variants {
|
|
|
1420
1871
|
/** Force the next pick to use a specific variant index. Useful for tests. */
|
|
1421
1872
|
playIndex(index: number, options?: PlayOptions): Voice;
|
|
1422
1873
|
private pick;
|
|
1874
|
+
private choose;
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
type Vec3 = readonly [number, number, number];
|
|
1878
|
+
/**
|
|
1879
|
+
* The listener of the 3D scene: where the ears are and which way they face.
|
|
1880
|
+
* A thin wrapper over `AudioContext.listener` that glides like the
|
|
1881
|
+
* spatializers do and covers browsers that only have the deprecated
|
|
1882
|
+
* `setPosition` / `setOrientation` methods. Reach it with `engine.listener`.
|
|
1883
|
+
*/
|
|
1884
|
+
declare class Listener {
|
|
1885
|
+
private ctx;
|
|
1886
|
+
private glide;
|
|
1887
|
+
constructor(ctx: AudioContext, glide?: number);
|
|
1888
|
+
/** Time constant (seconds) for position and orientation changes. 0 jumps. */
|
|
1889
|
+
setGlide(seconds: number): void;
|
|
1890
|
+
/** Move the listener to world position (x, y, z). */
|
|
1891
|
+
setPosition(x: number, y: number, z: number): void;
|
|
1892
|
+
/**
|
|
1893
|
+
* Point the listener. `forward` is where the nose points, `up` is the top
|
|
1894
|
+
* of the head. Defaults match Web Audio: facing -z with +y up.
|
|
1895
|
+
*/
|
|
1896
|
+
setOrientation(forward: Vec3, up?: Vec3): void;
|
|
1897
|
+
/** Current position, read from the listener's params (zeros where unsupported). */
|
|
1898
|
+
get position(): [number, number, number];
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
/**
|
|
1902
|
+
* The Master stage: headroom gain, then the master fader (volume and mute),
|
|
1903
|
+
* then an optional soft limiter, then the destination. Buses connect their
|
|
1904
|
+
* output to master.input. Reach it with `engine.master`.
|
|
1905
|
+
*
|
|
1906
|
+
* Headroom is a static gain offset; the limiter is a fast-attack
|
|
1907
|
+
* DynamicsCompressorNode that catches most peaks the headroom can't tame when
|
|
1908
|
+
* heavy FX stack on top of busy mixes. Note it is best-effort, not a true
|
|
1909
|
+
* brick-wall limiter — with a finite attack and no lookahead, transient peaks
|
|
1910
|
+
* above the threshold can still pass, so it does not guarantee a hard ceiling.
|
|
1911
|
+
*/
|
|
1912
|
+
declare class Master {
|
|
1913
|
+
readonly input: GainNode;
|
|
1914
|
+
/** Master fader: volume × mute. Sits after headroom, before the limiter. */
|
|
1915
|
+
private fader;
|
|
1916
|
+
private _volume;
|
|
1917
|
+
private _muted;
|
|
1918
|
+
private headroomDb;
|
|
1919
|
+
private ctx;
|
|
1920
|
+
private limiterNode;
|
|
1921
|
+
private limiterCfg;
|
|
1922
|
+
private destination;
|
|
1923
|
+
private _meterAnalyser;
|
|
1924
|
+
private _meterBuf;
|
|
1925
|
+
constructor(ctx: AudioContext, config?: MasterConfig);
|
|
1926
|
+
/** Master volume (0..1). The setter ramps over 10 ms. */
|
|
1927
|
+
get volume(): number;
|
|
1928
|
+
set volume(v: number);
|
|
1929
|
+
/** Mute everything. Volume is kept and comes back on unmute. */
|
|
1930
|
+
get muted(): boolean;
|
|
1931
|
+
set muted(v: boolean);
|
|
1932
|
+
/**
|
|
1933
|
+
* Fade the master volume to `target` over `duration` seconds. While muted
|
|
1934
|
+
* the target is stored and applied on unmute.
|
|
1935
|
+
*/
|
|
1936
|
+
fadeTo(target: number, duration: number, curve?: FadeCurve): Promise<void>;
|
|
1937
|
+
setHeadroom(db: number): void;
|
|
1938
|
+
get headroom(): number;
|
|
1939
|
+
/**
|
|
1940
|
+
* Enable or update the master limiter. Pass `null` to disable.
|
|
1941
|
+
* The limiter sits between master gain and destination.
|
|
1942
|
+
*/
|
|
1943
|
+
setLimiter(cfg: MasterLimiterConfig | null): void;
|
|
1944
|
+
/** Live gain reduction in dB. 0 if no limiter is engaged. */
|
|
1945
|
+
get reduction(): number;
|
|
1946
|
+
/**
|
|
1947
|
+
* Live amplitude readout on the master input. Returns `{ rms, peak }`
|
|
1948
|
+
* as linear values in [0..1]. The first call lazily attaches an
|
|
1949
|
+
* AnalyserNode as a passive sibling of the master gain — no audio-path
|
|
1950
|
+
* change. Same shape as `bus.meter()` and `voice.level()`.
|
|
1951
|
+
*/
|
|
1952
|
+
meter(): AudioLevel;
|
|
1953
|
+
dispose(): void;
|
|
1954
|
+
private rewire;
|
|
1423
1955
|
}
|
|
1424
1956
|
|
|
1425
1957
|
interface SnapshotState {
|
|
@@ -1428,6 +1960,19 @@ interface SnapshotState {
|
|
|
1428
1960
|
muted: boolean;
|
|
1429
1961
|
}>;
|
|
1430
1962
|
parameters: Record<string, number>;
|
|
1963
|
+
/**
|
|
1964
|
+
* Send levels, keyed by source bus then target bus:
|
|
1965
|
+
* `{ music: { reverb: 0.3 } }`. A send the snapshot names that doesn't
|
|
1966
|
+
* exist on the live mix is skipped; sends aren't created or removed.
|
|
1967
|
+
*/
|
|
1968
|
+
sends?: Record<string, Record<string, number>>;
|
|
1969
|
+
/**
|
|
1970
|
+
* FX bypass flags per bus, in chain order: `{ sfx: [false, true] }`.
|
|
1971
|
+
* Applied by position; extra entries are ignored.
|
|
1972
|
+
*/
|
|
1973
|
+
fx?: Record<string, boolean[]>;
|
|
1974
|
+
/** Buses that are soloed in this snapshot. Applying it solos exactly these. */
|
|
1975
|
+
solo?: string[];
|
|
1431
1976
|
}
|
|
1432
1977
|
interface ApplyOptions {
|
|
1433
1978
|
/** Crossfade duration in seconds. Default 0 (snap). */
|
|
@@ -1447,7 +1992,10 @@ declare class Snapshot {
|
|
|
1447
1992
|
readonly state: SnapshotState;
|
|
1448
1993
|
private getBus;
|
|
1449
1994
|
private getParam;
|
|
1450
|
-
|
|
1995
|
+
private allBuses;
|
|
1996
|
+
constructor(name: string, state: SnapshotState, getBus: (name: string) => Bus | undefined, getParam: (name: string) => Parameter | undefined, allBuses?: () => Iterable<Bus>);
|
|
1997
|
+
private findSend;
|
|
1998
|
+
private applyDiscrete;
|
|
1451
1999
|
apply(opts?: ApplyOptions): Promise<void>;
|
|
1452
2000
|
/**
|
|
1453
2001
|
* Snap the live mix to a linear interpolation between this snapshot and
|
|
@@ -1478,7 +2026,23 @@ interface Engine<TBusName extends string = string> {
|
|
|
1478
2026
|
/** Live AudioContext. Constructs one on first read. Throws if engine is closed. */
|
|
1479
2027
|
readonly context: AudioContext;
|
|
1480
2028
|
unlock(): Promise<void>;
|
|
2029
|
+
/**
|
|
2030
|
+
* Suspend audio on the app's behalf: a pause menu, an ad break. Unlike the
|
|
2031
|
+
* automatic suspend on tab hide, this one sticks — returning to the tab
|
|
2032
|
+
* doesn't resume it. `resume()` (or `unlock()`) does.
|
|
2033
|
+
*/
|
|
2034
|
+
suspend(): Promise<void>;
|
|
2035
|
+
/** Undo `suspend()`. Same as `unlock()`. */
|
|
2036
|
+
resume(): Promise<void>;
|
|
1481
2037
|
close(): Promise<void>;
|
|
2038
|
+
/**
|
|
2039
|
+
* The master stage: `volume`, `muted`, `fadeTo()`, `headroom`,
|
|
2040
|
+
* `setLimiter()`, `reduction` and `meter()`. Builds the audio graph on
|
|
2041
|
+
* first read.
|
|
2042
|
+
*/
|
|
2043
|
+
readonly master: Master;
|
|
2044
|
+
/** The 3D listener: `setPosition()`, `setOrientation()`. */
|
|
2045
|
+
readonly listener: Listener;
|
|
1482
2046
|
/**
|
|
1483
2047
|
* Load and decode an audio asset.
|
|
1484
2048
|
*
|
|
@@ -1514,6 +2078,16 @@ interface Engine<TBusName extends string = string> {
|
|
|
1514
2078
|
* argument — a URL or codec ladder.
|
|
1515
2079
|
*/
|
|
1516
2080
|
loadVariants(name: string, urls: readonly (string | readonly string[])[], options?: LoadSoundOptions & VariantsOptions): Promise<Variants>;
|
|
2081
|
+
/**
|
|
2082
|
+
* Remove an asset of any kind — sound, sprite, variants, music or stream —
|
|
2083
|
+
* registered under `name`, and evict its decoded buffers from the cache
|
|
2084
|
+
* unless `{ evictBuffer: false }`. Voices of sounds, sprites and variants
|
|
2085
|
+
* keep playing until they end; music instances and streams are stopped,
|
|
2086
|
+
* since a loop never ends on its own. No-op for an unknown name.
|
|
2087
|
+
*/
|
|
2088
|
+
unload(name: string, options?: {
|
|
2089
|
+
evictBuffer?: boolean;
|
|
2090
|
+
}): void;
|
|
1517
2091
|
/** Look up a previously loaded variants bundle. Throws SoundNotFoundError on miss. */
|
|
1518
2092
|
variants(name: string): Variants;
|
|
1519
2093
|
/** True if `name` was loaded as a variants bundle. */
|
|
@@ -1537,6 +2111,7 @@ interface Engine<TBusName extends string = string> {
|
|
|
1537
2111
|
/** Register a Sound from an AudioBuffer you constructed yourself (procedural, custom-decoded, time-stretched). */
|
|
1538
2112
|
createSound(name: string, buffer: AudioBuffer, options?: {
|
|
1539
2113
|
bus?: string;
|
|
2114
|
+
limit?: SoundLimit;
|
|
1540
2115
|
}): Sound;
|
|
1541
2116
|
/** Drop a sound from the registry. Active voices keep playing until they end naturally. */
|
|
1542
2117
|
removeSound(name: string): void;
|
|
@@ -1602,6 +2177,8 @@ interface Engine<TBusName extends string = string> {
|
|
|
1602
2177
|
* Live amplitude readout on the master input. Same `{ rms, peak }`
|
|
1603
2178
|
* shape as `bus.meter()` and `voice.level()`, just at the top of the
|
|
1604
2179
|
* chain. First call lazily attaches a passive AnalyserNode tap.
|
|
2180
|
+
*
|
|
2181
|
+
* @deprecated Use `engine.master.meter()`.
|
|
1605
2182
|
*/
|
|
1606
2183
|
masterMeter(): AudioLevel;
|
|
1607
2184
|
/**
|
|
@@ -1675,46 +2252,6 @@ interface CrossfadeOptions {
|
|
|
1675
2252
|
*/
|
|
1676
2253
|
declare function createEngine<TBusName extends string = string>(config?: EngineConfig<TBusName>): Engine<TBusName>;
|
|
1677
2254
|
|
|
1678
|
-
/**
|
|
1679
|
-
* The Master stage. Headroom-aware gain into an optional soft limiter, then to
|
|
1680
|
-
* destination. Buses connect their output to master.input.
|
|
1681
|
-
*
|
|
1682
|
-
* Headroom is a static gain offset; the limiter is a fast-attack
|
|
1683
|
-
* DynamicsCompressorNode that catches most peaks the headroom can't tame when
|
|
1684
|
-
* heavy FX stack on top of busy mixes. Note it is best-effort, not a true
|
|
1685
|
-
* brick-wall limiter — with a finite attack and no lookahead, transient peaks
|
|
1686
|
-
* above the threshold can still pass, so it does not guarantee a hard ceiling.
|
|
1687
|
-
*/
|
|
1688
|
-
declare class Master {
|
|
1689
|
-
readonly input: GainNode;
|
|
1690
|
-
private headroomDb;
|
|
1691
|
-
private ctx;
|
|
1692
|
-
private limiterNode;
|
|
1693
|
-
private limiterCfg;
|
|
1694
|
-
private destination;
|
|
1695
|
-
private _meterAnalyser;
|
|
1696
|
-
private _meterBuf;
|
|
1697
|
-
constructor(ctx: AudioContext, config?: MasterConfig);
|
|
1698
|
-
setHeadroom(db: number): void;
|
|
1699
|
-
get headroom(): number;
|
|
1700
|
-
/**
|
|
1701
|
-
* Enable or update the master limiter. Pass `null` to disable.
|
|
1702
|
-
* The limiter sits between master gain and destination.
|
|
1703
|
-
*/
|
|
1704
|
-
setLimiter(cfg: MasterLimiterConfig | null): void;
|
|
1705
|
-
/** Live gain reduction in dB. 0 if no limiter is engaged. */
|
|
1706
|
-
get reduction(): number;
|
|
1707
|
-
/**
|
|
1708
|
-
* Live amplitude readout on the master input. Returns `{ rms, peak }`
|
|
1709
|
-
* as linear values in [0..1]. The first call lazily attaches an
|
|
1710
|
-
* AnalyserNode as a passive sibling of the master gain — no audio-path
|
|
1711
|
-
* change. Same shape as `bus.meter()` and `voice.level()`.
|
|
1712
|
-
*/
|
|
1713
|
-
meter(): AudioLevel;
|
|
1714
|
-
dispose(): void;
|
|
1715
|
-
private rewire;
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
2255
|
/**
|
|
1719
2256
|
* Codec capability + asset-source picking.
|
|
1720
2257
|
*
|
|
@@ -1774,4 +2311,4 @@ type NormalizeFlag = boolean | LoudnessOptions;
|
|
|
1774
2311
|
declare function applyLoudnessNormalization(buffer: AudioBuffer, flag: NormalizeFlag, ctx?: BaseAudioContext): AudioBuffer;
|
|
1775
2312
|
declare function computeNormalizationGain(buffer: AudioBuffer, opts: Required<LoudnessOptions>): number;
|
|
1776
2313
|
|
|
1777
|
-
export { AggregateDecodeError, type ApplyOptions, type AssetResolver, type AudioLevel, type AudioMimeType, Bus, type BusConfig, BusGroup, BusNotFoundError, Compressor, type CompressorConfig, type ConcurrencyConfig, type CrossfadeOptions, type DecodeAttempt, DecodeError, type DistanceModel, 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, Music, type MusicLoadOptions, type MusicParts, type MusicPlayOptions, type MusicState, MusicVoice, type NormalizeFlag, Parameter, type ParameterCurve, type PlayOptions, PreloadError, type PreloadFailure, type PreloadItem, type PreloadOptions, type PreloadProgressEvent, type ResolveAssetContext, type ResolvedAsset, Reverb, type ReverbConfig, Send, type SendOptions, type SidechainConfig, type SkipToOutroOptions, Snapshot, type SnapshotState, Sound, SoundNotFoundError, type SpatialOptions, Spatializer, Sprite, type SpriteMap, type SpriteRegion, type SpriteRegionPlayOptions, type StopOptions, StreamSound, StretchProcessor, type StretchWorkletNode, type StretchWorkletOptions, type TickSource, type VariantStrategy, Variants, type VariantsOptions, Voice, type VoiceDefaults, type VoiceJitter, ZvukError, applyLoudnessNormalization, canPlay, computeNormalizationGain, createEngine, createStretchWorkletNode, ensureStretchWorklet, mimeForUrl, pickSource, pickSourceOrder };
|
|
2314
|
+
export { AggregateDecodeError, type ApplyOptions, type AssetKind, type AssetResolver, type AudioLevel, type AudioMimeType, type BeatEvent, Bus, type BusConfig, BusGroup, BusNotFoundError, type CacheConfig, Compressor, type CompressorConfig, type ConcurrencyConfig, type CrossfadeOptions, type DecodeAttempt, DecodeError, type DistanceModel, type DuckOptions, Ducker, type DuckerConfig, type Engine, EngineClosedError, type EngineConfig, type EngineState, type FadeCurve, type FadeOptions, Filter, type FilterConfig, type FilterKind, type FxInsert, Listener, type LoadSoundOptions, type LoudnessOptions, Master, type MasterConfig, type MasterLimiterConfig, Music, type MusicGrid, type MusicLoadOptions, type MusicParts, type MusicPlayOptions, type MusicState, MusicVoice, type NormalizeFlag, Parameter, type ParameterCurve, type PlayOptions, type PreloadBytesEvent, PreloadError, type PreloadFailure, type PreloadItem, type PreloadMusicItem, type PreloadOptions, type PreloadProgressEvent, type PreloadSoundItem, type PreloadSpriteItem, type PreloadVariantsItem, type ResolveAssetContext, type ResolvedAsset, Reverb, type ReverbConfig, Send, type SendOptions, type SidechainConfig, type SkipToOutroOptions, Snapshot, type SnapshotState, Sound, type SoundLimit, SoundNotFoundError, type SpatialOptions, Spatializer, Sprite, type SpriteMap, type SpriteRegion, SpriteRegionNotFoundError, type SpriteRegionPlayOptions, type StealStrategy, type StopOptions, StreamSound, StretchProcessor, type StretchWorkletNode, type StretchWorkletOptions, type TickSource, type VariantStrategy, Variants, type VariantsOptions, Voice, type VoiceCue, type VoiceDefaults, type VoiceJitter, ZvukError, applyLoudnessNormalization, canPlay, computeNormalizationGain, createEngine, createStretchWorkletNode, ensureStretchWorklet, mimeForUrl, pickSource, pickSourceOrder };
|