1 | import { OutputNode, ToneAudioNode, ToneAudioNodeOptions } from "../core/context/ToneAudioNode.js";
|
2 | import { Decibels } from "../core/type/Units.js";
|
3 | import { Param } from "../core/context/Param.js";
|
4 | export interface UserMediaOptions extends ToneAudioNodeOptions {
|
5 | volume: Decibels;
|
6 | mute: boolean;
|
7 | }
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export declare class UserMedia extends ToneAudioNode<UserMediaOptions> {
|
28 | readonly name: string;
|
29 | readonly input: undefined;
|
30 | readonly output: OutputNode;
|
31 | |
32 |
|
33 |
|
34 | private _mediaStream?;
|
35 | |
36 |
|
37 |
|
38 | private _stream?;
|
39 | |
40 |
|
41 |
|
42 | private _device?;
|
43 | |
44 |
|
45 |
|
46 | private _volume;
|
47 | |
48 |
|
49 |
|
50 | readonly volume: Param<"decibels">;
|
51 | |
52 |
|
53 |
|
54 | constructor(volume?: Decibels);
|
55 | constructor(options?: Partial<UserMediaOptions>);
|
56 | static getDefaults(): UserMediaOptions;
|
57 | /**
|
58 | * Open the media stream. If a string is passed in, it is assumed
|
59 | * to be the label or id of the stream, if a number is passed in,
|
60 | * it is the input number of the stream.
|
61 | * @param labelOrId The label or id of the audio input media device.
|
62 | * With no argument, the default stream is opened.
|
63 | * @return The promise is resolved when the stream is open.
|
64 | */
|
65 | open(labelOrId?: string | number): Promise<this>;
|
66 | /**
|
67 | * Close the media stream
|
68 | */
|
69 | close(): this;
|
70 | /**
|
71 | * Returns a promise which resolves with the list of audio input devices available.
|
72 | * @return The promise that is resolved with the devices
|
73 | * @example
|
74 | * Tone.UserMedia.enumerateDevices().then((devices) => {
|
75 | *
|
76 | * console.log(devices.map(device => device.label));
|
77 | * });
|
78 | */
|
79 | static enumerateDevices(): Promise<MediaDeviceInfo[]>;
|
80 | /**
|
81 | * Returns the playback state of the source, "started" when the microphone is open
|
82 | * and "stopped" when the mic is closed.
|
83 | */
|
84 | get state(): "started" | "stopped";
|
85 | /**
|
86 | * Returns an identifier for the represented device that is
|
87 | * persisted across sessions. It is un-guessable by other applications and
|
88 | * unique to the origin of the calling application. It is reset when the
|
89 | * user clears cookies (for Private Browsing, a different identifier is
|
90 | * used that is not persisted across sessions). Returns undefined when the
|
91 | * device is not open.
|
92 | */
|
93 | get deviceId(): string | undefined;
|
94 | /**
|
95 | * Returns a group identifier. Two devices have the
|
96 | * same group identifier if they belong to the same physical device.
|
97 | * Returns null when the device is not open.
|
98 | */
|
99 | get groupId(): string | undefined;
|
100 | /**
|
101 | * Returns a label describing this device (for example "Built-in Microphone").
|
102 | * Returns undefined when the device is not open or label is not available
|
103 | * because of permissions.
|
104 | */
|
105 | get label(): string | undefined;
|
106 | /**
|
107 | * Mute the output.
|
108 | * @example
|
109 | * const mic = new Tone.UserMedia();
|
110 | * mic.open().then(() => {
|
111 | *
|
112 | * });
|
113 | * // mute the output
|
114 | * mic.mute = true;
|
115 | */
|
116 | get mute(): boolean;
|
117 | set mute(mute: boolean);
|
118 | dispose(): this;
|
119 | /**
|
120 | * If getUserMedia is supported by the browser.
|
121 | */
|
122 | static get supported(): boolean;
|
123 | }
|