-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathindex.d.ts
58 lines (52 loc) · 1.45 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
export type SoundLevelResult = {
/**
* Frame number
*/
id: number;
/**
* Sound level in decibels
*
* @note -160 is a silence
*/
value: number;
/**
* Raw level value, OS-depended
*/
rawValue: number;
}
export type SoundLevelMonitorConfig = {
monitoringInterval?: number
samplingRate?: number
}
export type SoundLevelType = {
/**
* Start monitoring sound level
*
* @note `monitoringInterval` is not supported for desktop yet
*
* @note don't forget to call `stop` eventually
*
* on Android:
* @throws
* - `INVALID_STATE` - sound level recording already started
* - `COULDNT_CONFIGURE_MEDIA_RECORDER` - recording configuration failed (probably due-to lack of android.permission.RECORD_AUDIO)
* - `COULDNT_PREPARE_RECORDING` - preparation fails for some reason
* - `COULDNT_START_RECORDING` - can't start recording session (another app is using recording?)
*/
start: (config?: number | SoundLevelMonitorConfig) => Promise<void>;
/**
* Stop monitoring sound level
*
* on Android:
* @throws
* - `INVALID_STATE` - sound level recording hasn't been started
* - `RUNTIME_EXCEPTION` - no valid audio data received. You may be using a device that can't record audio.
*/
stop: () => Promise<void>;
/**
* User-provided callback to call on each frame
*/
onNewFrame: (result: SoundLevelResult) => void;
}
declare const SoundLevel: SoundLevelType;
export default SoundLevel;