-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
91 lines (91 loc) · 3.13 KB
/
index.d.ts
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* The browser does not support WebAssembly.
*/
export declare class WebAssemblyNotSupportedError extends Error {
constructor();
}
/**
* The browser does not support audio worklets.
*/
export declare class AudioWorkletNotSupportedError extends Error {
constructor();
}
/**
* Failed to fetch the WebAssembly module at the specified URL.
*/
export declare class WebAssemblyFetchError extends Error {
constructor(url: string, httpStatus: number);
}
/**
* Determines how to handle microphone access.
*/
export declare enum MicrophoneMode {
/**
* Mic access is requested if the number of inputs
* specified in the worklet node options is greater than zero.
* An error is thrown if access is denied.
* This is the default mode.
*/
required = "required",
/**
* Mic access is requested if the number of inputs
* specified in the worklet node options is greater than zero.
* No error is thrown if access is denied.
*/
optional = "optional",
/**
* Mic access is not requested, regardless of the number of inputs
* specified in the worklet node options.
*/
disabled = "disabled"
}
/**
* Options passed to startAudioWorklet.
*/
export interface StartAudioWorkletOptions {
/**
* The name used when registering the worklet processor with `registerProcessor`.
*/
workletNodeName: string;
/**
* The URL of the audio worklet processor source file.
*/
workletProcessorUrl: string;
/**
* Options passed to the `AudioWorkletNode` constructor.
* @see https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletNode/AudioWorkletNode
*/
workletNodeOptions: AudioWorkletNodeOptions;
/**
* Used to override the default options passed to the `AudioContext` constructor. Optional.
* @see https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/AudioContext#parameters
*/
audioContextOptions?: AudioContextOptions;
/**
* Options to pass when creating the microphone input
* stream using `getUserMedia`. If not specified, no options are passed.
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#properties_of_audio_tracks
*/
microphoneStreamOptions?: MediaTrackConstraints;
/**
* An optional URL to a WebAssembly module to load. The module data is stored
* in the `wasmData` attribute of the options object passed to the processor's constructor.
*/
wasmUrl?: string;
/**
* Determines how to handle microphone access. Defaults to `required` if not specified.
* @see MicrophoneMode.
* */
microphoneMode?: MicrophoneMode;
/**
* By default, a `?t=[timestamp]` suffix is added to `workletProcessorUrl` and `wasmUrl`
* in order to prevent caching. Set this flag to true to disable this behavior.
*/
disableUrlTimestampSuffix?: boolean;
}
/**
* Start and create an audio worklet node.
* @param options See StartAudioWorkletOptions
* @returns A promise that resolves with the created AudioWorkletNode.
*/
export declare function startAudioWorklet(options: StartAudioWorkletOptions): Promise<AudioWorkletNode>;