@avoid.quest/audio 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +70 -2
- package/dist/effects/index.d.ts +266 -0
- package/dist/effects/index.js +744 -0
- package/dist/effects/index.js.map +1 -0
- package/dist/errors-BT9HxDLn.js +74 -0
- package/dist/errors-BT9HxDLn.js.map +1 -0
- package/dist/errors-ChTQFwuZ.d.ts +53 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/midi/index.d.ts +162 -0
- package/dist/midi/index.js +338 -0
- package/dist/midi/index.js.map +1 -0
- package/dist/playback/index.d.ts +349 -0
- package/dist/playback/index.js +1372 -0
- package/dist/playback/index.js.map +1 -0
- package/dist/queue/index.d.ts +144 -0
- package/dist/queue/index.js +1062 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/recognize/index.d.ts +161 -0
- package/dist/recognize/index.js +2816 -0
- package/dist/recognize/index.js.map +1 -0
- package/dist/routing/index.d.ts +140 -0
- package/dist/routing/index.js +678 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/sync/index.d.ts +282 -0
- package/dist/sync/index.js +1103 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/worklet-loader-BvEW0oVO.d.ts +44 -0
- package/dist/worklet-loader-S7R8ZAmP.js +175 -0
- package/dist/worklet-loader-S7R8ZAmP.js.map +1 -0
- package/dist/worklets/couch-live.d.ts +1 -0
- package/dist/worklets/couch-live.js +365 -0
- package/dist/worklets/couch-live.js.map +1 -0
- package/dist/worklets/meter.d.ts +7 -0
- package/dist/worklets/meter.js +80 -0
- package/dist/worklets/meter.js.map +1 -0
- package/package.json +109 -4
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Schedule, Scope } from "effect";
|
|
2
|
+
import { n as AudioDecodeError, o as AudioPlaybackError, t as AudioCaptureError, u as AudioUnsupportedError } from "../errors-ChTQFwuZ.js";
|
|
3
|
+
import Hls, { HlsConfig } from "hls.js";
|
|
4
|
+
interface AudioContextOptionsInput {
|
|
5
|
+
readonly isMobile?: boolean;
|
|
6
|
+
readonly isFirefox?: boolean;
|
|
7
|
+
readonly sampleRate?: number;
|
|
8
|
+
}
|
|
9
|
+
interface AudioContextSnapshot {
|
|
10
|
+
readonly state: "suspended" | "running" | "closed";
|
|
11
|
+
readonly sampleRate: number;
|
|
12
|
+
readonly currentTime: number;
|
|
13
|
+
readonly baseLatency: number | undefined;
|
|
14
|
+
readonly outputLatency: number | undefined;
|
|
15
|
+
}
|
|
16
|
+
interface AudioContextHandle {
|
|
17
|
+
readonly context: AudioContext;
|
|
18
|
+
readonly ensureRunning: () => Effect.Effect<void, AudioPlaybackError>;
|
|
19
|
+
readonly getSnapshot: () => AudioContextSnapshot;
|
|
20
|
+
readonly close: () => Effect.Effect<void>;
|
|
21
|
+
}
|
|
22
|
+
interface AudioContextLayerOptions extends AudioContextOptionsInput {
|
|
23
|
+
/**
|
|
24
|
+
* Optional pre-created `AudioContext` instance to wrap instead of
|
|
25
|
+
* constructing a new browser `AudioContext`.
|
|
26
|
+
*/
|
|
27
|
+
readonly context?: AudioContext;
|
|
28
|
+
/**
|
|
29
|
+
* Optional custom `AudioContext` factory (useful in tests or custom hosts).
|
|
30
|
+
*/
|
|
31
|
+
readonly createContext?: (options: AudioContextOptions) => AudioContext;
|
|
32
|
+
/**
|
|
33
|
+
* Whether closing the layer `Scope` closes the underlying `AudioContext`.
|
|
34
|
+
* Defaults to `true` when constructed by the layer, and `false` when an
|
|
35
|
+
* existing `context` is supplied.
|
|
36
|
+
*/
|
|
37
|
+
readonly closeOnRelease?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Automatically attach passive user-gesture unlock listeners while suspended.
|
|
40
|
+
* Defaults to `true`.
|
|
41
|
+
*/
|
|
42
|
+
readonly unlockOnGesture?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Custom `EventTarget` for gesture unlock listeners (defaults to `window`).
|
|
45
|
+
*/
|
|
46
|
+
readonly unlockTarget?: EventTarget;
|
|
47
|
+
}
|
|
48
|
+
declare const AudioContextService_base: Context.ServiceClass<AudioContextService, "@avoid.quest/audio/AudioContextService", AudioContextHandle>;
|
|
49
|
+
export declare class AudioContextService extends AudioContextService_base {}
|
|
50
|
+
/**
|
|
51
|
+
* Computes browser-aware `AudioContextOptions`:
|
|
52
|
+
* - Mobile uses a 128-frame latency hint (`128 / 48_000`) to avoid glitches.
|
|
53
|
+
* - Firefox omits forced `sampleRate` because forcing 48 kHz breaks some device drivers.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createAudioContextOptions(options?: AudioContextOptionsInput): AudioContextOptions;
|
|
56
|
+
/**
|
|
57
|
+
* Normalizes Safari/iOS `"interrupted"` state to `"suspended"`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function normalizeAudioContextState(state: AudioContextState | "interrupted"): "suspended" | "running" | "closed";
|
|
60
|
+
export declare function snapshotAudioContext(context: AudioContext): AudioContextSnapshot;
|
|
61
|
+
/**
|
|
62
|
+
* Deduplicates concurrent `AudioContext.resume()` calls and normalizes iOS `"interrupted"` state.
|
|
63
|
+
*/
|
|
64
|
+
export declare function ensureAudioContextRunning(context: AudioContext): Effect.Effect<void, AudioPlaybackError>;
|
|
65
|
+
/**
|
|
66
|
+
* Attaches persistent passive user-gesture listeners to unlock a suspended
|
|
67
|
+
* `AudioContext` (including iOS Safari, where `touchstart` or early gestures
|
|
68
|
+
* may resolve without transitioning `state` to `"running"`). Listeners remain
|
|
69
|
+
* active across gestures until `context.state === "running"` (or `"closed"`),
|
|
70
|
+
* or until the returned cleanup callback is invoked.
|
|
71
|
+
*/
|
|
72
|
+
export declare function attachGestureUnlock(context: AudioContext, target?: EventTarget | undefined): () => void;
|
|
73
|
+
/**
|
|
74
|
+
* Acquires a `Scope`-managed `AudioContextHandle`, optionally attaching
|
|
75
|
+
* user-gesture unlock listeners and releasing listeners + closing owned
|
|
76
|
+
* `AudioContext` instances when the `Scope` closes.
|
|
77
|
+
*/
|
|
78
|
+
export declare function acquireAudioContext(options?: AudioContextLayerOptions): Effect.Effect<AudioContextHandle, AudioUnsupportedError, Scope.Scope>;
|
|
79
|
+
/**
|
|
80
|
+
* Builds a scoped Effect v4 `Layer` providing `AudioContextService`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function makeAudioContextLayer(options?: AudioContextLayerOptions): Layer.Layer<AudioContextService, AudioUnsupportedError>;
|
|
83
|
+
interface ChannelSelection {
|
|
84
|
+
readonly left: number;
|
|
85
|
+
readonly right: number;
|
|
86
|
+
}
|
|
87
|
+
interface DeviceCaptureOptions {
|
|
88
|
+
readonly deviceId?: string;
|
|
89
|
+
readonly stream?: MediaStream;
|
|
90
|
+
readonly channelCount?: number;
|
|
91
|
+
readonly channelSelection?: ChannelSelection;
|
|
92
|
+
readonly mediaDevices?: Pick<MediaDevices, "getUserMedia">;
|
|
93
|
+
readonly signal?: AbortSignal;
|
|
94
|
+
readonly onEnded?: () => void;
|
|
95
|
+
}
|
|
96
|
+
interface DisplayAudioOptions {
|
|
97
|
+
readonly mediaDevices?: Pick<MediaDevices, "getDisplayMedia">;
|
|
98
|
+
readonly requireBrowserTab?: boolean;
|
|
99
|
+
readonly signal?: AbortSignal;
|
|
100
|
+
}
|
|
101
|
+
interface LiveInputCapture {
|
|
102
|
+
readonly stream: MediaStream;
|
|
103
|
+
readonly sourceNode: MediaStreamAudioSourceNode;
|
|
104
|
+
readonly outputNode: GainNode;
|
|
105
|
+
readonly outputChannelCount: 1 | 2;
|
|
106
|
+
readonly stop: () => void;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Requests browser tab audio via `getDisplayMedia` with Chromium self-capture
|
|
110
|
+
* exclusion hints, abort/cancellation cleanup, and a feedback-loop guard
|
|
111
|
+
* verifying `displaySurface === "browser"` and at least one live audio track.
|
|
112
|
+
*/
|
|
113
|
+
export declare function requestDisplayAudio(options?: DisplayAudioOptions): Effect.Effect<MediaStream, AudioCaptureError>;
|
|
114
|
+
/**
|
|
115
|
+
* Acquires a live audio input (`getUserMedia` or a pre-acquired `MediaStream`),
|
|
116
|
+
* wires optional channel selection routing into an output `GainNode`, supports
|
|
117
|
+
* `AbortSignal` and `Scope`/fiber cancellation without leaking pending
|
|
118
|
+
* `MediaStreamTrack`s, and automatically stops tracks + disconnects nodes when
|
|
119
|
+
* the Effect `Scope` closes.
|
|
120
|
+
*/
|
|
121
|
+
export declare function acquireInputCapture(context: AudioContext, options?: DeviceCaptureOptions): Effect.Effect<LiveInputCapture, AudioCaptureError, Scope.Scope>;
|
|
122
|
+
export declare const MIN_PLAYBACK_RATE = 0.5;
|
|
123
|
+
export declare const MAX_PLAYBACK_RATE = 2;
|
|
124
|
+
export declare const DEFAULT_MEDIA_READY_TIMEOUT_MS = 20000;
|
|
125
|
+
export declare const DEFAULT_STALL_WATCHDOG_MS = 6000;
|
|
126
|
+
export declare const DEFAULT_MAX_RECOVERY_DELAY_MS = 30000;
|
|
127
|
+
interface StallRecoveryConfig {
|
|
128
|
+
readonly baseDelayMs?: number;
|
|
129
|
+
readonly maxDelayMs?: number;
|
|
130
|
+
readonly maxAttempts?: number;
|
|
131
|
+
}
|
|
132
|
+
interface MediaEngineLoadOptions {
|
|
133
|
+
readonly startPositionSeconds?: number;
|
|
134
|
+
readonly allowNativeHls?: boolean;
|
|
135
|
+
readonly hlsConfig?: Partial<HlsConfig>;
|
|
136
|
+
readonly crossOrigin?: "" | "anonymous" | "use-credentials" | null;
|
|
137
|
+
/**
|
|
138
|
+
* When `true`, `load()` waits for metadata/playable readiness
|
|
139
|
+
* (`loadedmetadata` / `canplay` / `MANIFEST_PARSED`) and fails with
|
|
140
|
+
* `MEDIA_READY_TIMEOUT` after `readyTimeoutMs` (default `DEFAULT_MEDIA_READY_TIMEOUT_MS`).
|
|
141
|
+
*/
|
|
142
|
+
readonly waitForReady?: boolean;
|
|
143
|
+
readonly readyTimeoutMs?: number;
|
|
144
|
+
}
|
|
145
|
+
interface MediaEngineOptions {
|
|
146
|
+
readonly element: HTMLAudioElement | HTMLVideoElement;
|
|
147
|
+
readonly allowNativeHls?: boolean;
|
|
148
|
+
readonly hlsConfig?: Partial<HlsConfig>;
|
|
149
|
+
readonly stallRecovery?: StallRecoveryConfig;
|
|
150
|
+
readonly mediaReadyTimeoutMs?: number;
|
|
151
|
+
readonly stallWatchdogMs?: number;
|
|
152
|
+
readonly userAgent?: string;
|
|
153
|
+
readonly loadHls?: () => Promise<{
|
|
154
|
+
readonly default: typeof Hls;
|
|
155
|
+
}>;
|
|
156
|
+
readonly onStall?: (currentTime: number) => void;
|
|
157
|
+
readonly onStreamError?: (currentTime: number, error: AudioPlaybackError) => void;
|
|
158
|
+
}
|
|
159
|
+
interface MediaEngineSnapshot {
|
|
160
|
+
readonly src: string | undefined;
|
|
161
|
+
readonly paused: boolean;
|
|
162
|
+
readonly currentTime: number;
|
|
163
|
+
readonly duration: number | undefined;
|
|
164
|
+
readonly playbackRate: number;
|
|
165
|
+
readonly preservesPitch: boolean;
|
|
166
|
+
readonly volume: number;
|
|
167
|
+
readonly muted: boolean;
|
|
168
|
+
readonly mode: "idle" | "native" | "native-hls" | "hls.js";
|
|
169
|
+
}
|
|
170
|
+
interface MediaEngine {
|
|
171
|
+
readonly element: HTMLAudioElement | HTMLVideoElement;
|
|
172
|
+
readonly load: (url: string, options?: MediaEngineLoadOptions) => Effect.Effect<void, AudioPlaybackError>;
|
|
173
|
+
readonly play: () => Effect.Effect<void, AudioPlaybackError>;
|
|
174
|
+
readonly pause: () => Effect.Effect<void>;
|
|
175
|
+
readonly seek: (seconds: number) => Effect.Effect<void>;
|
|
176
|
+
readonly setPlaybackRate: (rate: number) => Effect.Effect<number>;
|
|
177
|
+
readonly setPreservesPitch: (preserve: boolean) => Effect.Effect<boolean>;
|
|
178
|
+
readonly setVolume: (volume: number) => Effect.Effect<number>;
|
|
179
|
+
readonly setMuted: (muted: boolean) => Effect.Effect<boolean>;
|
|
180
|
+
readonly refreshUrl: (url: string, seekPositionSeconds?: number) => Effect.Effect<void, AudioPlaybackError>;
|
|
181
|
+
readonly runWithStallRecovery: <A, R>(effect: Effect.Effect<A, AudioPlaybackError, R>) => Effect.Effect<A, AudioPlaybackError, R>;
|
|
182
|
+
readonly getSnapshot: () => MediaEngineSnapshot;
|
|
183
|
+
readonly dispose: () => Effect.Effect<void>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Clamps playback speed into the supported `[0.5, 2.0]` range.
|
|
187
|
+
*/
|
|
188
|
+
export declare function clampPlaybackRate(rate: number): number;
|
|
189
|
+
/**
|
|
190
|
+
* Sets pitch preservation on an `HTMLMediaElement`, including Safari < 17 `webkitPreservesPitch`.
|
|
191
|
+
*/
|
|
192
|
+
export declare function applyPreservesPitch(element: HTMLMediaElement, preserve: boolean): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Detects `.m3u8` HLS streams, checking one level deep inside `?url=` proxy params.
|
|
195
|
+
*/
|
|
196
|
+
export declare function isHlsUrl(url: string, depth?: number): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Returns true for Safari / Apple WebKit browsers (excluding Chrome/Edge/Firefox).
|
|
199
|
+
*/
|
|
200
|
+
export declare function isWebKitBrowser(userAgent?: string | undefined): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Uses native HLS only on Safari/WebKit with `application/vnd.apple.mpegurl` support.
|
|
203
|
+
* Chrome stays on `hls.js` because native Chrome HLS rejects certain MP3/AAC segments.
|
|
204
|
+
*/
|
|
205
|
+
export declare function shouldUseNativeHls(element: Pick<HTMLMediaElement, "canPlayType">, allowNativeHls?: boolean, userAgent?: string): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Exponential backoff delay calculation matching Radio's recovery schedule:
|
|
208
|
+
* `0ms` for attempt `<= 0`, then `1s, 2s, 4s, 8s, 16s, 30s` cap.
|
|
209
|
+
*/
|
|
210
|
+
export declare function computeStallBackoffMs(attempt: number, baseDelayMs?: number, maxDelayMs?: number): number;
|
|
211
|
+
/**
|
|
212
|
+
* Builds an Effect v4 `Schedule` for bounded exponential stall/disconnect recovery.
|
|
213
|
+
*/
|
|
214
|
+
export declare function createStallRecoverySchedule(config?: StallRecoveryConfig): Schedule.Schedule<number>;
|
|
215
|
+
/**
|
|
216
|
+
* Creates a `Scope`-managed media/HLS playback engine supporting both
|
|
217
|
+
* `HTMLAudioElement` and `HTMLVideoElement` with lazy dynamic `import("hls.js")`,
|
|
218
|
+
* Safari native HLS detection, speed `0.5–2.0` + `preservesPitch`, URL renewal
|
|
219
|
+
* reload, media-ready timeout & stall watchdog, and Effect `Schedule` stall recovery.
|
|
220
|
+
*/
|
|
221
|
+
export declare function createMediaEngine(options: MediaEngineOptions): Effect.Effect<MediaEngine, never, Scope.Scope>;
|
|
222
|
+
export declare const SILENT_WAV_SAMPLE_RATE = 8000;
|
|
223
|
+
export declare const SILENT_WAV_DURATION_SECONDS = 10;
|
|
224
|
+
export declare const SILENT_WAV_HEADER_BYTES = 44;
|
|
225
|
+
/**
|
|
226
|
+
* Sanitizes metadata strings for Bluetooth AVRCP car/headphone displays:
|
|
227
|
+
* strips diacritics via NFKD, maps typographic punctuation to plain ASCII,
|
|
228
|
+
* removes non-printable/non-ASCII chars, collapses whitespace, and falls back
|
|
229
|
+
* to `fallback` (default `"Radio"`).
|
|
230
|
+
*/
|
|
231
|
+
export declare function sanitizeForBluetooth(input: string | null | undefined, fallback?: string): string;
|
|
232
|
+
/**
|
|
233
|
+
* Generates an all-zero mono 16-bit PCM RIFF/WAVE binary buffer.
|
|
234
|
+
* Defaults to Couch's exact 10 s @ 8 kHz keep-alive WAV (160,044 bytes total),
|
|
235
|
+
* ensuring Chromium treats the element as real media (> 5 s) for OS Now Playing / MPRIS.
|
|
236
|
+
*/
|
|
237
|
+
export declare function createSilentWavBytes(durationSeconds?: number, sampleRate?: number): Uint8Array;
|
|
238
|
+
export declare function createSilentWavBlob(durationSeconds?: number, sampleRate?: number): Blob;
|
|
239
|
+
interface MediaSessionMetadataInput {
|
|
240
|
+
readonly title: string;
|
|
241
|
+
readonly artist?: string;
|
|
242
|
+
readonly album?: string;
|
|
243
|
+
readonly artwork?: readonly MediaImage[];
|
|
244
|
+
}
|
|
245
|
+
interface MediaSessionHandlers {
|
|
246
|
+
readonly play?: () => void;
|
|
247
|
+
readonly pause?: () => void;
|
|
248
|
+
readonly stop?: () => void;
|
|
249
|
+
readonly previoustrack?: () => void;
|
|
250
|
+
readonly nexttrack?: () => void;
|
|
251
|
+
readonly seekbackward?: (details: MediaSessionActionDetails) => void;
|
|
252
|
+
readonly seekforward?: (details: MediaSessionActionDetails) => void;
|
|
253
|
+
readonly seekto?: (details: MediaSessionActionDetails) => void;
|
|
254
|
+
}
|
|
255
|
+
interface MediaSessionControllerOptions {
|
|
256
|
+
readonly sanitizeAvrcp?: boolean;
|
|
257
|
+
readonly avrcpFallback?: string;
|
|
258
|
+
readonly enableKeepAlive?: boolean;
|
|
259
|
+
readonly mediaSession?: MediaSession;
|
|
260
|
+
readonly createKeepAliveElement?: () => HTMLAudioElement;
|
|
261
|
+
}
|
|
262
|
+
interface MediaSessionController {
|
|
263
|
+
readonly setMetadata: (metadata: MediaSessionMetadataInput) => void;
|
|
264
|
+
readonly setPlaybackState: (state: MediaSessionPlaybackState) => void;
|
|
265
|
+
readonly setPositionState: (state: {
|
|
266
|
+
readonly duration?: number;
|
|
267
|
+
readonly position?: number;
|
|
268
|
+
readonly playbackRate?: number;
|
|
269
|
+
readonly isLive?: boolean;
|
|
270
|
+
}) => void;
|
|
271
|
+
readonly setHandlers: (handlers: MediaSessionHandlers) => void;
|
|
272
|
+
readonly startKeepAlive: () => Effect.Effect<void>;
|
|
273
|
+
readonly stopKeepAlive: () => void;
|
|
274
|
+
readonly dispose: () => void;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Merged MediaSession controller combining Radio's Bluetooth AVRCP sanitizer
|
|
278
|
+
* and Couch's 10 s silent WAV keep-alive element (`loop: true, volume: 0`, unmuted)
|
|
279
|
+
* with inert transport guards for live streams.
|
|
280
|
+
*/
|
|
281
|
+
export declare function createMediaSessionController(options?: MediaSessionControllerOptions): Effect.Effect<MediaSessionController, never, Scope.Scope>;
|
|
282
|
+
export declare const SAMPLE_MIME_TYPES: {
|
|
283
|
+
readonly mp3: "audio/mpeg";
|
|
284
|
+
readonly ogg: "audio/ogg";
|
|
285
|
+
readonly wav: "audio/wav";
|
|
286
|
+
};
|
|
287
|
+
export declare const SAMPLE_KEY_PATTERN: RegExp;
|
|
288
|
+
export declare const SAMPLER_MIN_SLICE_DURATION = 0.1;
|
|
289
|
+
export declare const SAMPLER_MAX_SLICE_DURATION = 2;
|
|
290
|
+
export declare const SAMPLER_RELEASE_SECONDS = 1;
|
|
291
|
+
export declare const SAMPLER_VOLUME_RAMP_SECONDS = 0.05;
|
|
292
|
+
export declare const SAMPLER_DEFAULT_BATCH_SIZE = 4;
|
|
293
|
+
interface SamplerOptions {
|
|
294
|
+
readonly destination?: AudioNode;
|
|
295
|
+
readonly initialVolume?: number;
|
|
296
|
+
readonly fetchImpl?: typeof fetch;
|
|
297
|
+
readonly random?: () => number;
|
|
298
|
+
}
|
|
299
|
+
interface SlicePlaybackOptions {
|
|
300
|
+
readonly offsetSeconds?: number;
|
|
301
|
+
readonly durationSeconds?: number;
|
|
302
|
+
readonly attackSeconds?: number;
|
|
303
|
+
readonly releaseSeconds?: number;
|
|
304
|
+
readonly gain?: number;
|
|
305
|
+
readonly playbackRate?: number;
|
|
306
|
+
}
|
|
307
|
+
interface RandomSliceOptions {
|
|
308
|
+
readonly minDurationSeconds?: number;
|
|
309
|
+
readonly maxDurationSeconds?: number;
|
|
310
|
+
readonly releaseSeconds?: number;
|
|
311
|
+
readonly gain?: number;
|
|
312
|
+
}
|
|
313
|
+
interface SampleLoadEntry {
|
|
314
|
+
readonly key: string;
|
|
315
|
+
readonly url: string;
|
|
316
|
+
}
|
|
317
|
+
interface SampleBatchLoadResult {
|
|
318
|
+
readonly loaded: readonly string[];
|
|
319
|
+
readonly failed: readonly {
|
|
320
|
+
readonly key: string;
|
|
321
|
+
readonly error: string;
|
|
322
|
+
}[];
|
|
323
|
+
}
|
|
324
|
+
interface ActiveSliceHandle {
|
|
325
|
+
readonly key: string;
|
|
326
|
+
readonly offsetSeconds: number;
|
|
327
|
+
readonly durationSeconds: number;
|
|
328
|
+
readonly stop: () => void;
|
|
329
|
+
}
|
|
330
|
+
interface BufferSampler {
|
|
331
|
+
readonly masterGain: GainNode;
|
|
332
|
+
readonly registerBuffer: (key: string, buffer: AudioBuffer) => void;
|
|
333
|
+
readonly getBuffer: (key: string) => AudioBuffer | undefined;
|
|
334
|
+
readonly keys: () => readonly string[];
|
|
335
|
+
readonly loadBuffer: (key: string, url: string) => Effect.Effect<AudioBuffer, AudioDecodeError>;
|
|
336
|
+
readonly loadBatch: (entries: readonly SampleLoadEntry[], batchSize?: number) => Effect.Effect<SampleBatchLoadResult>;
|
|
337
|
+
readonly playSlice: (key: string, options?: SlicePlaybackOptions) => ActiveSliceHandle | undefined;
|
|
338
|
+
readonly playRandom: (options?: RandomSliceOptions) => ActiveSliceHandle | undefined;
|
|
339
|
+
readonly setVolume: (value: number) => number;
|
|
340
|
+
readonly activeVoiceCount: () => number;
|
|
341
|
+
readonly stopAll: () => void;
|
|
342
|
+
readonly dispose: () => void;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Creates a Web Audio buffer/slice `Sampler` (`AudioBufferSourceNode -> voiceGain -> masterGain -> destination`).
|
|
346
|
+
* Supports Cwavasape random-slice playback, one-shot envelope triggering, and batched loading.
|
|
347
|
+
*/
|
|
348
|
+
export declare function createSampler(context: BaseAudioContext, options?: SamplerOptions): BufferSampler;
|
|
349
|
+
export type { ActiveSliceHandle, AudioContextHandle, AudioContextLayerOptions, AudioContextOptionsInput, AudioContextSnapshot, BufferSampler, ChannelSelection, DeviceCaptureOptions, DisplayAudioOptions, LiveInputCapture, MediaEngine, MediaEngineLoadOptions, MediaEngineOptions, MediaEngineSnapshot, MediaSessionController, MediaSessionControllerOptions, MediaSessionHandlers, MediaSessionMetadataInput, RandomSliceOptions, SampleBatchLoadResult, SampleLoadEntry, SamplerOptions, SlicePlaybackOptions, StallRecoveryConfig };
|