react-native-audio-api 0.11.0-nightly-95f9c99-20251215 → 0.11.0-nightly-dd83923-20251216
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/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +382 -39
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +45 -18
- package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +33 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +170 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +46 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +0 -1
- package/android/src/main/cpp/audioapi/android/core/utils/FileOptions.cpp +83 -0
- package/android/src/main/cpp/audioapi/android/core/utils/FileOptions.h +22 -0
- package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +8 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +493 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +70 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/ptrs.hpp +56 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/utils.cpp +114 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/utils.h +34 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +296 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +40 -0
- package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +32 -0
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +2 -0
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +7 -3
- package/android/src/main/java/com/swmansion/audioapi/system/CentralizedForegroundService.kt +1 -0
- package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +18 -0
- package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotification.kt +1 -0
- package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotificationReceiver.kt +2 -0
- package/android/src/oldarch/NativeAudioAPIModuleSpec.java +100 -80
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +3 -11
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +145 -16
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +21 -6
- package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +43 -60
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +53 -33
- package/common/cpp/audioapi/core/sources/RecorderAdapterNode.cpp +42 -14
- package/common/cpp/audioapi/core/sources/RecorderAdapterNode.h +12 -9
- package/common/cpp/audioapi/core/utils/AudioFileWriter.cpp +41 -0
- package/common/cpp/audioapi/core/utils/AudioFileWriter.h +44 -0
- package/common/cpp/audioapi/core/utils/AudioRecorderCallback.cpp +101 -0
- package/common/cpp/audioapi/core/utils/AudioRecorderCallback.h +52 -0
- package/common/cpp/audioapi/utils/AudioFileProperties.cpp +92 -0
- package/common/cpp/audioapi/utils/AudioFileProperties.h +76 -0
- package/common/cpp/audioapi/utils/Result.hpp +323 -0
- package/common/cpp/audioapi/utils/UnitConversion.h +9 -0
- package/ios/audioapi/ios/AudioAPIModule.mm +9 -14
- package/ios/audioapi/ios/core/IOSAudioPlayer.h +1 -1
- package/ios/audioapi/ios/core/IOSAudioPlayer.mm +7 -6
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +39 -13
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +302 -26
- package/ios/audioapi/ios/core/NativeAudioPlayer.m +7 -11
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +8 -9
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +70 -76
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +1 -0
- package/ios/audioapi/ios/core/utils/FileOptions.h +33 -0
- package/ios/audioapi/ios/core/utils/FileOptions.mm +195 -0
- package/ios/audioapi/ios/core/utils/IOSFileWriter.h +53 -0
- package/ios/audioapi/ios/core/utils/IOSFileWriter.mm +239 -0
- package/ios/audioapi/ios/core/utils/IOSRecorderCallback.h +47 -0
- package/ios/audioapi/ios/core/utils/IOSRecorderCallback.mm +185 -0
- package/ios/audioapi/ios/system/AudioEngine.h +21 -16
- package/ios/audioapi/ios/system/AudioEngine.mm +138 -130
- package/ios/audioapi/ios/system/AudioSessionManager.h +19 -9
- package/ios/audioapi/ios/system/AudioSessionManager.mm +250 -215
- package/ios/audioapi/ios/system/NotificationManager.mm +24 -42
- package/lib/commonjs/api.js +82 -109
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/core/AudioRecorder.js +159 -13
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/commonjs/system/notification/PlaybackNotificationManager.js +17 -14
- package/lib/commonjs/system/notification/PlaybackNotificationManager.js.map +1 -1
- package/lib/commonjs/system/notification/RecordingNotificationManager.js +22 -19
- package/lib/commonjs/system/notification/RecordingNotificationManager.js.map +1 -1
- package/lib/commonjs/system/notification/SimpleNotificationManager.js +16 -13
- package/lib/commonjs/system/notification/SimpleNotificationManager.js.map +1 -1
- package/lib/commonjs/types.js +39 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/filePresets.js +43 -0
- package/lib/commonjs/utils/filePresets.js.map +1 -0
- package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js +6 -3
- package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js.map +1 -1
- package/lib/commonjs/web-system/notification/RecordingNotificationManager.js +6 -3
- package/lib/commonjs/web-system/notification/RecordingNotificationManager.js.map +1 -1
- package/lib/module/api.js +5 -4
- package/lib/module/api.js.map +1 -1
- package/lib/module/core/AudioRecorder.js +159 -13
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/module/system/notification/PlaybackNotificationManager.js +17 -14
- package/lib/module/system/notification/PlaybackNotificationManager.js.map +1 -1
- package/lib/module/system/notification/RecordingNotificationManager.js +22 -19
- package/lib/module/system/notification/RecordingNotificationManager.js.map +1 -1
- package/lib/module/system/notification/SimpleNotificationManager.js +16 -13
- package/lib/module/system/notification/SimpleNotificationManager.js.map +1 -1
- package/lib/module/types.js +38 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/filePresets.js +39 -0
- package/lib/module/utils/filePresets.js.map +1 -0
- package/lib/module/web-system/notification/PlaybackNotificationManager.js +6 -3
- package/lib/module/web-system/notification/PlaybackNotificationManager.js.map +1 -1
- package/lib/module/web-system/notification/RecordingNotificationManager.js +6 -3
- package/lib/module/web-system/notification/RecordingNotificationManager.js.map +1 -1
- package/lib/typescript/api.d.ts +5 -4
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/core/AudioRecorder.d.ts +69 -7
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +36 -2
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +24 -4
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
- package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts +4 -3
- package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts.map +1 -1
- package/lib/typescript/system/notification/RecordingNotificationManager.d.ts +4 -3
- package/lib/typescript/system/notification/RecordingNotificationManager.d.ts.map +1 -1
- package/lib/typescript/system/notification/SimpleNotificationManager.d.ts +3 -2
- package/lib/typescript/system/notification/SimpleNotificationManager.d.ts.map +1 -1
- package/lib/typescript/system/notification/types.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +79 -3
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/filePresets.d.ts +9 -0
- package/lib/typescript/utils/filePresets.d.ts.map +1 -0
- package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts +4 -3
- package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts.map +1 -1
- package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts +4 -3
- package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/AudioAPIModule/globals.d.ts +1 -2
- package/src/api.ts +8 -29
- package/src/core/AudioRecorder.ts +195 -23
- package/src/events/types.ts +40 -2
- package/src/interfaces.ts +34 -5
- package/src/specs/NativeAudioAPIModule.ts +2 -2
- package/src/system/notification/PlaybackNotificationManager.ts +20 -16
- package/src/system/notification/RecordingNotificationManager.ts +26 -21
- package/src/system/notification/SimpleNotificationManager.ts +18 -13
- package/src/system/notification/types.ts +1 -0
- package/src/types.ts +89 -3
- package/src/utils/filePresets.ts +47 -0
- package/src/web-system/notification/PlaybackNotificationManager.ts +9 -5
- package/src/web-system/notification/RecordingNotificationManager.ts +9 -5
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import AudioBuffer from './core/AudioBuffer';
|
|
2
|
+
export type Result<T> = ({
|
|
3
|
+
status: 'success';
|
|
4
|
+
} & T) | {
|
|
5
|
+
status: 'error';
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
2
8
|
export type ChannelCountMode = 'max' | 'clamped-max' | 'explicit';
|
|
3
9
|
export type ChannelInterpretation = 'speakers' | 'discrete';
|
|
4
10
|
export type BiquadFilterType = 'lowpass' | 'highpass' | 'bandpass' | 'lowshelf' | 'highshelf' | 'peaking' | 'notch' | 'allpass';
|
|
5
|
-
export type ContextState = 'running' | 'closed' |
|
|
11
|
+
export type ContextState = 'running' | 'closed' | 'suspended';
|
|
6
12
|
export type AudioWorkletRuntime = 'AudioRuntime' | 'UIRuntime';
|
|
7
13
|
export type OscillatorType = 'sine' | 'square' | 'sawtooth' | 'triangle' | 'custom';
|
|
8
14
|
export interface PeriodicWaveConstraints {
|
|
@@ -16,9 +22,60 @@ export interface OfflineAudioContextOptions {
|
|
|
16
22
|
length: number;
|
|
17
23
|
sampleRate: number;
|
|
18
24
|
}
|
|
19
|
-
export
|
|
25
|
+
export declare enum FileDirectory {
|
|
26
|
+
Document = 0,
|
|
27
|
+
Cache = 1
|
|
28
|
+
}
|
|
29
|
+
export declare enum FileFormat {
|
|
30
|
+
Wav = 0,
|
|
31
|
+
Caf = 1,
|
|
32
|
+
M4A = 2,
|
|
33
|
+
Flac = 3
|
|
34
|
+
}
|
|
35
|
+
export declare enum IOSAudioQuality {
|
|
36
|
+
Min = 0,
|
|
37
|
+
Low = 1,
|
|
38
|
+
Medium = 2,
|
|
39
|
+
High = 3,
|
|
40
|
+
Max = 4
|
|
41
|
+
}
|
|
42
|
+
export declare enum BitDepth {
|
|
43
|
+
Bit16 = 0,
|
|
44
|
+
Bit24 = 1,
|
|
45
|
+
Bit32 = 2
|
|
46
|
+
}
|
|
47
|
+
export declare enum FlacCompressionLevel {
|
|
48
|
+
L0 = 0,
|
|
49
|
+
L1 = 1,
|
|
50
|
+
L2 = 2,
|
|
51
|
+
L3 = 3,
|
|
52
|
+
L4 = 4,
|
|
53
|
+
L5 = 5,
|
|
54
|
+
L6 = 6,
|
|
55
|
+
L7 = 7,
|
|
56
|
+
L8 = 8
|
|
57
|
+
}
|
|
58
|
+
export interface FilePresetType {
|
|
59
|
+
bitRate: number;
|
|
20
60
|
sampleRate: number;
|
|
21
|
-
|
|
61
|
+
bitDepth: BitDepth;
|
|
62
|
+
iosQuality: IOSAudioQuality;
|
|
63
|
+
flacCompressionLevel: FlacCompressionLevel;
|
|
64
|
+
}
|
|
65
|
+
export interface AudioRecorderFileOptions {
|
|
66
|
+
channelCount?: number;
|
|
67
|
+
batchDurationSeconds?: number;
|
|
68
|
+
format?: FileFormat;
|
|
69
|
+
preset?: FilePresetType;
|
|
70
|
+
directory?: FileDirectory;
|
|
71
|
+
subDirectory?: string;
|
|
72
|
+
fileNamePrefix?: string;
|
|
73
|
+
androidFlushIntervalMs?: number;
|
|
74
|
+
}
|
|
75
|
+
export interface FileInfo {
|
|
76
|
+
path: string;
|
|
77
|
+
size: number;
|
|
78
|
+
duration: number;
|
|
22
79
|
}
|
|
23
80
|
export type WindowType = 'blackman' | 'hann';
|
|
24
81
|
export interface AudioBufferBaseSourceNodeOptions {
|
|
@@ -29,6 +86,25 @@ export interface ConvolverNodeOptions {
|
|
|
29
86
|
buffer?: AudioBuffer | null;
|
|
30
87
|
disableNormalization?: boolean;
|
|
31
88
|
}
|
|
89
|
+
export interface AudioRecorderCallbackOptions {
|
|
90
|
+
/**
|
|
91
|
+
* The desired sample rate (in Hz) for audio buffers delivered to the
|
|
92
|
+
* recording callback. Common values include 44100 or 48000 Hz. The actual
|
|
93
|
+
* sample rate may differ depending on hardware and system capabilities.
|
|
94
|
+
*/
|
|
95
|
+
sampleRate: number;
|
|
96
|
+
/**
|
|
97
|
+
* The preferred size of each audio buffer, expressed as the number of samples
|
|
98
|
+
* per channel. Smaller buffers reduce latency but increase CPU load, while
|
|
99
|
+
* larger buffers improve efficiency at the cost of higher latency.
|
|
100
|
+
*/
|
|
101
|
+
bufferLength: number;
|
|
102
|
+
/**
|
|
103
|
+
* The desired number of audio channels per buffer. Typically 1 for mono or 2
|
|
104
|
+
* for stereo recordings.
|
|
105
|
+
*/
|
|
106
|
+
channelCount: number;
|
|
107
|
+
}
|
|
32
108
|
export interface IIRFilterNodeOptions {
|
|
33
109
|
feedforward: number[];
|
|
34
110
|
feedback: number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,aAAa,GAAG,UAAU,CAAC;AAElE,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,UAAU,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,GACX,SAAS,GACT,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,WAAW,CAAC;AAE/D,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,QAAQ,GACR,UAAU,GACV,UAAU,GACV,QAAQ,CAAC;AAEb,MAAM,WAAW,uBAAuB;IACtC,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FilePresetType } from '../types';
|
|
2
|
+
declare const FilePreset: {
|
|
3
|
+
readonly Low: FilePresetType;
|
|
4
|
+
readonly Medium: FilePresetType;
|
|
5
|
+
readonly High: FilePresetType;
|
|
6
|
+
readonly Lossless: FilePresetType;
|
|
7
|
+
};
|
|
8
|
+
export default FilePreset;
|
|
9
|
+
//# sourceMappingURL=filePresets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filePresets.d.ts","sourceRoot":"","sources":["../../../src/utils/filePresets.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAGf,MAAM,UAAU,CAAC;AAkClB,QAAA,MAAM,UAAU;;;;;CAKN,CAAC;AAEX,eAAe,UAAU,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AudioEventSubscription } from '../../events';
|
|
2
|
-
import type {
|
|
2
|
+
import type { NotificationEvents, NotificationManager, PlaybackControlName, PlaybackNotificationEventName, PlaybackNotificationInfo } from '../../system';
|
|
3
3
|
declare class PlaybackNotificationManager implements NotificationManager<PlaybackNotificationInfo, PlaybackNotificationInfo, PlaybackNotificationEventName> {
|
|
4
|
-
private
|
|
5
|
-
private
|
|
4
|
+
private isRegistered_;
|
|
5
|
+
private isShown_;
|
|
6
6
|
constructor();
|
|
7
7
|
register(): Promise<void>;
|
|
8
8
|
show(info: PlaybackNotificationInfo): Promise<void>;
|
|
@@ -11,6 +11,7 @@ declare class PlaybackNotificationManager implements NotificationManager<Playbac
|
|
|
11
11
|
unregister(): Promise<void>;
|
|
12
12
|
enableControl(control: PlaybackControlName, enabled: boolean): Promise<void>;
|
|
13
13
|
isActive(): Promise<boolean>;
|
|
14
|
+
isRegistered(): boolean;
|
|
14
15
|
addEventListener<T extends PlaybackNotificationEventName>(eventName: T, callback: (event: NotificationEvents[T]) => void): AudioEventSubscription;
|
|
15
16
|
removeEventListener(subscription: AudioEventSubscription): void;
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaybackNotificationManager.d.ts","sourceRoot":"","sources":["../../../../src/web-system/notification/PlaybackNotificationManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EACV,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"PlaybackNotificationManager.d.ts","sourceRoot":"","sources":["../../../../src/web-system/notification/PlaybackNotificationManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAGtB,cAAM,2BACJ,YACE,mBAAmB,CACjB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,CAC9B;IAEH,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;;IAInB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAEzB,IAAI,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAEnD,MAAM,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAErD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAErB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3B,aAAa,CACjB,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC;IAEV,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC,YAAY,IAAI,OAAO;IAIvB,gBAAgB,CAAC,CAAC,SAAS,6BAA6B,EACtD,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,sBAAsB;IAOzB,mBAAmB,CAAC,YAAY,EAAE,sBAAsB,GAAG,IAAI;CAChE;;AAED,wBAAiD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AudioEventSubscription } from '../../events';
|
|
2
|
-
import type {
|
|
2
|
+
import type { NotificationEvents, NotificationManager, RecordingControlName, RecordingNotificationEventName, RecordingNotificationInfo } from '../../system';
|
|
3
3
|
declare class RecordingNotificationManager implements NotificationManager<RecordingNotificationInfo, RecordingNotificationInfo, RecordingNotificationEventName> {
|
|
4
|
-
private
|
|
5
|
-
private
|
|
4
|
+
private isRegistered_;
|
|
5
|
+
private isShown_;
|
|
6
6
|
constructor();
|
|
7
7
|
register(): Promise<void>;
|
|
8
8
|
show(info: RecordingNotificationInfo): Promise<void>;
|
|
@@ -11,6 +11,7 @@ declare class RecordingNotificationManager implements NotificationManager<Record
|
|
|
11
11
|
unregister(): Promise<void>;
|
|
12
12
|
enableControl(control: RecordingControlName, enabled: boolean): Promise<void>;
|
|
13
13
|
isActive(): Promise<boolean>;
|
|
14
|
+
isRegistered(): boolean;
|
|
14
15
|
addEventListener<T extends RecordingNotificationEventName>(eventName: T, callback: (event: NotificationEvents[T]) => void): AudioEventSubscription;
|
|
15
16
|
removeEventListener(subscription: AudioEventSubscription): void;
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordingNotificationManager.d.ts","sourceRoot":"","sources":["../../../../src/web-system/notification/RecordingNotificationManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EACV,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"RecordingNotificationManager.d.ts","sourceRoot":"","sources":["../../../../src/web-system/notification/RecordingNotificationManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,8BAA8B,EAC9B,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AAGtB,cAAM,4BACJ,YACE,mBAAmB,CACjB,yBAAyB,EACzB,yBAAyB,EACzB,8BAA8B,CAC/B;IAEH,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;;IAInB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAEzB,IAAI,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAEpD,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAEtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAErB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3B,aAAa,CACjB,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC;IAEV,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC,YAAY,IAAI,OAAO;IAIvB,gBAAgB,CAAC,CAAC,SAAS,8BAA8B,EACvD,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,sBAAsB;IAOzB,mBAAmB,CAAC,YAAY,EAAE,sBAAsB,GAAG,IAAI;CAChE;;AAED,wBAAkD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.11.0-nightly-
|
|
3
|
+
"version": "0.11.0-nightly-dd83923-20251216",
|
|
4
4
|
"description": "react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification",
|
|
5
5
|
"bin": {
|
|
6
6
|
"setup-rn-audio-api-web": "./scripts/setup-rn-audio-api-web.js"
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@babel/core": "^7.25.2",
|
|
91
91
|
"@babel/preset-env": "^7.25.3",
|
|
92
92
|
"@babel/types": "^7.20.0",
|
|
93
|
-
"@commitlint/config-conventional": "
|
|
93
|
+
"@commitlint/config-conventional": "17.0.2",
|
|
94
94
|
"@evilmartians/lefthook": "^1.5.0",
|
|
95
95
|
"@expo/config-plugins": "^9.0.0",
|
|
96
96
|
"@expo/config-types": "^53.0.4",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"@types/react-test-renderer": "^19.1.0",
|
|
109
109
|
"@types/semver": "7.7.1",
|
|
110
110
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
111
|
-
"commitlint": "
|
|
111
|
+
"commitlint": "17.0.2",
|
|
112
112
|
"del-cli": "^5.1.0",
|
|
113
113
|
"eslint": "^8.57.0",
|
|
114
114
|
"eslint-config-prettier": "^8.3.0",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"react-native": "0.82.0",
|
|
131
131
|
"react-native-builder-bob": "0.33.1",
|
|
132
132
|
"turbo": "^1.10.7",
|
|
133
|
-
"typescript": "5.8.3"
|
|
133
|
+
"typescript": "~5.8.3"
|
|
134
134
|
},
|
|
135
135
|
"react-native-builder-bob": {
|
|
136
136
|
"source": "src",
|
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
IAudioStretcher,
|
|
7
7
|
IOfflineAudioContext,
|
|
8
8
|
} from '../interfaces';
|
|
9
|
-
import type { AudioRecorderOptions } from '../types';
|
|
10
9
|
|
|
11
10
|
/* eslint-disable no-var */
|
|
12
11
|
declare global {
|
|
@@ -23,7 +22,7 @@ declare global {
|
|
|
23
22
|
audioWorkletRuntime: any
|
|
24
23
|
) => IOfflineAudioContext;
|
|
25
24
|
|
|
26
|
-
var createAudioRecorder: (
|
|
25
|
+
var createAudioRecorder: () => IAudioRecorder;
|
|
27
26
|
|
|
28
27
|
var createAudioDecoder: () => IAudioDecoder;
|
|
29
28
|
|
package/src/api.ts
CHANGED
|
@@ -25,49 +25,28 @@ export { default as StreamerNode } from './core/StreamerNode';
|
|
|
25
25
|
export { default as WorkletNode } from './core/WorkletNode';
|
|
26
26
|
export { default as WorkletProcessingNode } from './core/WorkletProcessingNode';
|
|
27
27
|
export { default as WorkletSourceNode } from './core/WorkletSourceNode';
|
|
28
|
+
|
|
28
29
|
export { default as useSystemVolume } from './hooks/useSystemVolume';
|
|
29
30
|
export { default as AudioManager } from './system';
|
|
30
31
|
|
|
32
|
+
export * from './errors';
|
|
33
|
+
export * from './system/types';
|
|
34
|
+
export * from './types';
|
|
35
|
+
export { default as FilePreset } from './utils/filePresets';
|
|
36
|
+
|
|
31
37
|
// Notification System
|
|
32
38
|
export {
|
|
33
39
|
PlaybackNotificationManager,
|
|
34
40
|
RecordingNotificationManager,
|
|
35
41
|
} from './system/notification';
|
|
36
42
|
|
|
37
|
-
export {
|
|
38
|
-
AudioWorkletRuntime,
|
|
39
|
-
BiquadFilterType,
|
|
40
|
-
ChannelCountMode,
|
|
41
|
-
ChannelInterpretation,
|
|
42
|
-
ContextState,
|
|
43
|
-
OscillatorType,
|
|
44
|
-
PeriodicWaveConstraints,
|
|
45
|
-
WindowType,
|
|
46
|
-
} from './types';
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
IOSCategory,
|
|
50
|
-
IOSMode,
|
|
51
|
-
IOSOption,
|
|
52
|
-
PermissionStatus,
|
|
53
|
-
SessionOptions,
|
|
54
|
-
} from './system/types';
|
|
55
|
-
|
|
56
43
|
export {
|
|
57
44
|
NotificationManager,
|
|
58
|
-
PlaybackNotificationInfo,
|
|
59
45
|
PlaybackControlName,
|
|
60
46
|
PlaybackNotificationEventName,
|
|
61
|
-
|
|
47
|
+
PlaybackNotificationInfo,
|
|
62
48
|
RecordingControlName,
|
|
63
49
|
RecordingNotificationEventName,
|
|
50
|
+
RecordingNotificationInfo,
|
|
64
51
|
SimpleNotificationOptions,
|
|
65
52
|
} from './system/notification';
|
|
66
|
-
|
|
67
|
-
export {
|
|
68
|
-
IndexSizeError,
|
|
69
|
-
InvalidAccessError,
|
|
70
|
-
InvalidStateError,
|
|
71
|
-
NotSupportedError,
|
|
72
|
-
RangeError,
|
|
73
|
-
} from './errors';
|
|
@@ -1,57 +1,229 @@
|
|
|
1
|
+
import { AudioEventEmitter, AudioEventSubscription } from '../events';
|
|
2
|
+
import {
|
|
3
|
+
OnAudioReadyEventType,
|
|
4
|
+
OnRecorderErrorEventType,
|
|
5
|
+
} from '../events/types';
|
|
1
6
|
import { IAudioRecorder } from '../interfaces';
|
|
2
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
AudioRecorderCallbackOptions,
|
|
9
|
+
AudioRecorderFileOptions,
|
|
10
|
+
FileDirectory,
|
|
11
|
+
FileFormat,
|
|
12
|
+
FileInfo,
|
|
13
|
+
Result,
|
|
14
|
+
} from '../types';
|
|
15
|
+
import FilePreset from '../utils/filePresets';
|
|
3
16
|
import AudioBuffer from './AudioBuffer';
|
|
4
|
-
import { OnAudioReadyEventType } from '../events/types';
|
|
5
|
-
import { AudioEventEmitter } from '../events';
|
|
6
17
|
import RecorderAdapterNode from './RecorderAdapterNode';
|
|
7
18
|
|
|
19
|
+
// Enforces default options, making sure that all properties are defined
|
|
20
|
+
// for the contract with native code.
|
|
21
|
+
function withDefaultOptions(
|
|
22
|
+
inOptions: AudioRecorderFileOptions
|
|
23
|
+
): Required<AudioRecorderFileOptions> {
|
|
24
|
+
return {
|
|
25
|
+
directory: FileDirectory.Cache,
|
|
26
|
+
subDirectory: 'AudioAPI',
|
|
27
|
+
fileNamePrefix: 'recording_',
|
|
28
|
+
channelCount: 2,
|
|
29
|
+
format: FileFormat.M4A,
|
|
30
|
+
batchDurationSeconds: 0,
|
|
31
|
+
preset: FilePreset.High,
|
|
32
|
+
androidFlushIntervalMs: 500,
|
|
33
|
+
...inOptions,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
8
37
|
export default class AudioRecorder {
|
|
38
|
+
protected onAudioReadySubscription: AudioEventSubscription | null = null;
|
|
39
|
+
protected onErrorSubscription: AudioEventSubscription | null = null;
|
|
9
40
|
protected readonly recorder: IAudioRecorder;
|
|
41
|
+
protected options_: AudioRecorderFileOptions | null = null;
|
|
42
|
+
private isFileOutputEnabled: boolean = false;
|
|
10
43
|
|
|
11
|
-
|
|
44
|
+
protected readonly audioEventEmitter = new AudioEventEmitter(
|
|
12
45
|
global.AudioEventEmitter
|
|
13
46
|
);
|
|
14
47
|
|
|
15
|
-
constructor(
|
|
16
|
-
this.recorder = global.createAudioRecorder(
|
|
48
|
+
constructor() {
|
|
49
|
+
this.recorder = global.createAudioRecorder();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
enableFileOutput(
|
|
53
|
+
// TODO: Re-enable 'batchDurationSeconds' once supported
|
|
54
|
+
options?: Omit<AudioRecorderFileOptions, 'batchDurationSeconds'>
|
|
55
|
+
): Result<{ path: string }> {
|
|
56
|
+
this.options_ = options || {};
|
|
57
|
+
const parsedOptions = withDefaultOptions(this.options_);
|
|
58
|
+
const result = this.recorder.enableFileOutput(parsedOptions);
|
|
59
|
+
this.isFileOutputEnabled = true;
|
|
60
|
+
|
|
61
|
+
return result;
|
|
17
62
|
}
|
|
18
63
|
|
|
19
|
-
public
|
|
20
|
-
this.
|
|
64
|
+
public get options(): AudioRecorderFileOptions | null {
|
|
65
|
+
return this.options_;
|
|
21
66
|
}
|
|
22
67
|
|
|
23
|
-
|
|
24
|
-
this.
|
|
68
|
+
disableFileOutput(): void {
|
|
69
|
+
this.options_ = null;
|
|
70
|
+
this.recorder.disableFileOutput();
|
|
71
|
+
this.isFileOutputEnabled = false;
|
|
25
72
|
}
|
|
26
73
|
|
|
27
|
-
|
|
74
|
+
/** Starts the audio recording process with configured output options */
|
|
75
|
+
start(): Result<{ path: string }> {
|
|
76
|
+
if (!this.isFileOutputEnabled) {
|
|
77
|
+
this.recorder.start();
|
|
78
|
+
return { status: 'success', path: '' };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return this.recorder.start();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Stops the audio recording process and releases internal resources */
|
|
85
|
+
stop(): Result<FileInfo> {
|
|
86
|
+
return this.recorder.stop();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Pauses the audio recording process without tearing down anything */
|
|
90
|
+
pause(): void {
|
|
91
|
+
this.recorder.pause();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Resumes the audio recording process after being paused */
|
|
95
|
+
resume(): void {
|
|
96
|
+
this.recorder.resume();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Connects a {@link RecorderAdapterNode} to the recorder’s audio graph.
|
|
101
|
+
*
|
|
102
|
+
* Each node can only be connected once. Attempting to connect a node multiple
|
|
103
|
+
* times will throw an error.
|
|
104
|
+
*
|
|
105
|
+
* @param node - The adapter node to connect to the recorder.
|
|
106
|
+
* @throws If the node has already been connected.
|
|
107
|
+
*/
|
|
108
|
+
connect(node: RecorderAdapterNode): void {
|
|
28
109
|
if (node.wasConnected) {
|
|
29
110
|
throw new Error(
|
|
30
111
|
'RecorderAdapterNode cannot be connected more than once. Refer to the documentation for more details.'
|
|
31
112
|
);
|
|
32
113
|
}
|
|
114
|
+
|
|
33
115
|
node.wasConnected = true;
|
|
34
116
|
this.recorder.connect(node.getNode());
|
|
35
117
|
}
|
|
36
118
|
|
|
37
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Disconnects the recorder from all connected adapter nodes.
|
|
121
|
+
*
|
|
122
|
+
* After calling this method, any connected {@link RecorderAdapterNode} will no
|
|
123
|
+
* longer receive audio data until reconnected.
|
|
124
|
+
*/
|
|
125
|
+
disconnect(): void {
|
|
38
126
|
this.recorder.disconnect();
|
|
39
127
|
}
|
|
40
128
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Registers a callback to receive raw audio data during an active recording
|
|
131
|
+
* session.
|
|
132
|
+
*
|
|
133
|
+
* The callback is periodically invoked with audio buffers that match the
|
|
134
|
+
* preferred configuration provided in `options`. These parameters (sample
|
|
135
|
+
* rate, buffer length, and channel count) guide how audio data is chunked and
|
|
136
|
+
* delivered, though the exact values may vary depending on device
|
|
137
|
+
* capabilities. Values may vary depending on device capabilities.
|
|
138
|
+
*
|
|
139
|
+
* @param options - Preferred configuration for the audio buffers delivered to
|
|
140
|
+
* the callback.
|
|
141
|
+
* @param callback - Function invoked each time a new audio buffer is
|
|
142
|
+
* available. The callback receives an {@link OnAudioReadyEventType} object
|
|
143
|
+
* containing the audio data and associated metadata.
|
|
144
|
+
*/
|
|
145
|
+
onAudioReady(
|
|
146
|
+
options: AudioRecorderCallbackOptions,
|
|
147
|
+
callback: (event: OnAudioReadyEventType) => void
|
|
148
|
+
): Result<void> {
|
|
149
|
+
if (this.onAudioReadySubscription) {
|
|
150
|
+
this.recorder.clearOnAudioReady();
|
|
151
|
+
this.onAudioReadySubscription.remove();
|
|
152
|
+
this.onAudioReadySubscription = null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
this.onAudioReadySubscription =
|
|
156
|
+
this.audioEventEmitter.addAudioEventListener('audioReady', (event) => {
|
|
157
|
+
const audioBuffer = new AudioBuffer(event.buffer);
|
|
158
|
+
callback({
|
|
159
|
+
...event,
|
|
160
|
+
buffer: audioBuffer,
|
|
161
|
+
});
|
|
47
162
|
});
|
|
48
|
-
};
|
|
49
163
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
164
|
+
return this.recorder.setOnAudioReady({
|
|
165
|
+
sampleRate: options.sampleRate,
|
|
166
|
+
bufferLength: options.bufferLength,
|
|
167
|
+
channelCount: options.channelCount,
|
|
168
|
+
callbackId: this.onAudioReadySubscription.subscriptionId,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Removes the previously registered audio data callback, if any.
|
|
174
|
+
*
|
|
175
|
+
* This stops further `onAudioReady` events from being delivered during
|
|
176
|
+
* recording. Calling this method is safe even if no callback is currently
|
|
177
|
+
* registered.
|
|
178
|
+
*/
|
|
179
|
+
clearOnAudioReady(): void {
|
|
180
|
+
if (!this.onAudioReadySubscription) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
this.recorder.clearOnAudioReady();
|
|
185
|
+
|
|
186
|
+
this.onAudioReadySubscription.remove();
|
|
187
|
+
this.onAudioReadySubscription = null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
isRecording(): boolean {
|
|
191
|
+
return this.recorder.isRecording();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
isPaused(): boolean {
|
|
195
|
+
return this.recorder.isPaused();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
getCurrentDuration(): number {
|
|
199
|
+
return this.recorder.getCurrentDuration();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
onError(callback: (error: OnRecorderErrorEventType) => void): void {
|
|
203
|
+
if (this.onErrorSubscription) {
|
|
204
|
+
this.recorder.clearOnError();
|
|
205
|
+
this.onErrorSubscription.remove();
|
|
206
|
+
this.onErrorSubscription = null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
this.onErrorSubscription = this.audioEventEmitter.addAudioEventListener(
|
|
210
|
+
'recorderError',
|
|
211
|
+
callback
|
|
53
212
|
);
|
|
54
213
|
|
|
55
|
-
this.recorder.
|
|
214
|
+
this.recorder.setOnError({
|
|
215
|
+
callbackId: this.onErrorSubscription.subscriptionId,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
clearOnError(): void {
|
|
220
|
+
if (!this.onErrorSubscription) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
this.recorder.clearOnError();
|
|
225
|
+
|
|
226
|
+
this.onErrorSubscription.remove();
|
|
227
|
+
this.onErrorSubscription = null;
|
|
56
228
|
}
|
|
57
229
|
}
|
package/src/events/types.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface EventTypeWithValue {
|
|
|
9
9
|
|
|
10
10
|
interface OnInterruptionEventType {
|
|
11
11
|
type: 'ended' | 'began';
|
|
12
|
-
|
|
12
|
+
shouldResume: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
interface OnRouteChangeEventType {
|
|
@@ -24,7 +24,26 @@ interface OnRouteChangeEventType {
|
|
|
24
24
|
| 'NoSuitableRouteForCategory';
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
export interface OnRecorderErrorEventType {
|
|
28
|
+
message: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface RemoteCommandEvents {
|
|
32
|
+
remotePlay: EventEmptyType;
|
|
33
|
+
remotePause: EventEmptyType;
|
|
34
|
+
remoteStop: EventEmptyType;
|
|
35
|
+
remoteTogglePlayPause: EventEmptyType;
|
|
36
|
+
remoteChangePlaybackRate: EventTypeWithValue;
|
|
37
|
+
remoteNextTrack: EventEmptyType;
|
|
38
|
+
remotePreviousTrack: EventEmptyType;
|
|
39
|
+
remoteSkipForward: EventTypeWithValue;
|
|
40
|
+
remoteSkipBackward: EventTypeWithValue;
|
|
41
|
+
remoteSeekForward: EventEmptyType;
|
|
42
|
+
remoteSeekBackward: EventEmptyType;
|
|
43
|
+
remoteChangePlaybackPosition: EventTypeWithValue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type SystemEvents = RemoteCommandEvents & {
|
|
28
47
|
volumeChange: EventTypeWithValue;
|
|
29
48
|
interruption: OnInterruptionEventType;
|
|
30
49
|
routeChange: OnRouteChangeEventType;
|
|
@@ -35,9 +54,27 @@ export interface OnEndedEventType extends EventEmptyType {
|
|
|
35
54
|
isLast: boolean | undefined;
|
|
36
55
|
}
|
|
37
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Represents the data payload received by the audio recorder callback each time
|
|
59
|
+
* a new audio buffer becomes available during recording.
|
|
60
|
+
*/
|
|
38
61
|
export interface OnAudioReadyEventType {
|
|
62
|
+
/**
|
|
63
|
+
* The audio buffer containing the recorded PCM data. This buffer includes one
|
|
64
|
+
* or more channels of floating-point samples in the range of -1.0 to 1.0.
|
|
65
|
+
*/
|
|
39
66
|
buffer: AudioBuffer;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The number of audio frames contained in this buffer. A frame represents a
|
|
70
|
+
* single sample across all channels.
|
|
71
|
+
*/
|
|
40
72
|
numFrames: number;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The timestamp (in seconds) indicating when this buffer was captured,
|
|
76
|
+
* relative to the start of the recording session.
|
|
77
|
+
*/
|
|
41
78
|
when: number;
|
|
42
79
|
}
|
|
43
80
|
|
|
@@ -48,6 +85,7 @@ interface AudioAPIEvents {
|
|
|
48
85
|
positionChanged: EventTypeWithValue;
|
|
49
86
|
audioError: EventEmptyType; // to change
|
|
50
87
|
systemStateChanged: EventEmptyType; // to change
|
|
88
|
+
recorderError: OnRecorderErrorEventType;
|
|
51
89
|
}
|
|
52
90
|
|
|
53
91
|
type AudioEvents = SystemEvents & AudioAPIEvents & NotificationEvents;
|