miniaudio_node 1.0.4 → 1.5.1
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/index.d.ts +518 -34
- package/index.js +570 -265
- package/miniaudio_node.darwin-arm64.node +0 -0
- package/miniaudio_node.darwin-x64.node +0 -0
- package/miniaudio_node.linux-arm64-gnu.node +0 -0
- package/miniaudio_node.linux-x64-gnu.node +0 -0
- package/miniaudio_node.win32-ia32-msvc.node +0 -0
- package/miniaudio_node.win32-x64-msvc.node +0 -0
- package/package.json +24 -16
package/index.d.ts
CHANGED
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
1
|
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export declare function createAudioPlayer(config?: AudioPlayerConfig | undefined | null): AudioPlayer
|
|
29
|
-
export declare function quickPlay(filePath: string, config?: AudioPlayerConfig | undefined | null): AudioPlayer
|
|
30
|
-
export interface AudioMetadata {
|
|
31
|
-
duration: number
|
|
32
|
-
title?: string
|
|
33
|
-
artist?: string
|
|
34
|
-
album?: string
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/** Decoder for audio files in various formats (WAV, MP3, FLAC, OGG, etc.) */
|
|
4
|
+
export declare class AudioDecoder {
|
|
5
|
+
/** Create a decoder from a file path */
|
|
6
|
+
constructor(filePath: string)
|
|
7
|
+
/** Create a decoder from raw audio data */
|
|
8
|
+
static fromData(data: Array<number>): AudioDecoder
|
|
9
|
+
/** Get sample rate of decoded audio */
|
|
10
|
+
getSampleRate(): number
|
|
11
|
+
/** Get number of channels (1=mono, 2=stereo, etc.) */
|
|
12
|
+
getChannels(): number
|
|
13
|
+
/** Get duration in seconds */
|
|
14
|
+
getDuration(): number
|
|
15
|
+
/** Reset decoder to beginning */
|
|
16
|
+
reset(): void
|
|
17
|
+
/** Decode all audio samples into a vector */
|
|
18
|
+
decodeToSamples(): Array<number>
|
|
19
|
+
/** Get a slice of decoded samples (limited by duration to prevent memory issues) */
|
|
20
|
+
decodeSlice(startSeconds: number, endSeconds: number): Array<number>
|
|
21
|
+
/** Check if this is a stereo file */
|
|
22
|
+
isStereo(): boolean
|
|
23
|
+
/** Check if this is a mono file */
|
|
24
|
+
isMono(): boolean
|
|
35
25
|
}
|
|
36
|
-
|
|
26
|
+
|
|
37
27
|
/** Thread-safe audio player with rodio backend */
|
|
38
28
|
export declare class AudioPlayer {
|
|
39
29
|
constructor()
|
|
@@ -51,4 +41,498 @@ export declare class AudioPlayer {
|
|
|
51
41
|
getDuration(): number
|
|
52
42
|
getCurrentTime(): number
|
|
53
43
|
getCurrentFile(): string | null
|
|
44
|
+
seekTo(position: number): void
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A queue for managing multiple audio sources that play in sequence */
|
|
48
|
+
export declare class AudioSourceQueue {
|
|
49
|
+
constructor()
|
|
50
|
+
/** Add an audio source from a file */
|
|
51
|
+
addSource(filePath: string, title?: string | undefined | null): string
|
|
52
|
+
/** Add an audio source from a buffer */
|
|
53
|
+
addBuffer(buffer: Array<number>, title?: string | undefined | null): string
|
|
54
|
+
/** Remove a source by its ID */
|
|
55
|
+
removeSource(sourceId: string): void
|
|
56
|
+
/** Get a specific source by its ID */
|
|
57
|
+
getSource(sourceId: string): AudioQueueItem
|
|
58
|
+
getSources(): Array<AudioQueueItem>
|
|
59
|
+
getLength(): number
|
|
60
|
+
getCurrentIndex(): number
|
|
61
|
+
setCurrentIndex(index: number): void
|
|
62
|
+
clear(): void
|
|
63
|
+
isPlaying(): boolean
|
|
64
|
+
setPlaying(playing: boolean): void
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Audio stream for real-time playback */
|
|
68
|
+
export declare class AudioStream {
|
|
69
|
+
constructor()
|
|
70
|
+
/** Open and initialize the audio stream */
|
|
71
|
+
open(): void
|
|
72
|
+
/** Play an audio file */
|
|
73
|
+
playFile(filePath: string): void
|
|
74
|
+
/** Play raw audio data from buffer */
|
|
75
|
+
playBuffer(buffer: SamplesBuffer): void
|
|
76
|
+
/** Play base64 encoded audio data */
|
|
77
|
+
playBase64(base64Data: string): void
|
|
78
|
+
/** Get the current playback state */
|
|
79
|
+
getState(): PlayError
|
|
80
|
+
/** Check if audio is currently playing */
|
|
81
|
+
isPlaying(): boolean
|
|
82
|
+
/** Pause the stream */
|
|
83
|
+
pause(): void
|
|
84
|
+
/** Resume the stream */
|
|
85
|
+
resume(): void
|
|
86
|
+
/** Stop the stream */
|
|
87
|
+
stop(): void
|
|
88
|
+
/** Set the master volume (0.0 to 1.0) */
|
|
89
|
+
setVolume(volume: number): void
|
|
90
|
+
/** Get the current volume */
|
|
91
|
+
getVolume(): number
|
|
92
|
+
/** Get supported stream configurations */
|
|
93
|
+
static getSupportedConfigs(): Array<SupportedStreamConfig>
|
|
54
94
|
}
|
|
95
|
+
|
|
96
|
+
/** Stream builder for creating audio streams with specific configurations */
|
|
97
|
+
export declare class AudioStreamBuilder {
|
|
98
|
+
constructor()
|
|
99
|
+
setSampleRate(rate: number): void
|
|
100
|
+
setChannels(channels: number): void
|
|
101
|
+
setBufferSize(size: number): void
|
|
102
|
+
build(): AudioStream
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Blue noise generator - high frequency emphasis */
|
|
106
|
+
export declare class BlueNoise {
|
|
107
|
+
constructor(durationMs: number, sampleRate: number, channels: number)
|
|
108
|
+
getSamples(): Array<number>
|
|
109
|
+
getNext(): number | null
|
|
110
|
+
reset(): void
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Brownian noise (random walk) - low frequency emphasis */
|
|
114
|
+
export declare class BrownianNoise {
|
|
115
|
+
constructor(durationMs: number, sampleRate: number, channels: number)
|
|
116
|
+
getSamples(): Array<number>
|
|
117
|
+
getNext(): number | null
|
|
118
|
+
reset(): void
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Channel count converter - handles converting between mono, stereo, and multi-channel audio */
|
|
122
|
+
export declare class ChannelCountConverter {
|
|
123
|
+
constructor(sourceChannels: number, targetChannels: number)
|
|
124
|
+
/** Convert audio samples from source channel count to target channel count */
|
|
125
|
+
convert(samples: Array<number>): Array<number>
|
|
126
|
+
sourceChannels(): number
|
|
127
|
+
targetChannels(): number
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Decoder builder for configuring decoder behavior */
|
|
131
|
+
export declare class DecoderBuilder {
|
|
132
|
+
constructor()
|
|
133
|
+
setLoopEnabled(enabled: boolean): void
|
|
134
|
+
setLoopCount(count: number): void
|
|
135
|
+
setSampleRate(rate: number): void
|
|
136
|
+
setChannels(channels: number): void
|
|
137
|
+
buildFromFile(filePath: string): AudioDecoder
|
|
138
|
+
buildFromData(data: Array<number>): AudioDecoder
|
|
139
|
+
buildLooped(filePath: string): LoopedDecoder
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Decoder builder settings */
|
|
143
|
+
export declare class DecoderBuilderSettings {
|
|
144
|
+
enableLooping: boolean
|
|
145
|
+
loopCount: number
|
|
146
|
+
sampleRate?: number
|
|
147
|
+
channels?: number
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Looped decoder - decodes audio and repeats it indefinitely */
|
|
151
|
+
export declare class LoopedDecoder {
|
|
152
|
+
/** Create a new looped decoder */
|
|
153
|
+
constructor(decoder: AudioDecoder, loopCount?: number | undefined | null)
|
|
154
|
+
/** Get the loop count (0 = infinite) */
|
|
155
|
+
getLoopCount(): number
|
|
156
|
+
/** Set the loop count (use u32::MAX for infinite) */
|
|
157
|
+
setLoopCount(count: number): void
|
|
158
|
+
/** Decode with loops applied */
|
|
159
|
+
decodeLooped(): Array<number>
|
|
160
|
+
/** Get reference to inner decoder */
|
|
161
|
+
getDecoder(): AudioDecoder
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** A mixer that combines multiple audio sources into a single output stream */
|
|
165
|
+
export declare class Mixer {
|
|
166
|
+
/** Create a new mixer with default settings (44100 Hz, stereo, max 16 sources) */
|
|
167
|
+
constructor()
|
|
168
|
+
/** Create a mixer with custom configuration */
|
|
169
|
+
static withConfig(sampleRate: number, channels: number, maxSources: number): Mixer
|
|
170
|
+
/** Add an audio source to the mixer */
|
|
171
|
+
addSource(source: MixerSource): void
|
|
172
|
+
/** Remove a source by its ID */
|
|
173
|
+
removeSource(sourceId: string): void
|
|
174
|
+
/** Get all current sources */
|
|
175
|
+
getSources(): Array<MixerSource>
|
|
176
|
+
/** Get the number of sources */
|
|
177
|
+
getSourceCount(): number
|
|
178
|
+
/** Clear all sources */
|
|
179
|
+
clear(): void
|
|
180
|
+
/**
|
|
181
|
+
* Mix all sources at a specific time point (synchronous operation)
|
|
182
|
+
* Returns a buffer of mixed samples
|
|
183
|
+
*/
|
|
184
|
+
sampleAt(timeMs: number): Array<number>
|
|
185
|
+
/** Start mixing multiple sources in real-time (simulated) */
|
|
186
|
+
startMixing(): void
|
|
187
|
+
/** Stop all mixing */
|
|
188
|
+
stopMixing(): void
|
|
189
|
+
/** Get the sample rate of the mixer */
|
|
190
|
+
getSampleRate(): number
|
|
191
|
+
/** Get the channel count of the mixer */
|
|
192
|
+
getChannels(): number
|
|
193
|
+
/** Set the master volume (0.0 to 1.0) */
|
|
194
|
+
setMasterVolume(volume: number): void
|
|
195
|
+
/** Get the master volume */
|
|
196
|
+
getMasterVolume(): number
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** A source that can be added to a mixer */
|
|
200
|
+
export declare class MixerSource {
|
|
201
|
+
constructor(id: string, samples: Array<number>, sampleRate: number, channels: number)
|
|
202
|
+
/** Get source ID */
|
|
203
|
+
getId(): string
|
|
204
|
+
/** Get audio samples */
|
|
205
|
+
getSamples(): Array<number>
|
|
206
|
+
/** Get samples at a specific time (simplified to return relative audio) */
|
|
207
|
+
getSamplesAt(timeMs: number): Array<number>
|
|
208
|
+
/** Get sample rate */
|
|
209
|
+
getSampleRate(): number
|
|
210
|
+
/** Get channels */
|
|
211
|
+
getChannels(): number
|
|
212
|
+
/** Set volume (0.0 to 1.0) */
|
|
213
|
+
setVolume(volume: number): void
|
|
214
|
+
/** Get volume */
|
|
215
|
+
getVolume(): number
|
|
216
|
+
/** Set pan (-1.0 left, 0.0 center, 1.0 right) */
|
|
217
|
+
setPan(pan: number): void
|
|
218
|
+
/** Get pan */
|
|
219
|
+
getPan(): number
|
|
220
|
+
/** Enable or disable source */
|
|
221
|
+
setEnabled(enabled: boolean): void
|
|
222
|
+
/** Check if source is enabled */
|
|
223
|
+
isEnabled(): boolean
|
|
224
|
+
/** Get duration in milliseconds */
|
|
225
|
+
durationMs(): number
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Pink noise generator - equal power per octave */
|
|
229
|
+
export declare class PinkNoise {
|
|
230
|
+
constructor(durationMs: number, sampleRate: number, channels: number)
|
|
231
|
+
getSamples(): Array<number>
|
|
232
|
+
getNext(): number | null
|
|
233
|
+
reset(): void
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Sample rate converter - handles converting between different sample rates (e.g., 44100 to 48000) */
|
|
237
|
+
export declare class SampleRateConverter {
|
|
238
|
+
constructor(sourceRate: number, targetRate: number)
|
|
239
|
+
/** Convert audio samples from source rate to target rate using linear interpolation */
|
|
240
|
+
convert(samples: Array<number>): Array<number>
|
|
241
|
+
sourceRate(): number
|
|
242
|
+
targetRate(): number
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** A buffer containing audio samples */
|
|
246
|
+
export declare class SamplesBuffer {
|
|
247
|
+
/** Create a new samples buffer */
|
|
248
|
+
constructor(channels: number, sampleRate: number, samples: Array<number>)
|
|
249
|
+
/** Get the number of channels in this buffer (1=mono, 2=stereo) */
|
|
250
|
+
getChannels(): number
|
|
251
|
+
/** Get the sample rate of this buffer */
|
|
252
|
+
getSampleRate(): number
|
|
253
|
+
/** Get the number of samples in this buffer */
|
|
254
|
+
getLen(): number
|
|
255
|
+
/** Get the duration of this buffer in seconds */
|
|
256
|
+
getDuration(): number
|
|
257
|
+
/** Get a copy of the samples in this buffer */
|
|
258
|
+
getSamples(): Array<number>
|
|
259
|
+
/** Create a buffer from raw bytes (16-bit little-endian samples) */
|
|
260
|
+
static fromBytes(bytes: Array<number>, channels: number, sampleRate: number): SamplesBuffer
|
|
261
|
+
/** Play this buffer with the given sink */
|
|
262
|
+
play(): void
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** Sample type converter - handles converting between different bit depths (8, 16, 24, 32 bit) */
|
|
266
|
+
export declare class SampleTypeConverter {
|
|
267
|
+
constructor(sourceBits: number, targetBits: number)
|
|
268
|
+
/** Convert between different sample bit depths */
|
|
269
|
+
convert(samples: Array<number>): Array<number>
|
|
270
|
+
sourceBits(): number
|
|
271
|
+
targetBits(): number
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export declare class SourcesQueueInput {
|
|
275
|
+
constructor()
|
|
276
|
+
pushFile(filePath: string): string
|
|
277
|
+
pushBuffer(buffer: Array<number>): string
|
|
278
|
+
setTitle(sourceId: string, title: string): void
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Queue output interface - for consuming sources from a queue */
|
|
282
|
+
export declare class SourcesQueueOutput {
|
|
283
|
+
constructor()
|
|
284
|
+
peek(): AudioQueueItem
|
|
285
|
+
pop(): AudioQueueItem
|
|
286
|
+
hasNext(): boolean
|
|
287
|
+
getRemaining(): number
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** Static buffer that owns its audio data */
|
|
291
|
+
export declare class StaticSamplesBuffer {
|
|
292
|
+
constructor(channels: number, sampleRate: number, samples: Array<number>)
|
|
293
|
+
getInner(): SamplesBuffer
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Velvet noise - sparse, crackly noise */
|
|
297
|
+
export declare class VelvetNoise {
|
|
298
|
+
constructor(durationMs: number, sampleRate: number, channels: number)
|
|
299
|
+
getSamples(): Array<number>
|
|
300
|
+
getNext(): number | null
|
|
301
|
+
reset(): void
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Violet noise - very high frequency emphasis */
|
|
305
|
+
export declare class VioletNoise {
|
|
306
|
+
constructor(durationMs: number, sampleRate: number, channels: number)
|
|
307
|
+
getSamples(): Array<number>
|
|
308
|
+
getNext(): number | null
|
|
309
|
+
reset(): void
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** White Gaussian noise */
|
|
313
|
+
export declare class WhiteGaussianNoise {
|
|
314
|
+
constructor(durationMs: number, sampleRate: number, channels: number, stdDev?: number | undefined | null)
|
|
315
|
+
getSamples(): Array<number>
|
|
316
|
+
getNext(): number | null
|
|
317
|
+
reset(): void
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** White Triangular noise */
|
|
321
|
+
export declare class WhiteTriangularNoise {
|
|
322
|
+
constructor(durationMs: number, sampleRate: number, channels: number)
|
|
323
|
+
getSamples(): Array<number>
|
|
324
|
+
getNext(): number | null
|
|
325
|
+
reset(): void
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** White Uniform noise (standard random noise) */
|
|
329
|
+
export declare class WhiteUniformNoise {
|
|
330
|
+
constructor(durationMs: number, sampleRate: number, channels: number)
|
|
331
|
+
getSamples(): Array<number>
|
|
332
|
+
getNext(): number | null
|
|
333
|
+
reset(): void
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Audio device information structure */
|
|
337
|
+
export interface AudioDeviceInfo {
|
|
338
|
+
id: string
|
|
339
|
+
name: string
|
|
340
|
+
isDefault: boolean
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export interface AudioMetadata {
|
|
344
|
+
duration: number
|
|
345
|
+
title?: string
|
|
346
|
+
artist?: string
|
|
347
|
+
album?: string
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export interface AudioPlayerConfig {
|
|
351
|
+
volume?: number
|
|
352
|
+
autoPlay?: boolean
|
|
353
|
+
debug?: boolean
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface AudioQueueItem {
|
|
357
|
+
sourceId: string
|
|
358
|
+
filePath?: string
|
|
359
|
+
buffer?: Array<number>
|
|
360
|
+
title?: string
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** Parameters for channel count conversion */
|
|
364
|
+
export interface ChannelCountConversion {
|
|
365
|
+
sourceChannels: number
|
|
366
|
+
targetChannels: number
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export declare function createAudioPlayer(config?: AudioPlayerConfig | undefined | null): AudioPlayer
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Converts a value from decibels to linear gain (multiplier).
|
|
373
|
+
*
|
|
374
|
+
* # Example
|
|
375
|
+
* ```
|
|
376
|
+
* // -6dB is approximately 0.5
|
|
377
|
+
* assert!(db_to_linear(-6.0) < 0.51 && db_to_linear(-6.0) > 0.49);
|
|
378
|
+
* // 0dB is 1.0
|
|
379
|
+
* assert_eq!(db_to_linear(0.0), 1.0);
|
|
380
|
+
* ```
|
|
381
|
+
*
|
|
382
|
+
* # Arguments
|
|
383
|
+
* * `db` - Value in decibels
|
|
384
|
+
*
|
|
385
|
+
* # Returns
|
|
386
|
+
* Linear gain multiplier (0.0 to infinity)
|
|
387
|
+
*/
|
|
388
|
+
export declare function dbToLinear(db: number): number
|
|
389
|
+
|
|
390
|
+
/** Decoder error types (for audio decoding operations) */
|
|
391
|
+
export declare const enum DecoderError {
|
|
392
|
+
InvalidFormat = 'InvalidFormat',
|
|
393
|
+
CorruptedData = 'CorruptedData',
|
|
394
|
+
UnsupportedCodec = 'UnsupportedCodec',
|
|
395
|
+
IoError = 'IoError'
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** Error types for device operations */
|
|
399
|
+
export declare const enum DevicesError {
|
|
400
|
+
NoDevicesFound = 'NoDevicesFound',
|
|
401
|
+
PermissionDenied = 'PermissionDenied',
|
|
402
|
+
InvalidDevice = 'InvalidDevice',
|
|
403
|
+
NotInitialized = 'NotInitialized'
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export declare function getAudioInfo(): string
|
|
407
|
+
|
|
408
|
+
export declare function getAudioMetadata(filePath: string): AudioMetadata
|
|
409
|
+
|
|
410
|
+
export declare function getSupportedFormats(): Array<string>
|
|
411
|
+
|
|
412
|
+
export declare function initializeAudio(): string
|
|
413
|
+
|
|
414
|
+
/** Get current debug logging state */
|
|
415
|
+
export declare function isDebugEnabled(): boolean
|
|
416
|
+
|
|
417
|
+
export declare function isFormatSupported(format: string): boolean
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Converts a linear gain multiplier to decibels.
|
|
421
|
+
*
|
|
422
|
+
* # Example
|
|
423
|
+
* ```
|
|
424
|
+
* // 0.5 is approximately -6dB
|
|
425
|
+
* assert!((linear_to_db(0.5) + 6.0).abs() < 0.1);
|
|
426
|
+
* // 1.0 is 0dB
|
|
427
|
+
* assert_eq!(linear_to_db(1.0), 0.0);
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
430
|
+
* # Arguments
|
|
431
|
+
* * `linear` - Linear gain multiplier
|
|
432
|
+
*
|
|
433
|
+
* # Returns
|
|
434
|
+
* Value in decibels
|
|
435
|
+
*/
|
|
436
|
+
export declare function linearToDb(linear: number): number
|
|
437
|
+
|
|
438
|
+
/** Create a new mixer instance */
|
|
439
|
+
export declare function mixer(maxSources?: number | undefined | null): Mixer
|
|
440
|
+
|
|
441
|
+
/** Create pink noise (with 1/f frequency spectrum) */
|
|
442
|
+
export declare function pink(durationMs: number, sampleRate: number, channels: number): PinkNoise
|
|
443
|
+
|
|
444
|
+
/** Create and open a stream for audio playback */
|
|
445
|
+
export declare function play(filePath: string): AudioStream
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Audio player state enumeration
|
|
449
|
+
* Audio player state enumeration
|
|
450
|
+
*/
|
|
451
|
+
export declare const enum PlaybackState {
|
|
452
|
+
Stopped = 'Stopped',
|
|
453
|
+
Loaded = 'Loaded',
|
|
454
|
+
Playing = 'Playing',
|
|
455
|
+
Paused = 'Paused'
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** Play error for stream operations */
|
|
459
|
+
export declare const enum PlayError {
|
|
460
|
+
AlreadyPlaying = 'AlreadyPlaying',
|
|
461
|
+
NotLoaded = 'NotLoaded',
|
|
462
|
+
SystemError = 'SystemError'
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** Creates a new audio source queue */
|
|
466
|
+
export declare function queue(): AudioSourceQueue
|
|
467
|
+
|
|
468
|
+
export declare function quickPlay(filePath: string, config?: AudioPlayerConfig | undefined | null): AudioPlayer
|
|
469
|
+
|
|
470
|
+
/** Parameters for sample rate conversion */
|
|
471
|
+
export interface SampleRateConversion {
|
|
472
|
+
sourceRate: number
|
|
473
|
+
targetRate: number
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/** Parameters for sample type conversion */
|
|
477
|
+
export interface SampleTypeConversion {
|
|
478
|
+
sourceBits: number
|
|
479
|
+
targetBits: number
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/** Seek error types */
|
|
483
|
+
export declare const enum SeekError {
|
|
484
|
+
InvalidPosition = 'InvalidPosition',
|
|
485
|
+
NotSeekable = 'NotSeekable',
|
|
486
|
+
OutOfBounds = 'OutOfBounds'
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/** Enable or disable debug logging (defaults to false) */
|
|
490
|
+
export declare function setDebug(enabled: boolean): void
|
|
491
|
+
|
|
492
|
+
/** Audio source function types (for generator sources) */
|
|
493
|
+
export declare const enum SourceFunction {
|
|
494
|
+
Sine = 'Sine',
|
|
495
|
+
Square = 'Square',
|
|
496
|
+
Sawtooth = 'Sawtooth',
|
|
497
|
+
Triangle = 'Triangle',
|
|
498
|
+
WhiteNoise = 'WhiteNoise',
|
|
499
|
+
PinkNoise = 'PinkNoise',
|
|
500
|
+
BrownNoise = 'BrownNoise'
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** Error types for stream operations */
|
|
504
|
+
export declare const enum StreamError {
|
|
505
|
+
NotPlaying = 'NotPlaying',
|
|
506
|
+
EndOfFile = 'EndOfFile',
|
|
507
|
+
InvalidData = 'InvalidData',
|
|
508
|
+
UnsupportedFormat = 'UnsupportedFormat'
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/** Stream output configuration */
|
|
512
|
+
export interface StreamOutputConfig {
|
|
513
|
+
sampleRate?: SampleRate
|
|
514
|
+
channels?: ChannelCount
|
|
515
|
+
bufferSize?: number
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/** Stream play error */
|
|
519
|
+
export declare const enum StreamPlayError {
|
|
520
|
+
AlreadyPlaying = 'AlreadyPlaying',
|
|
521
|
+
NotReady = 'NotReady',
|
|
522
|
+
SystemError = 'SystemError'
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** Get supported output configurations for the audio system */
|
|
526
|
+
export declare function supportedOutputConfigs(): Array<SupportedStreamConfig>
|
|
527
|
+
|
|
528
|
+
/** Supported stream configuration */
|
|
529
|
+
export interface SupportedStreamConfig {
|
|
530
|
+
sampleRate: SampleRate
|
|
531
|
+
channelCount: ChannelCount
|
|
532
|
+
sampleWidth: number
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export declare function testTone(frequency: number, durationMs: number): void
|
|
536
|
+
|
|
537
|
+
/** Create white noise (neutral frequency spectrum) */
|
|
538
|
+
export declare function white(durationMs: number, sampleRate: number, channels: number): WhiteUniformNoise
|