@litlab/audx 0.0.1 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +96 -53
  2. package/dist/bin.js +1212 -0
  3. package/dist/cc-DgCkkqq8.js +13 -0
  4. package/dist/cc-he3fHS3P.js +12 -0
  5. package/dist/index.d.ts +723 -3
  6. package/dist/index.js +1534 -126
  7. package/dist/react.d.ts +583 -0
  8. package/dist/react.js +1556 -0
  9. package/package.json +64 -39
  10. package/schemas/pack.schema.json +4 -0
  11. package/schemas/patch.schema.json +857 -0
  12. package/dist/codegen/theme-codegen.d.ts +0 -12
  13. package/dist/codegen/theme-codegen.d.ts.map +0 -1
  14. package/dist/codegen/theme-codegen.js +0 -153
  15. package/dist/codegen/theme-codegen.js.map +0 -1
  16. package/dist/commands/add.d.ts +0 -2
  17. package/dist/commands/add.d.ts.map +0 -1
  18. package/dist/commands/add.js +0 -120
  19. package/dist/commands/add.js.map +0 -1
  20. package/dist/commands/diff.d.ts +0 -2
  21. package/dist/commands/diff.d.ts.map +0 -1
  22. package/dist/commands/diff.js +0 -103
  23. package/dist/commands/diff.js.map +0 -1
  24. package/dist/commands/generate.d.ts +0 -12
  25. package/dist/commands/generate.d.ts.map +0 -1
  26. package/dist/commands/generate.js +0 -96
  27. package/dist/commands/generate.js.map +0 -1
  28. package/dist/commands/init.d.ts +0 -2
  29. package/dist/commands/init.d.ts.map +0 -1
  30. package/dist/commands/init.js +0 -79
  31. package/dist/commands/init.js.map +0 -1
  32. package/dist/commands/list.d.ts +0 -14
  33. package/dist/commands/list.d.ts.map +0 -1
  34. package/dist/commands/list.js +0 -93
  35. package/dist/commands/list.js.map +0 -1
  36. package/dist/commands/remove.d.ts +0 -2
  37. package/dist/commands/remove.d.ts.map +0 -1
  38. package/dist/commands/remove.js +0 -71
  39. package/dist/commands/remove.js.map +0 -1
  40. package/dist/commands/theme.d.ts +0 -31
  41. package/dist/commands/theme.d.ts.map +0 -1
  42. package/dist/commands/theme.js +0 -142
  43. package/dist/commands/theme.js.map +0 -1
  44. package/dist/commands/update.d.ts +0 -2
  45. package/dist/commands/update.d.ts.map +0 -1
  46. package/dist/commands/update.js +0 -123
  47. package/dist/commands/update.js.map +0 -1
  48. package/dist/core/alias-resolver.d.ts +0 -24
  49. package/dist/core/alias-resolver.d.ts.map +0 -1
  50. package/dist/core/alias-resolver.js +0 -87
  51. package/dist/core/alias-resolver.js.map +0 -1
  52. package/dist/core/config.d.ts +0 -21
  53. package/dist/core/config.d.ts.map +0 -1
  54. package/dist/core/config.js +0 -43
  55. package/dist/core/config.js.map +0 -1
  56. package/dist/core/file-writer.d.ts +0 -14
  57. package/dist/core/file-writer.d.ts.map +0 -1
  58. package/dist/core/file-writer.js +0 -90
  59. package/dist/core/file-writer.js.map +0 -1
  60. package/dist/core/package-manager.d.ts +0 -3
  61. package/dist/core/package-manager.d.ts.map +0 -1
  62. package/dist/core/package-manager.js +0 -17
  63. package/dist/core/package-manager.js.map +0 -1
  64. package/dist/core/registry.d.ts +0 -18
  65. package/dist/core/registry.d.ts.map +0 -1
  66. package/dist/core/registry.js +0 -69
  67. package/dist/core/registry.js.map +0 -1
  68. package/dist/core/theme-manager.d.ts +0 -35
  69. package/dist/core/theme-manager.d.ts.map +0 -1
  70. package/dist/core/theme-manager.js +0 -94
  71. package/dist/core/theme-manager.js.map +0 -1
  72. package/dist/core/utils.d.ts +0 -22
  73. package/dist/core/utils.d.ts.map +0 -1
  74. package/dist/core/utils.js +0 -44
  75. package/dist/core/utils.js.map +0 -1
  76. package/dist/index.d.ts.map +0 -1
  77. package/dist/index.js.map +0 -1
  78. package/dist/types.d.ts +0 -116
  79. package/dist/types.d.ts.map +0 -1
  80. package/dist/types.js +0 -43
  81. package/dist/types.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,3 +1,723 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=index.d.ts.map
1
+ /** Standard oscillator waveform source with optional FM synthesis. */
2
+ type OscillatorSource = {
3
+ type: "sine" | "triangle" | "square" | "sawtooth";
4
+ /** Fixed frequency in Hz, or a `{ start, end }` range for a pitch sweep. */
5
+ frequency: number | {
6
+ start: number;
7
+ end: number;
8
+ };
9
+ /** Detune in cents. */
10
+ detune?: number;
11
+ /** Frequency modulation: `ratio` is the modulator-to-carrier ratio, `depth` is the modulation index. */
12
+ fm?: {
13
+ ratio: number;
14
+ depth: number;
15
+ };
16
+ };
17
+ /** Procedural noise source (white, pink, or brown). */
18
+ type NoiseSource = {
19
+ type: "noise";
20
+ /** @defaultValue `"white"` */
21
+ color?: "white" | "pink" | "brown";
22
+ };
23
+ /** Custom waveform built from a harmonic series via `createPeriodicWave`. */
24
+ type WavetableSource = {
25
+ type: "wavetable";
26
+ /** Amplitude of each harmonic (index 0 = fundamental). */
27
+ harmonics: number[];
28
+ /** Fixed frequency in Hz, or a `{ start, end }` range for a pitch sweep. */
29
+ frequency: number | {
30
+ start: number;
31
+ end: number;
32
+ };
33
+ };
34
+ /** Plays a pre-recorded audio sample from a URL or an existing `AudioBuffer`. */
35
+ type SampleSource = {
36
+ type: "sample";
37
+ /** URL of the audio file to fetch and decode. Cached after first load. */
38
+ url?: string;
39
+ /** Pre-decoded buffer to use directly. */
40
+ buffer?: AudioBuffer;
41
+ /** Playback speed multiplier. @defaultValue `1` */
42
+ playbackRate?: number;
43
+ /** Detune in cents. */
44
+ detune?: number;
45
+ /** Whether the sample loops. */
46
+ loop?: boolean;
47
+ /** Loop region start in seconds. */
48
+ loopStart?: number;
49
+ /** Loop region end in seconds. */
50
+ loopEnd?: number;
51
+ };
52
+ /** Live audio input from a `MediaStream` (e.g. microphone). Requires a real-time `AudioContext`. */
53
+ type StreamSource = {
54
+ type: "stream";
55
+ stream: MediaStream;
56
+ };
57
+ /** DC offset source, useful for control signals and modulation. */
58
+ type ConstantSource = {
59
+ type: "constant";
60
+ /** @defaultValue `1` */
61
+ offset?: number;
62
+ };
63
+ /** Union of all audio source types that can drive a {@link Layer}. */
64
+ type Source = OscillatorSource | NoiseSource | WavetableSource | SampleSource | StreamSource | ConstantSource;
65
+ /** Biquad filter type identifiers matching the Web Audio API `BiquadFilterNode.type`. */
66
+ type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "notch" | "allpass" | "peaking" | "lowshelf" | "highshelf";
67
+ /** Time-varying envelope applied to a filter's cutoff frequency. */
68
+ type FilterEnvelope = {
69
+ /** Time in seconds to ramp from the base frequency to `peak`. @defaultValue `0` */
70
+ attack?: number;
71
+ /** Target frequency in Hz at the peak of the envelope. */
72
+ peak: number;
73
+ /** Time in seconds to decay from `peak` back to the base frequency. */
74
+ decay: number;
75
+ };
76
+ /** Standard biquad filter with optional frequency envelope. */
77
+ type BiquadFilter = {
78
+ type: BiquadFilterType;
79
+ /** Cutoff or center frequency in Hz. */
80
+ frequency: number;
81
+ /** Q factor (resonance). @defaultValue `1` */
82
+ resonance?: number;
83
+ /** Gain in dB (only applies to peaking / shelf types). */
84
+ gain?: number;
85
+ /** Optional frequency envelope that sweeps the cutoff over time. */
86
+ envelope?: FilterEnvelope;
87
+ };
88
+ /** Arbitrary IIR filter defined by feedforward and feedback coefficients. */
89
+ type IIRFilter = {
90
+ type: "iir";
91
+ feedforward: number[];
92
+ feedback: number[];
93
+ };
94
+ /** Union of supported filter types. */
95
+ type Filter = BiquadFilter | IIRFilter;
96
+ /**
97
+ * Amplitude envelope (ADSR).
98
+ *
99
+ * Only `decay` is required. Omitting `attack` makes the sound start at full
100
+ * volume; omitting `sustain` lets it fade to silence after the decay phase.
101
+ */
102
+ type Envelope = {
103
+ /** Time in seconds to ramp from silence to peak volume. @defaultValue `0` */
104
+ attack?: number;
105
+ /** Time in seconds for the decay phase. */
106
+ decay: number;
107
+ /** Sustain level as a fraction of peak volume (0 – 1). @defaultValue `0` */
108
+ sustain?: number;
109
+ /** Time in seconds for the release phase after sustain. @defaultValue `0` */
110
+ release?: number;
111
+ };
112
+ /** Parameter that an {@link LFO} can modulate. */
113
+ type LFOTarget = "frequency" | "detune" | "gain" | "pan" | "filter.frequency" | "filter.detune" | "filter.Q" | "filter.gain" | "playbackRate";
114
+ /** Low-frequency oscillator for periodic modulation of a target parameter. */
115
+ type LFO = {
116
+ /** Waveform shape of the modulator. */
117
+ type: "sine" | "triangle" | "square" | "sawtooth";
118
+ /** Modulation rate in Hz. */
119
+ frequency: number;
120
+ /** Modulation depth (units depend on the target parameter). */
121
+ depth: number;
122
+ /** Which parameter this LFO modulates. */
123
+ target: LFOTarget;
124
+ };
125
+ /** 3D spatial panner configuration using the Web Audio `PannerNode`. */
126
+ type Panner3D = {
127
+ positionX: number;
128
+ positionY: number;
129
+ positionZ: number;
130
+ orientationX?: number;
131
+ orientationY?: number;
132
+ orientationZ?: number;
133
+ /** @defaultValue `"HRTF"` */
134
+ panningModel?: "equalpower" | "HRTF";
135
+ /** @defaultValue `"inverse"` */
136
+ distanceModel?: "linear" | "inverse" | "exponential";
137
+ maxDistance?: number;
138
+ refDistance?: number;
139
+ rolloffFactor?: number;
140
+ coneInnerAngle?: number;
141
+ coneOuterAngle?: number;
142
+ coneOuterGain?: number;
143
+ };
144
+ /** Position and orientation of the audio listener for 3D spatialization. */
145
+ type Listener = {
146
+ positionX: number;
147
+ positionY: number;
148
+ positionZ: number;
149
+ forwardX?: number;
150
+ forwardY?: number;
151
+ forwardZ?: number;
152
+ upX?: number;
153
+ upY?: number;
154
+ upZ?: number;
155
+ };
156
+ /** Algorithmic reverb generated from an exponentially-decaying noise impulse. */
157
+ type ReverbEffect = {
158
+ type: "reverb";
159
+ /** Tail length in seconds. @defaultValue `0.5` */
160
+ decay?: number;
161
+ /** Delay in seconds before the reverb onset. @defaultValue `0` */
162
+ preDelay?: number;
163
+ /** High-frequency damping (0 – 1). @defaultValue `0` */
164
+ damping?: number;
165
+ /** Multiplier on the decay length. @defaultValue `1` */
166
+ roomSize?: number;
167
+ /** Dry/wet mix (0 = fully dry, 1 = fully wet). @defaultValue `0.3` */
168
+ mix?: number;
169
+ };
170
+ /** Convolution reverb using a provided impulse response buffer or URL. */
171
+ type ConvolverEffect = {
172
+ type: "convolver";
173
+ /** URL of the impulse response audio file. */
174
+ url?: string;
175
+ /** Pre-decoded impulse response buffer. */
176
+ buffer?: AudioBuffer;
177
+ /** @defaultValue `0.5` */
178
+ mix?: number;
179
+ };
180
+ /** Feedback delay with optional filter in the feedback path. */
181
+ type DelayEffect = {
182
+ type: "delay";
183
+ /** Delay time in seconds. @defaultValue `0.25` */
184
+ time?: number;
185
+ /** Feedback gain (0 – 1). @defaultValue `0.3` */
186
+ feedback?: number;
187
+ /** Optional filter applied in the feedback loop. */
188
+ feedbackFilter?: {
189
+ type: BiquadFilterType;
190
+ frequency: number;
191
+ Q?: number;
192
+ };
193
+ /** @defaultValue `0.3` */
194
+ mix?: number;
195
+ };
196
+ /** Waveshaper-based distortion using a `tanh` transfer curve. */
197
+ type DistortionEffect = {
198
+ type: "distortion";
199
+ /** Drive amount (higher = more distortion). @defaultValue `50` */
200
+ amount?: number;
201
+ /** @defaultValue `0.5` */
202
+ mix?: number;
203
+ };
204
+ /** Stereo chorus using two LFO-modulated delay lines. */
205
+ type ChorusEffect = {
206
+ type: "chorus";
207
+ /** LFO rate in Hz. @defaultValue `1.5` */
208
+ rate?: number;
209
+ /** LFO depth in seconds. @defaultValue `0.003` */
210
+ depth?: number;
211
+ /** @defaultValue `0.3` */
212
+ mix?: number;
213
+ };
214
+ /** Flanging effect via a short LFO-modulated delay with feedback. */
215
+ type FlangerEffect = {
216
+ type: "flanger";
217
+ /** LFO rate in Hz. @defaultValue `0.5` */
218
+ rate?: number;
219
+ /** LFO depth in seconds. @defaultValue `0.002` */
220
+ depth?: number;
221
+ /** Feedback gain (0 – 1). @defaultValue `0.5` */
222
+ feedback?: number;
223
+ /** @defaultValue `0.5` */
224
+ mix?: number;
225
+ };
226
+ /** Multi-stage allpass phaser with LFO sweep. */
227
+ type PhaserEffect = {
228
+ type: "phaser";
229
+ /** LFO rate in Hz. @defaultValue `0.5` */
230
+ rate?: number;
231
+ /** LFO depth in Hz. @defaultValue `1000` */
232
+ depth?: number;
233
+ /** Number of allpass stages. @defaultValue `4` */
234
+ stages?: number;
235
+ /** Feedback gain (0 – 1). @defaultValue `0.5` */
236
+ feedback?: number;
237
+ /** @defaultValue `0.5` */
238
+ mix?: number;
239
+ };
240
+ /** Amplitude modulation (volume tremolo). */
241
+ type TremoloEffect = {
242
+ type: "tremolo";
243
+ /** LFO rate in Hz. @defaultValue `4` */
244
+ rate?: number;
245
+ /** Modulation depth (0 – 1). @defaultValue `0.5` */
246
+ depth?: number;
247
+ };
248
+ /** Pitch vibrato via a short modulated delay line. */
249
+ type VibratoEffect = {
250
+ type: "vibrato";
251
+ /** LFO rate in Hz. @defaultValue `5` */
252
+ rate?: number;
253
+ /** LFO depth in seconds. @defaultValue `0.002` */
254
+ depth?: number;
255
+ };
256
+ /** Bit-depth reduction and optional sample-rate decimation. */
257
+ type BitcrusherEffect = {
258
+ type: "bitcrusher";
259
+ /** Bit depth. @defaultValue `8` */
260
+ bits?: number;
261
+ /** Sample rate reduction factor. @defaultValue `1` */
262
+ sampleRateReduction?: number;
263
+ /** @defaultValue `1` */
264
+ mix?: number;
265
+ };
266
+ /** Dynamics compressor wrapping the native `DynamicsCompressorNode`. */
267
+ type CompressorEffect = {
268
+ type: "compressor";
269
+ /** Threshold in dB. @defaultValue `-24` */
270
+ threshold?: number;
271
+ /** Knee width in dB. @defaultValue `30` */
272
+ knee?: number;
273
+ /** Compression ratio. @defaultValue `4` */
274
+ ratio?: number;
275
+ /** Attack time in seconds. @defaultValue `0.003` */
276
+ attack?: number;
277
+ /** Release time in seconds. @defaultValue `0.25` */
278
+ release?: number;
279
+ };
280
+ /** A single band in a parametric EQ. */
281
+ type EQBand = {
282
+ type: "lowshelf" | "highshelf" | "peaking";
283
+ /** Center or corner frequency in Hz. */
284
+ frequency: number;
285
+ /** Gain in dB. */
286
+ gain: number;
287
+ /** Q factor. @defaultValue `1` */
288
+ Q?: number;
289
+ };
290
+ /** Multi-band parametric equalizer built from chained `BiquadFilterNode`s. */
291
+ type EQEffect = {
292
+ type: "eq";
293
+ bands: EQBand[];
294
+ };
295
+ /** Simple gain stage. */
296
+ type GainEffect = {
297
+ type: "gain";
298
+ /** Linear gain value. */
299
+ value: number;
300
+ };
301
+ /** Stereo panner effect. */
302
+ type StereoPanEffect = {
303
+ type: "pan";
304
+ /** Pan position from -1 (full left) to 1 (full right). */
305
+ value: number;
306
+ };
307
+ /** Union of all effect types that can be applied to a {@link Layer} or globally. */
308
+ type Effect = ReverbEffect | ConvolverEffect | DelayEffect | DistortionEffect | ChorusEffect | FlangerEffect | PhaserEffect | TremoloEffect | VibratoEffect | BitcrusherEffect | CompressorEffect | EQEffect | GainEffect | StereoPanEffect;
309
+ /**
310
+ * A single audio layer combining a source, envelope, filter chain, effects,
311
+ * LFO modulation, and spatial positioning.
312
+ */
313
+ type Layer = {
314
+ /** The audio source that generates the signal. */
315
+ source: Source;
316
+ /** One or more filters applied before the envelope. */
317
+ filter?: Filter | Filter[];
318
+ /** Amplitude envelope (ADSR). Defaults to a short 0.5 s fade if omitted. */
319
+ envelope?: Envelope;
320
+ /** Output gain (0 – 1). @defaultValue `0.5` */
321
+ gain?: number;
322
+ /** Stereo pan (-1 left, 0 center, 1 right). */
323
+ pan?: number;
324
+ /** 3D spatialization config. Mutually exclusive with `pan`. */
325
+ panner?: Panner3D;
326
+ /** Start delay in seconds relative to the sound's trigger time. */
327
+ delay?: number;
328
+ /** One or more LFOs for periodic modulation. */
329
+ lfo?: LFO | LFO[];
330
+ /** Per-layer effects chain applied after the envelope. */
331
+ effects?: Effect[];
332
+ };
333
+ /** A sound built from multiple parallel {@link Layer}s with an optional global effects chain. */
334
+ type MultiLayerSound = {
335
+ layers: Layer[];
336
+ /** Effects applied to the summed output of all layers. */
337
+ effects?: Effect[];
338
+ };
339
+ /**
340
+ * Top-level sound definition: either a single {@link Layer} or a
341
+ * {@link MultiLayerSound} with multiple layers.
342
+ */
343
+ type SoundDefinition = Layer | MultiLayerSound;
344
+ /** Handle returned by the engine for stopping an in-flight voice. */
345
+ type VoiceHandle = {
346
+ /**
347
+ * Stops the voice with an optional fade-out.
348
+ *
349
+ * @param releaseTime - Fade-out duration in seconds. @defaultValue `0.015`
350
+ */
351
+ stop: (releaseTime?: number) => void;
352
+ };
353
+ /** Runtime overrides passed when triggering a sound. */
354
+ type PlayOptions = {
355
+ /** Volume multiplier (0 – 1). */
356
+ volume?: number;
357
+ /** Stereo pan override (-1 left, 0 center, 1 right). */
358
+ pan?: number;
359
+ /** Detune in cents, added to the source's existing detune. */
360
+ detune?: number;
361
+ /** Playback rate multiplier. */
362
+ playbackRate?: number;
363
+ /** Velocity sensitivity (0 – 1). Scales gain and can dim filter cutoffs. */
364
+ velocity?: number;
365
+ /**
366
+ * Per-voice random variation applied once on every trigger, so repeated
367
+ * plays of the same sound don't feel identical. Each field is the maximum
368
+ * symmetric offset (`±value`). Omitted fields are not jittered.
369
+ *
370
+ * @example
371
+ * ```ts
372
+ * // ±60 cents of pitch and ±10% volume on every click
373
+ * click({ jitter: { detune: 60, volume: 0.1 } });
374
+ * ```
375
+ */
376
+ jitter?: {
377
+ /** Random detune in cents, applied as ±value. E.g. `50` = ±50 cents. */
378
+ detune?: number;
379
+ /** Random volume multiplier, applied as ±value (0 – 1). E.g. `0.1` = ±10%. */
380
+ volume?: number;
381
+ /** Random playback rate offset, applied as ±value. E.g. `0.05` = ±5%. */
382
+ playbackRate?: number;
383
+ };
384
+ };
385
+ /** A single step in a {@link playSequence} timeline. */
386
+ type SequenceStep = {
387
+ /** A sound definition to render, or a pre-bound play function. */
388
+ sound: SoundDefinition | ((opts?: PlayOptions) => VoiceHandle | undefined);
389
+ /** Absolute time in seconds within the sequence. */
390
+ at?: number;
391
+ /** Relative offset in seconds from the previous step. */
392
+ wait?: number;
393
+ /** Per-step volume override. */
394
+ volume?: number;
395
+ };
396
+ /** Options for sequence playback. */
397
+ type SequenceOptions = {
398
+ /** Whether the sequence loops indefinitely. */
399
+ loop?: boolean;
400
+ /** Total loop duration in seconds (used when `loop` is true). */
401
+ duration?: number;
402
+ };
403
+ /** JSON-serializable patch containing named sound definitions. */
404
+ type SoundPatch = {
405
+ /** Optional JSON Schema reference for validation. */
406
+ $schema?: string;
407
+ /** Display name of the patch. */
408
+ name: string;
409
+ author?: string;
410
+ version?: string;
411
+ description?: string;
412
+ tags?: string[];
413
+ /** Map of sound names to their definitions. */
414
+ sounds: Record<string, SoundDefinition>;
415
+ };
416
+ /** Configuration for creating an {@link AudioAnalyser}. */
417
+ type AnalyserOptions = {
418
+ /** FFT window size (must be a power of 2). @defaultValue `2048` */
419
+ fftSize?: number;
420
+ /** Smoothing between consecutive frames (0 – 1). @defaultValue `0.8` */
421
+ smoothingTimeConstant?: number;
422
+ /** Minimum dB range for frequency data. */
423
+ minDecibels?: number;
424
+ /** Maximum dB range for frequency data. */
425
+ maxDecibels?: number;
426
+ };
427
+ /** Options for offline (non-realtime) audio rendering. */
428
+ type OfflineRenderOptions = {
429
+ /** Total render duration in seconds. */
430
+ duration: number;
431
+ /** Sample rate in Hz. @defaultValue `44100` */
432
+ sampleRate?: number;
433
+ /** Number of output channels. @defaultValue `2` */
434
+ numberOfChannels?: number;
435
+ };
436
+ /** A connectable effect node with an input, output, and optional cleanup. */
437
+ type EffectNode = {
438
+ input: AudioNode;
439
+ output: AudioNode;
440
+ /** Stops any internal oscillators / resources. */
441
+ dispose?: () => void;
442
+ };
443
+ /** Options passed when creating the shared `AudioContext`. */
444
+ type ContextOptions = {
445
+ /** Hint for the desired audio latency category. */
446
+ latencyHint?: AudioContextLatencyCategory;
447
+ /** Desired sample rate in Hz. */
448
+ sampleRate?: number;
449
+ };
450
+
451
+ /**
452
+ * Wrapper around the native `AnalyserNode` with pre-allocated typed arrays
453
+ * for zero-allocation reads in animation loops.
454
+ */
455
+ type AudioAnalyser = {
456
+ /** The underlying Web Audio `AnalyserNode`. */
457
+ node: AnalyserNode;
458
+ /** Returns byte-scaled frequency magnitudes (0 – 255). */
459
+ getFrequencyData: () => Uint8Array;
460
+ /** Returns byte-scaled time-domain waveform (0 – 255). */
461
+ getTimeDomainData: () => Uint8Array;
462
+ /** Returns frequency magnitudes in dB. */
463
+ getFloatFrequencyData: () => Float32Array;
464
+ /** Returns time-domain waveform as floats (-1 to 1). */
465
+ getFloatTimeDomainData: () => Float32Array;
466
+ /** Number of frequency bins (half of `fftSize`). */
467
+ frequencyBinCount: number;
468
+ /** Disconnects the analyser and releases resources. */
469
+ dispose: () => void;
470
+ };
471
+ /**
472
+ * Creates a standalone {@link AudioAnalyser}.
473
+ *
474
+ * The caller is responsible for connecting a source to `analyser.node`.
475
+ * Call `analyser.dispose()` when finished to disconnect.
476
+ *
477
+ * @param opts - FFT size, smoothing, and dB range overrides
478
+ */
479
+ declare function createAnalyser(opts?: AnalyserOptions): AudioAnalyser;
480
+ /**
481
+ * Creates an {@link AudioAnalyser} that is pre-connected to the master bus.
482
+ *
483
+ * Useful for visualising the combined output of all sounds.
484
+ * The returned analyser automatically disconnects from the master bus on
485
+ * `dispose()`.
486
+ *
487
+ * @param opts - FFT size, smoothing, and dB range overrides
488
+ */
489
+ declare function createMasterAnalyser(opts?: AnalyserOptions): AudioAnalyser;
490
+
491
+ /**
492
+ * Ensures the `AudioContext` is running and ready for playback.
493
+ *
494
+ * Unlike {@link getContext}, this awaits the `resume()` promise so the
495
+ * caller can be certain audio output is active before proceeding.
496
+ *
497
+ * @param options - Context creation options
498
+ * @returns A promise that resolves to the active `AudioContext`
499
+ */
500
+ declare function ensureReady(options?: ContextOptions): Promise<AudioContext>;
501
+ /**
502
+ * Closes the shared `AudioContext` and releases all associated resources.
503
+ *
504
+ * After calling this, the next call to {@link getContext} will create a
505
+ * fresh context.
506
+ */
507
+ declare function dispose(): void;
508
+ /**
509
+ * Returns the master bus `GainNode`, creating it on first access.
510
+ *
511
+ * The master bus sits between all sound output and `ctx.destination`,
512
+ * providing a single point to control global volume.
513
+ */
514
+ declare function getMasterBus(): GainNode;
515
+ /**
516
+ * Returns the appropriate destination node for sound output.
517
+ *
518
+ * If a master bus has been created, routes through it; otherwise falls
519
+ * back to `ctx.destination`.
520
+ */
521
+ declare function getDestination(): AudioNode;
522
+ /**
523
+ * Sets the master volume for all audio output.
524
+ *
525
+ * @param volume - Linear gain value (0 = silent, 1 = unity)
526
+ */
527
+ declare function setMasterVolume(volume: number): void;
528
+ /**
529
+ * Configures the 3D audio listener position and orientation.
530
+ *
531
+ * @param listener - Position and orientation values
532
+ * @see {@link getListener}
533
+ */
534
+ declare function setListener(listener: Listener): void;
535
+ /**
536
+ * Reads the current 3D audio listener position and orientation.
537
+ *
538
+ * @returns A snapshot of the listener's spatial parameters
539
+ * @see {@link setListener}
540
+ */
541
+ declare function getListener(): Listener;
542
+
543
+ /**
544
+ * Renders a sound definition to an `AudioBuffer` using `OfflineAudioContext`.
545
+ *
546
+ * No speakers are involved — the entire render happens in memory.
547
+ *
548
+ * @param definition - The sound to render
549
+ * @param options - Duration, sample rate, and channel count
550
+ * @param playOpts - Runtime overrides (volume, detune, etc.)
551
+ * @returns A promise resolving to the rendered `AudioBuffer`
552
+ */
553
+ declare function renderToBuffer(definition: SoundDefinition, options: OfflineRenderOptions, playOpts?: PlayOptions): Promise<AudioBuffer>;
554
+ /**
555
+ * Encodes an `AudioBuffer` as a 16-bit PCM WAV `Blob`.
556
+ *
557
+ * @param buffer - The audio buffer to encode
558
+ * @returns A `Blob` with MIME type `audio/wav`
559
+ */
560
+ declare function bufferToWav(buffer: AudioBuffer): Blob;
561
+ /**
562
+ * Convenience wrapper that renders a sound and encodes it as a WAV `Blob`.
563
+ *
564
+ * Equivalent to calling {@link renderToBuffer} followed by {@link bufferToWav}.
565
+ *
566
+ * @param definition - The sound to render
567
+ * @param options - Duration, sample rate, and channel count
568
+ * @param playOpts - Runtime overrides
569
+ * @returns A promise resolving to a WAV `Blob`
570
+ */
571
+ declare function renderToWav(definition: SoundDefinition, options: OfflineRenderOptions, playOpts?: PlayOptions): Promise<Blob>;
572
+
573
+ /**
574
+ * A loaded sound patch with methods to play individual sounds by name.
575
+ *
576
+ * @example
577
+ * ```typescript
578
+ * const patch = await loadPatch("https://example.com/ui-sounds.json");
579
+ * patch.play("click");
580
+ * ```
581
+ */
582
+ type AudioPatch = {
583
+ /** `true` once the patch data has been loaded and parsed. */
584
+ ready: boolean;
585
+ name: string;
586
+ author?: string;
587
+ version?: string;
588
+ description?: string;
589
+ tags?: string[];
590
+ /** Names of all sounds contained in this patch. */
591
+ sounds: string[];
592
+ /**
593
+ * Plays a named sound from the patch.
594
+ *
595
+ * @param name - Sound name (must exist in {@link sounds})
596
+ * @param opts - Runtime overrides
597
+ * @throws {Error} If the sound name is not found in the patch
598
+ */
599
+ play: (name: string, opts?: PlayOptions) => VoiceHandle;
600
+ /** Returns the raw {@link SoundDefinition} for a named sound, or `undefined`. */
601
+ get: (name: string) => SoundDefinition | undefined;
602
+ /** Returns a deep-cloned copy of the underlying {@link SoundPatch} data. */
603
+ toJSON: () => SoundPatch;
604
+ };
605
+ declare function createPatchInstance(data: SoundPatch): AudioPatch;
606
+ /**
607
+ * Creates an {@link AudioPatch} from an in-memory {@link SoundPatch} object.
608
+ *
609
+ * @param data - The sound patch data
610
+ * @returns A ready-to-play `AudioPatch`
611
+ */
612
+ declare function definePatch(data: SoundPatch): AudioPatch;
613
+ /**
614
+ * Loads a sound patch from a URL or an in-memory object.
615
+ *
616
+ * When `source` is a string, it is fetched as JSON and decoded into a
617
+ * {@link SoundPatch}. When it is already a `SoundPatch`, it is used directly.
618
+ *
619
+ * @param source - URL string or `SoundPatch` object
620
+ * @returns A promise that resolves to a ready-to-play {@link AudioPatch}
621
+ * @throws {Error} If the network request fails
622
+ */
623
+ declare function loadPatch(source: string | SoundPatch): Promise<AudioPatch>;
624
+
625
+ /**
626
+ * Binds a {@link SoundDefinition} into a reusable play function.
627
+ *
628
+ * The returned function creates a new voice each time it is called,
629
+ * routing through the master bus.
630
+ *
631
+ * @param definition - The sound to bind
632
+ * @returns A function that plays the sound and returns a {@link VoiceHandle}
633
+ *
634
+ * @example
635
+ * ```typescript
636
+ * import { defineSound } from "@litlab/audx";
637
+ *
638
+ * const click = defineSound({
639
+ * source: { type: "sine", frequency: { start: 1800, end: 400 } },
640
+ * envelope: { attack: 0, decay: 0.08 },
641
+ * gain: 0.3,
642
+ * });
643
+ *
644
+ * click(); // plays the sound
645
+ * ```
646
+ */
647
+ declare function defineSound(definition: SoundDefinition): (opts?: PlayOptions) => VoiceHandle;
648
+ /**
649
+ * Binds a list of {@link SequenceStep}s into a reusable play function.
650
+ *
651
+ * @param steps - Ordered list of sequence steps
652
+ * @param options - Loop and duration settings
653
+ * @returns A function that starts the sequence and returns a stop callback
654
+ *
655
+ * @example
656
+ * ```typescript
657
+ * const melody = defineSequence([
658
+ * { sound: noteC, at: 0 },
659
+ * { sound: noteE, at: 0.25 },
660
+ * { sound: noteG, at: 0.5 },
661
+ * ], { loop: true, duration: 1 });
662
+ *
663
+ * const stop = melody();
664
+ * // later...
665
+ * stop?.();
666
+ * ```
667
+ */
668
+ declare function defineSequence(steps: SequenceStep[], options?: SequenceOptions): (opts?: PlayOptions) => (() => void) | undefined;
669
+ /**
670
+ * Shortcut: creates a sine-wave sound with the given frequency and decay.
671
+ *
672
+ * @param frequency - Fixed Hz or `{ start, end }` sweep
673
+ * @param decay - Envelope decay time in seconds
674
+ * @param gain - Output gain (0 – 1). @defaultValue `0.4`
675
+ */
676
+ declare function sine(frequency: number | {
677
+ start: number;
678
+ end: number;
679
+ }, decay: number, gain?: number): (opts?: PlayOptions) => VoiceHandle;
680
+ /**
681
+ * Shortcut: creates a triangle-wave sound with the given frequency and decay.
682
+ *
683
+ * @param frequency - Fixed Hz or `{ start, end }` sweep
684
+ * @param decay - Envelope decay time in seconds
685
+ * @param gain - Output gain (0 – 1). @defaultValue `0.4`
686
+ */
687
+ declare function triangle(frequency: number | {
688
+ start: number;
689
+ end: number;
690
+ }, decay: number, gain?: number): (opts?: PlayOptions) => VoiceHandle;
691
+ /**
692
+ * Shortcut: creates a square-wave sound with the given frequency and decay.
693
+ *
694
+ * @param frequency - Fixed Hz or `{ start, end }` sweep
695
+ * @param decay - Envelope decay time in seconds
696
+ * @param gain - Output gain (0 – 1). @defaultValue `0.4`
697
+ */
698
+ declare function square(frequency: number | {
699
+ start: number;
700
+ end: number;
701
+ }, decay: number, gain?: number): (opts?: PlayOptions) => VoiceHandle;
702
+ /**
703
+ * Shortcut: creates a sawtooth-wave sound with the given frequency and decay.
704
+ *
705
+ * @param frequency - Fixed Hz or `{ start, end }` sweep
706
+ * @param decay - Envelope decay time in seconds
707
+ * @param gain - Output gain (0 – 1). @defaultValue `0.4`
708
+ */
709
+ declare function sawtooth(frequency: number | {
710
+ start: number;
711
+ end: number;
712
+ }, decay: number, gain?: number): (opts?: PlayOptions) => VoiceHandle;
713
+ /**
714
+ * Shortcut: creates a noise burst with the given color and decay.
715
+ *
716
+ * @param color - Noise spectrum. @defaultValue `"white"`
717
+ * @param decay - Envelope decay time in seconds. @defaultValue `0.05`
718
+ * @param gain - Output gain (0 – 1). @defaultValue `0.4`
719
+ */
720
+ declare function noise(color?: "white" | "pink" | "brown", decay?: number, gain?: number): (opts?: PlayOptions) => VoiceHandle;
721
+
722
+ export { bufferToWav, createAnalyser, createMasterAnalyser, createPatchInstance, definePatch, defineSequence, defineSound, dispose, ensureReady, getDestination, getListener, getMasterBus, loadPatch, noise, renderToBuffer, renderToWav, sawtooth, setListener, setMasterVolume, sine, square, triangle };
723
+ export type { AnalyserOptions, AudioAnalyser, AudioPatch, BiquadFilter, BiquadFilterType, BitcrusherEffect, ChorusEffect, CompressorEffect, ConstantSource, ContextOptions, ConvolverEffect, DelayEffect, DistortionEffect, EQBand, EQEffect, Effect, EffectNode, Envelope, Filter, FilterEnvelope, FlangerEffect, GainEffect, IIRFilter, LFO, LFOTarget, Layer, Listener, MultiLayerSound, NoiseSource, OfflineRenderOptions, OscillatorSource, Panner3D, PhaserEffect, PlayOptions, ReverbEffect, SampleSource, SequenceOptions, SequenceStep, SoundDefinition, SoundPatch, Source, StereoPanEffect, StreamSource, TremoloEffect, VibratoEffect, VoiceHandle, WavetableSource };