-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathaudio-decode.d.ts
More file actions
52 lines (45 loc) · 1.57 KB
/
audio-decode.d.ts
File metadata and controls
52 lines (45 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
export interface AudioData {
channelData: Float32Array[];
sampleRate: number;
}
export interface StreamDecoder {
/** Feed a chunk of encoded audio data, or call empty to flush + free. */
(chunk?: Uint8Array): Promise<AudioData>;
/** Flush without freeing. */
flush(): Promise<AudioData>;
/** Free resources without flushing. */
free(): void;
}
type Format = 'mp3' | 'flac' | 'opus' | 'oga' | 'm4a' | 'wav' | 'qoa' | 'aac' | 'aiff' | 'caf' | 'webm' | 'amr' | 'wma';
interface FormatDecoder {
/** Create a decoder instance. */
(): Promise<StreamDecoder>;
}
/** Whole-file decode: auto-detects format. */
declare function decode(buf: ArrayBuffer | Uint8Array): Promise<AudioData>;
/** Chunked decode from stream or async iterable. */
declare function decode(
source: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>,
format: Format
): AsyncGenerator<AudioData>;
declare namespace decode {
export const mp3: FormatDecoder;
export const flac: FormatDecoder;
export const opus: FormatDecoder;
export const oga: FormatDecoder;
export const m4a: FormatDecoder;
export const wav: FormatDecoder;
export const qoa: FormatDecoder;
export const aac: FormatDecoder;
export const aiff: FormatDecoder;
export const caf: FormatDecoder;
export const webm: FormatDecoder;
export const amr: FormatDecoder;
export const wma: FormatDecoder;
}
export default decode;
/** Chunked decode from stream or async iterable. */
export function decodeChunked(
source: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>,
format: Format
): AsyncGenerator<AudioData>;