@siteed/expo-audio-stream 2.1.0 → 2.2.0

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.
Files changed (187) hide show
  1. package/README.md +40 -222
  2. package/build/index.d.ts +11 -15
  3. package/build/index.js +44 -14
  4. package/package.json +49 -110
  5. package/src/index.ts +18 -32
  6. package/CHANGELOG.md +0 -206
  7. package/android/build.gradle +0 -105
  8. package/android/src/main/AndroidManifest.xml +0 -27
  9. package/android/src/main/java/net/siteed/audiostream/AudioAnalysisData.kt +0 -166
  10. package/android/src/main/java/net/siteed/audiostream/AudioDataEncoder.kt +0 -9
  11. package/android/src/main/java/net/siteed/audiostream/AudioFileHandler.kt +0 -131
  12. package/android/src/main/java/net/siteed/audiostream/AudioFormatUtils.kt +0 -103
  13. package/android/src/main/java/net/siteed/audiostream/AudioNotificationsManager.kt +0 -435
  14. package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +0 -2235
  15. package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +0 -1437
  16. package/android/src/main/java/net/siteed/audiostream/AudioRecordingService.kt +0 -152
  17. package/android/src/main/java/net/siteed/audiostream/AudioTrimmer.kt +0 -1099
  18. package/android/src/main/java/net/siteed/audiostream/Constants.kt +0 -21
  19. package/android/src/main/java/net/siteed/audiostream/EventSender.kt +0 -7
  20. package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +0 -739
  21. package/android/src/main/java/net/siteed/audiostream/FFT.kt +0 -99
  22. package/android/src/main/java/net/siteed/audiostream/Features.kt +0 -98
  23. package/android/src/main/java/net/siteed/audiostream/NotificationConfig.kt +0 -70
  24. package/android/src/main/java/net/siteed/audiostream/PermissionUtils.kt +0 -59
  25. package/android/src/main/java/net/siteed/audiostream/RecordingActionReceiver.kt +0 -59
  26. package/android/src/main/java/net/siteed/audiostream/RecordingConfig.kt +0 -205
  27. package/android/src/main/java/net/siteed/audiostream/WaveformConfig.kt +0 -19
  28. package/android/src/main/java/net/siteed/audiostream/WaveformRenderer.kt +0 -159
  29. package/android/src/main/res/drawable/ic_default_action_icon.xml +0 -16
  30. package/android/src/main/res/drawable/ic_microphone.xml +0 -13
  31. package/android/src/main/res/drawable/ic_pause.xml +0 -10
  32. package/android/src/main/res/drawable/ic_play.xml +0 -10
  33. package/android/src/main/res/drawable/ic_stop.xml +0 -10
  34. package/android/src/main/res/layout/notification_recording.xml +0 -37
  35. package/android/src/main/test/java/net/siteed/audiostream/AudioProcessorTest.kt +0 -56
  36. package/app.plugin.js +0 -1
  37. package/build/AudioAnalysis/AudioAnalysis.types.d.ts +0 -179
  38. package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +0 -1
  39. package/build/AudioAnalysis/AudioAnalysis.types.js +0 -3
  40. package/build/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
  41. package/build/AudioAnalysis/extractAudioAnalysis.d.ts +0 -68
  42. package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +0 -1
  43. package/build/AudioAnalysis/extractAudioAnalysis.js +0 -203
  44. package/build/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
  45. package/build/AudioAnalysis/extractAudioData.d.ts +0 -3
  46. package/build/AudioAnalysis/extractAudioData.d.ts.map +0 -1
  47. package/build/AudioAnalysis/extractAudioData.js +0 -5
  48. package/build/AudioAnalysis/extractAudioData.js.map +0 -1
  49. package/build/AudioAnalysis/extractMelSpectrogram.d.ts +0 -14
  50. package/build/AudioAnalysis/extractMelSpectrogram.d.ts.map +0 -1
  51. package/build/AudioAnalysis/extractMelSpectrogram.js +0 -85
  52. package/build/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
  53. package/build/AudioAnalysis/extractPreview.d.ts +0 -11
  54. package/build/AudioAnalysis/extractPreview.d.ts.map +0 -1
  55. package/build/AudioAnalysis/extractPreview.js +0 -25
  56. package/build/AudioAnalysis/extractPreview.js.map +0 -1
  57. package/build/AudioAnalysis/extractWaveform.d.ts +0 -8
  58. package/build/AudioAnalysis/extractWaveform.d.ts.map +0 -1
  59. package/build/AudioAnalysis/extractWaveform.js +0 -11
  60. package/build/AudioAnalysis/extractWaveform.js.map +0 -1
  61. package/build/AudioRecorder.provider.d.ts +0 -11
  62. package/build/AudioRecorder.provider.d.ts.map +0 -1
  63. package/build/AudioRecorder.provider.js +0 -37
  64. package/build/AudioRecorder.provider.js.map +0 -1
  65. package/build/ExpoAudioStream.native.d.ts +0 -3
  66. package/build/ExpoAudioStream.native.d.ts.map +0 -1
  67. package/build/ExpoAudioStream.native.js +0 -6
  68. package/build/ExpoAudioStream.native.js.map +0 -1
  69. package/build/ExpoAudioStream.types.d.ts +0 -532
  70. package/build/ExpoAudioStream.types.d.ts.map +0 -1
  71. package/build/ExpoAudioStream.types.js +0 -2
  72. package/build/ExpoAudioStream.types.js.map +0 -1
  73. package/build/ExpoAudioStream.web.d.ts +0 -59
  74. package/build/ExpoAudioStream.web.d.ts.map +0 -1
  75. package/build/ExpoAudioStream.web.js +0 -285
  76. package/build/ExpoAudioStream.web.js.map +0 -1
  77. package/build/ExpoAudioStreamModule.d.ts +0 -3
  78. package/build/ExpoAudioStreamModule.d.ts.map +0 -1
  79. package/build/ExpoAudioStreamModule.js +0 -693
  80. package/build/ExpoAudioStreamModule.js.map +0 -1
  81. package/build/WebRecorder.web.d.ts +0 -119
  82. package/build/WebRecorder.web.d.ts.map +0 -1
  83. package/build/WebRecorder.web.js +0 -436
  84. package/build/WebRecorder.web.js.map +0 -1
  85. package/build/constants.d.ts +0 -11
  86. package/build/constants.d.ts.map +0 -1
  87. package/build/constants.js +0 -14
  88. package/build/constants.js.map +0 -1
  89. package/build/events.d.ts +0 -26
  90. package/build/events.d.ts.map +0 -1
  91. package/build/events.js +0 -21
  92. package/build/events.js.map +0 -1
  93. package/build/index.d.ts.map +0 -1
  94. package/build/index.js.map +0 -1
  95. package/build/trimAudio.d.ts +0 -25
  96. package/build/trimAudio.d.ts.map +0 -1
  97. package/build/trimAudio.js +0 -67
  98. package/build/trimAudio.js.map +0 -1
  99. package/build/useAudioRecorder.d.ts +0 -21
  100. package/build/useAudioRecorder.d.ts.map +0 -1
  101. package/build/useAudioRecorder.js +0 -427
  102. package/build/useAudioRecorder.js.map +0 -1
  103. package/build/utils/BlobFix.d.ts +0 -9
  104. package/build/utils/BlobFix.d.ts.map +0 -1
  105. package/build/utils/BlobFix.js +0 -498
  106. package/build/utils/BlobFix.js.map +0 -1
  107. package/build/utils/audioProcessing.d.ts +0 -24
  108. package/build/utils/audioProcessing.d.ts.map +0 -1
  109. package/build/utils/audioProcessing.js +0 -133
  110. package/build/utils/audioProcessing.js.map +0 -1
  111. package/build/utils/concatenateBuffers.d.ts +0 -8
  112. package/build/utils/concatenateBuffers.d.ts.map +0 -1
  113. package/build/utils/concatenateBuffers.js +0 -21
  114. package/build/utils/concatenateBuffers.js.map +0 -1
  115. package/build/utils/convertPCMToFloat32.d.ts +0 -13
  116. package/build/utils/convertPCMToFloat32.d.ts.map +0 -1
  117. package/build/utils/convertPCMToFloat32.js +0 -120
  118. package/build/utils/convertPCMToFloat32.js.map +0 -1
  119. package/build/utils/encodingToBitDepth.d.ts +0 -5
  120. package/build/utils/encodingToBitDepth.d.ts.map +0 -1
  121. package/build/utils/encodingToBitDepth.js +0 -13
  122. package/build/utils/encodingToBitDepth.js.map +0 -1
  123. package/build/utils/getWavFileInfo.d.ts +0 -26
  124. package/build/utils/getWavFileInfo.d.ts.map +0 -1
  125. package/build/utils/getWavFileInfo.js +0 -92
  126. package/build/utils/getWavFileInfo.js.map +0 -1
  127. package/build/utils/writeWavHeader.d.ts +0 -49
  128. package/build/utils/writeWavHeader.d.ts.map +0 -1
  129. package/build/utils/writeWavHeader.js +0 -91
  130. package/build/utils/writeWavHeader.js.map +0 -1
  131. package/build/workers/InlineFeaturesExtractor.web.d.ts +0 -2
  132. package/build/workers/InlineFeaturesExtractor.web.d.ts.map +0 -1
  133. package/build/workers/InlineFeaturesExtractor.web.js +0 -828
  134. package/build/workers/InlineFeaturesExtractor.web.js.map +0 -1
  135. package/build/workers/inlineAudioWebWorker.web.d.ts +0 -2
  136. package/build/workers/inlineAudioWebWorker.web.d.ts.map +0 -1
  137. package/build/workers/inlineAudioWebWorker.web.js +0 -157
  138. package/build/workers/inlineAudioWebWorker.web.js.map +0 -1
  139. package/expo-module.config.json +0 -9
  140. package/ios/AudioAnalysisData.swift +0 -74
  141. package/ios/AudioNotificationManager.swift +0 -135
  142. package/ios/AudioProcessingHelpers.swift +0 -743
  143. package/ios/AudioProcessor.swift +0 -1313
  144. package/ios/AudioStreamError.swift +0 -7
  145. package/ios/AudioStreamManager.swift +0 -1708
  146. package/ios/AudioStreamManagerDelegate.swift +0 -16
  147. package/ios/DataPoint.swift +0 -54
  148. package/ios/DecodingConfig.swift +0 -47
  149. package/ios/ExpoAudioStream.podspec +0 -27
  150. package/ios/ExpoAudioStreamModule.swift +0 -805
  151. package/ios/FFT.swift +0 -62
  152. package/ios/Features.swift +0 -95
  153. package/ios/Logger.swift +0 -7
  154. package/ios/NotificationExtension.swift +0 -15
  155. package/ios/RecordingResult.swift +0 -22
  156. package/ios/RecordingSettings.swift +0 -265
  157. package/ios/WaveformExtractor.swift +0 -105
  158. package/plugin/build/index.d.ts +0 -21
  159. package/plugin/build/index.js +0 -191
  160. package/plugin/src/index.ts +0 -278
  161. package/plugin/tsconfig.json +0 -10
  162. package/plugin/tsconfig.tsbuildinfo +0 -1
  163. package/src/AudioAnalysis/AudioAnalysis.types.ts +0 -202
  164. package/src/AudioAnalysis/extractAudioAnalysis.ts +0 -333
  165. package/src/AudioAnalysis/extractAudioData.ts +0 -6
  166. package/src/AudioAnalysis/extractMelSpectrogram.ts +0 -144
  167. package/src/AudioAnalysis/extractPreview.ts +0 -34
  168. package/src/AudioAnalysis/extractWaveform.ts +0 -22
  169. package/src/AudioRecorder.provider.tsx +0 -54
  170. package/src/ExpoAudioStream.native.ts +0 -6
  171. package/src/ExpoAudioStream.types.ts +0 -641
  172. package/src/ExpoAudioStream.web.ts +0 -359
  173. package/src/ExpoAudioStreamModule.ts +0 -967
  174. package/src/WebRecorder.web.ts +0 -580
  175. package/src/constants.ts +0 -18
  176. package/src/events.ts +0 -60
  177. package/src/trimAudio.ts +0 -90
  178. package/src/useAudioRecorder.tsx +0 -620
  179. package/src/utils/BlobFix.ts +0 -559
  180. package/src/utils/audioProcessing.ts +0 -205
  181. package/src/utils/concatenateBuffers.ts +0 -24
  182. package/src/utils/convertPCMToFloat32.ts +0 -170
  183. package/src/utils/encodingToBitDepth.ts +0 -18
  184. package/src/utils/getWavFileInfo.ts +0 -132
  185. package/src/utils/writeWavHeader.ts +0 -114
  186. package/src/workers/InlineFeaturesExtractor.web.tsx +0 -827
  187. package/src/workers/inlineAudioWebWorker.web.tsx +0 -156
@@ -1,641 +0,0 @@
1
- // packages/expo-audio-stream/src/ExpoAudioStream.types.ts
2
- import {
3
- AudioAnalysis,
4
- AudioFeaturesOptions,
5
- DecodingConfig,
6
- } from './AudioAnalysis/AudioAnalysis.types'
7
- import { AudioAnalysisEvent } from './events'
8
-
9
- export interface CompressionInfo {
10
- /** Size of the compressed audio data in bytes */
11
- size: number
12
- /** MIME type of the compressed audio (e.g., 'audio/aac', 'audio/opus') */
13
- mimeType: string
14
- /** Bitrate of the compressed audio in bits per second */
15
- bitrate: number
16
- /** Format of the compression (e.g., 'aac', 'opus') */
17
- format: string
18
- /** URI to the compressed audio file if available */
19
- compressedFileUri?: string
20
- }
21
-
22
- export interface AudioStreamStatus {
23
- /** Indicates whether audio recording is currently active */
24
- isRecording: boolean
25
- /** Indicates whether recording is in a paused state */
26
- isPaused: boolean
27
- /** Duration of the current recording in milliseconds */
28
- durationMs: number
29
- /** Size of the recorded audio data in bytes */
30
- size: number
31
- /** Interval in milliseconds at which recording data is emitted */
32
- interval: number
33
- /** Interval in milliseconds at which analysis data is emitted */
34
- intervalAnalysis: number
35
- /** MIME type of the recorded audio (e.g., 'audio/wav') */
36
- mimeType: string
37
- /** Information about audio compression if enabled */
38
- compression?: CompressionInfo
39
- }
40
-
41
- export interface AudioDataEvent {
42
- /** Audio data as base64 string (native) or Float32Array (web) */
43
- data: string | Float32Array
44
- /** Current position in the audio stream in bytes */
45
- position: number
46
- /** URI to the file being recorded */
47
- fileUri: string
48
- /** Size of the current data chunk in bytes */
49
- eventDataSize: number
50
- /** Total size of the recording so far in bytes */
51
- totalSize: number
52
- /** Information about compression if enabled, including the compressed data chunk */
53
- compression?: CompressionInfo & {
54
- /** Base64 (native) or Blob (web) encoded compressed data chunk */
55
- data?: string | Blob
56
- }
57
- }
58
-
59
- export type EncodingType = 'pcm_32bit' | 'pcm_16bit' | 'pcm_8bit'
60
- export type SampleRate = 16000 | 44100 | 48000
61
- export type BitDepth = 8 | 16 | 32
62
- export type PCMFormat = `pcm_${BitDepth}bit`
63
-
64
- export type ConsoleLike = {
65
- /** Logs a message with optional arguments */
66
- log: (message: string, ...args: unknown[]) => void
67
- /** Logs a debug message with optional arguments */
68
- debug: (message: string, ...args: unknown[]) => void
69
- /** Logs an info message with optional arguments */
70
- info: (message: string, ...args: unknown[]) => void
71
- /** Logs a warning message with optional arguments */
72
- warn: (message: string, ...args: unknown[]) => void
73
- /** Logs an error message with optional arguments */
74
- error: (message: string, ...args: unknown[]) => void
75
- }
76
-
77
- export interface Chunk {
78
- /** Transcribed text content */
79
- text: string
80
- /** Start and end timestamp in seconds [start, end] where end can be null if ongoing */
81
- timestamp: [number, number | null]
82
- }
83
-
84
- export interface TranscriberData {
85
- /** Unique identifier for the transcription */
86
- id: string
87
- /** Indicates if the transcriber is currently processing */
88
- isBusy: boolean
89
- /** Complete transcribed text */
90
- text: string
91
- /** Start time of the transcription in milliseconds */
92
- startTime: number
93
- /** End time of the transcription in milliseconds */
94
- endTime: number
95
- /** Array of transcribed text chunks with timestamps */
96
- chunks: Chunk[]
97
- }
98
-
99
- export interface AudioRecording {
100
- /** URI to the recorded audio file */
101
- fileUri: string
102
- /** Filename of the recorded audio */
103
- filename: string
104
- /** Duration of the recording in milliseconds */
105
- durationMs: number
106
- /** Size of the recording in bytes */
107
- size: number
108
- /** MIME type of the recorded audio */
109
- mimeType: string
110
- /** Number of audio channels (1 for mono, 2 for stereo) */
111
- channels: number
112
- /** Bit depth of the audio (8, 16, or 32 bits) */
113
- bitDepth: BitDepth
114
- /** Sample rate of the audio in Hz */
115
- sampleRate: SampleRate
116
- /** Timestamp when the recording was created */
117
- createdAt?: number
118
- /** Array of transcription data if available */
119
- transcripts?: TranscriberData[]
120
- /** Analysis data for the recording if processing was enabled */
121
- analysisData?: AudioAnalysis
122
- /** Information about compression if enabled, including the URI to the compressed file */
123
- compression?: CompressionInfo & {
124
- /** URI to the compressed audio file */
125
- compressedFileUri: string
126
- }
127
- }
128
-
129
- export interface StartRecordingResult {
130
- /** URI to the file being recorded */
131
- fileUri: string
132
- /** MIME type of the recording */
133
- mimeType: string
134
- /** Number of audio channels (1 for mono, 2 for stereo) */
135
- channels?: number
136
- /** Bit depth of the audio (8, 16, or 32 bits) */
137
- bitDepth?: BitDepth
138
- /** Sample rate of the audio in Hz */
139
- sampleRate?: SampleRate
140
- /** Information about compression if enabled, including the URI to the compressed file */
141
- compression?: CompressionInfo & {
142
- /** URI to the compressed audio file */
143
- compressedFileUri: string
144
- }
145
- }
146
-
147
- export interface AudioSessionConfig {
148
- /**
149
- * Audio session category that defines the audio behavior
150
- * - 'Ambient': Audio continues with silent switch, mixes with other audio
151
- * - 'SoloAmbient': Audio continues with silent switch, interrupts other audio
152
- * - 'Playback': Audio continues in background, interrupts other audio
153
- * - 'Record': Optimized for recording, interrupts other audio
154
- * - 'PlayAndRecord': Allows simultaneous playback and recording
155
- * - 'MultiRoute': Routes audio to multiple outputs simultaneously
156
- */
157
- category?:
158
- | 'Ambient'
159
- | 'SoloAmbient'
160
- | 'Playback'
161
- | 'Record'
162
- | 'PlayAndRecord'
163
- | 'MultiRoute'
164
- /**
165
- * Audio session mode that defines the behavior for specific use cases
166
- * - 'Default': Standard audio behavior
167
- * - 'VoiceChat': Optimized for voice chat applications
168
- * - 'VideoChat': Optimized for video chat applications
169
- * - 'GameChat': Optimized for in-game chat
170
- * - 'VideoRecording': Optimized for video recording
171
- * - 'Measurement': Optimized for audio measurement
172
- * - 'MoviePlayback': Optimized for movie playback
173
- * - 'SpokenAudio': Optimized for spoken audio content
174
- */
175
- mode?:
176
- | 'Default'
177
- | 'VoiceChat'
178
- | 'VideoChat'
179
- | 'GameChat'
180
- | 'VideoRecording'
181
- | 'Measurement'
182
- | 'MoviePlayback'
183
- | 'SpokenAudio'
184
- /**
185
- * Options that modify the behavior of the audio session category
186
- * - 'MixWithOthers': Allows mixing with other active audio sessions
187
- * - 'DuckOthers': Reduces the volume of other audio sessions
188
- * - 'InterruptSpokenAudioAndMixWithOthers': Interrupts spoken audio and mixes with others
189
- * - 'AllowBluetooth': Allows audio routing to Bluetooth devices
190
- * - 'AllowBluetoothA2DP': Allows audio routing to Bluetooth A2DP devices
191
- * - 'AllowAirPlay': Allows audio routing to AirPlay devices
192
- * - 'DefaultToSpeaker': Routes audio to the speaker by default
193
- */
194
- categoryOptions?: (
195
- | 'MixWithOthers'
196
- | 'DuckOthers'
197
- | 'InterruptSpokenAudioAndMixWithOthers'
198
- | 'AllowBluetooth'
199
- | 'AllowBluetoothA2DP'
200
- | 'AllowAirPlay'
201
- | 'DefaultToSpeaker'
202
- )[]
203
- }
204
-
205
- export interface IOSConfig {
206
- /** Configuration for the iOS audio session */
207
- audioSession?: AudioSessionConfig
208
- }
209
-
210
- // Add new type for interruption reasons
211
- export type RecordingInterruptionReason =
212
- /** Audio focus was lost to another app */
213
- | 'audioFocusLoss'
214
- /** Audio focus was regained */
215
- | 'audioFocusGain'
216
- /** Recording was interrupted by a phone call */
217
- | 'phoneCall'
218
- /** Phone call that interrupted recording has ended */
219
- | 'phoneCallEnded'
220
- /** Recording was stopped by the system or another app */
221
- | 'recordingStopped'
222
-
223
- // Add new interface for interruption events
224
- export interface RecordingInterruptionEvent {
225
- /** The reason for the recording interruption */
226
- reason: RecordingInterruptionReason
227
- /** Indicates whether the recording is paused due to the interruption */
228
- isPaused: boolean
229
- }
230
-
231
- export interface RecordingConfig {
232
- /** Sample rate for recording in Hz (16000, 44100, or 48000) */
233
- sampleRate?: SampleRate
234
-
235
- /** Number of audio channels (1 for mono, 2 for stereo) */
236
- channels?: 1 | 2
237
-
238
- /** Encoding type for the recording (pcm_32bit, pcm_16bit, pcm_8bit) */
239
- encoding?: EncodingType
240
-
241
- /** Interval in milliseconds at which to emit recording data */
242
- interval?: number
243
-
244
- /** Interval in milliseconds at which to emit analysis data */
245
- intervalAnalysis?: number
246
-
247
- /** Keep the device awake while recording (default is false) */
248
- keepAwake?: boolean
249
-
250
- /** Show a notification during recording (default is false) */
251
- showNotification?: boolean
252
-
253
- /** Show waveform in the notification (Android only, when showNotification is true) */
254
- showWaveformInNotification?: boolean
255
-
256
- /** Configuration for the notification */
257
- notification?: NotificationConfig
258
-
259
- /** Enable audio processing (default is false) */
260
- enableProcessing?: boolean
261
-
262
- /** iOS-specific configuration */
263
- ios?: IOSConfig
264
-
265
- /** Duration of each segment in milliseconds for analysis (default: 100) */
266
- segmentDurationMs?: number
267
-
268
- /** Feature options to extract during audio processing */
269
- features?: AudioFeaturesOptions
270
-
271
- /** Callback function to handle audio stream data */
272
- onAudioStream?: (_: AudioDataEvent) => Promise<void>
273
-
274
- /** Callback function to handle audio features extraction results */
275
- onAudioAnalysis?: (_: AudioAnalysisEvent) => Promise<void>
276
-
277
- /** Configuration for audio compression */
278
- compression?: {
279
- /** Enable audio compression */
280
- enabled: boolean
281
- /** Format for compression (aac or opus) */
282
- format: 'aac' | 'opus'
283
- /** Bitrate for compression in bits per second */
284
- bitrate?: number
285
- }
286
-
287
- /** Whether to automatically resume recording after an interruption (default is false) */
288
- autoResumeAfterInterruption?: boolean
289
-
290
- /** Optional callback to handle recording interruptions */
291
- onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void
292
-
293
- /** Optional directory path where output files will be saved */
294
- outputDirectory?: string // If not provided, uses default app directory
295
- /** Optional filename for the recording (uses UUID if not provided) */
296
- filename?: string // If not provided, uses UUID
297
- }
298
-
299
- export interface NotificationConfig {
300
- /** Title of the notification */
301
- title?: string
302
-
303
- /** Main text content of the notification */
304
- text?: string
305
-
306
- /** Icon to be displayed in the notification (resource name or URI) */
307
- icon?: string
308
-
309
- /** Android-specific notification configuration */
310
- android?: {
311
- /** Unique identifier for the notification channel */
312
- channelId?: string
313
-
314
- /** User-visible name of the notification channel */
315
- channelName?: string
316
-
317
- /** User-visible description of the notification channel */
318
- channelDescription?: string
319
-
320
- /** Unique identifier for this notification */
321
- notificationId?: number
322
-
323
- /** List of actions that can be performed from the notification */
324
- actions?: NotificationAction[]
325
-
326
- /** Configuration for the waveform visualization in the notification */
327
- waveform?: WaveformConfig
328
-
329
- /** Color of the notification LED (if device supports it) */
330
- lightColor?: string
331
-
332
- /** Priority of the notification (affects how it's displayed) */
333
- priority?: 'min' | 'low' | 'default' | 'high' | 'max'
334
-
335
- /** Accent color for the notification (used for the app icon and buttons) */
336
- accentColor?: string
337
- }
338
-
339
- /** iOS-specific notification configuration */
340
- ios?: {
341
- /** Identifier for the notification category (used for grouping similar notifications) */
342
- categoryIdentifier?: string
343
- }
344
- }
345
-
346
- export interface NotificationAction {
347
- /** Display title for the action */
348
- title: string
349
-
350
- /** Unique identifier for the action */
351
- identifier: string
352
-
353
- /** Icon to be displayed for the action (Android only) */
354
- icon?: string
355
- }
356
-
357
- export interface WaveformConfig {
358
- /** The color of the waveform (e.g., "#FFFFFF" for white) */
359
- color?: string // The color of the waveform (e.g., "#FFFFFF" for white)
360
- /** Opacity of the waveform (0.0 - 1.0) */
361
- opacity?: number // Opacity of the waveform (0.0 - 1.0)
362
- /** Width of the waveform line (default: 1.5) */
363
- strokeWidth?: number // Width of the waveform line (default: 1.5)
364
- /** Drawing style: "stroke" for outline, "fill" for solid */
365
- style?: 'stroke' | 'fill' // Drawing style: "stroke" for outline, "fill" for solid
366
- /** Whether to mirror the waveform (symmetrical display) */
367
- mirror?: boolean // Whether to mirror the waveform (symmetrical display)
368
- /** Height of the waveform view in dp (default: 64) */
369
- height?: number // Height of the waveform view in dp (default: 64)
370
- }
371
-
372
- export interface ExtractAudioDataOptions {
373
- /** URI of the audio file to extract data from */
374
- fileUri: string
375
- /** Start time in milliseconds (for time-based range) */
376
- startTimeMs?: number
377
- /** End time in milliseconds (for time-based range) */
378
- endTimeMs?: number
379
- /** Start position in bytes (for byte-based range) */
380
- position?: number
381
- /** Length in bytes to extract (for byte-based range) */
382
- length?: number
383
- /** Include normalized audio data in [-1, 1] range */
384
- includeNormalizedData?: boolean
385
- /** Include base64 encoded string representation of the audio data */
386
- includeBase64Data?: boolean
387
- /** Include WAV header in the PCM data (makes it a valid WAV file) */
388
- includeWavHeader?: boolean
389
- /** Logger for debugging - can pass console directly. */
390
- logger?: ConsoleLike
391
- /** Compute the checksum of the PCM data */
392
- computeChecksum?: boolean
393
- /** Target config for the normalized audio (Android and Web) */
394
- decodingOptions?: DecodingConfig
395
- }
396
-
397
- export interface ExtractedAudioData {
398
- /** Raw PCM audio data */
399
- pcmData: Uint8Array
400
- /** Normalized audio data in [-1, 1] range (when includeNormalizedData is true) */
401
- normalizedData?: Float32Array
402
- /** Base64 encoded string representation of the audio data (when includeBase64Data is true) */
403
- base64Data?: string
404
- /** Sample rate in Hz (e.g., 44100, 48000) */
405
- sampleRate: number
406
- /** Number of audio channels (1 for mono, 2 for stereo) */
407
- channels: number
408
- /** Bits per sample (8, 16, or 32) */
409
- bitDepth: BitDepth
410
- /** Duration of the audio in milliseconds */
411
- durationMs: number
412
- /** PCM format identifier (e.g., "pcm_16bit") */
413
- format: PCMFormat
414
- /** Total number of audio samples per channel */
415
- samples: number
416
- /** Whether the pcmData includes a WAV header */
417
- hasWavHeader?: boolean
418
- /** CRC32 Checksum of PCM data */
419
- checksum?: number
420
- }
421
-
422
- export interface UseAudioRecorderState {
423
- /** Starts recording with the specified configuration */
424
- startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>
425
- /** Stops the current recording and returns the recording data */
426
- stopRecording: () => Promise<AudioRecording | null>
427
- /** Pauses the current recording */
428
- pauseRecording: () => Promise<void>
429
- /** Resumes a paused recording */
430
- resumeRecording: () => Promise<void>
431
- /** Indicates whether recording is currently active */
432
- isRecording: boolean
433
- /** Indicates whether recording is in a paused state */
434
- isPaused: boolean
435
- /** Duration of the current recording in milliseconds */
436
- durationMs: number // Duration of the recording
437
- /** Size of the recorded audio in bytes */
438
- size: number // Size in bytes of the recorded audio
439
- /** Information about compression if enabled */
440
- compression?: CompressionInfo
441
- /** Analysis data for the recording if processing was enabled */
442
- analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag
443
- /** Optional callback to handle recording interruptions */
444
- onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void
445
- }
446
-
447
- /**
448
- * Represents an event emitted during the trimming process to report progress.
449
- */
450
- export interface TrimProgressEvent {
451
- /**
452
- * The percentage of the trimming process that has been completed, ranging from 0 to 100.
453
- */
454
- progress: number
455
-
456
- /**
457
- * The number of bytes that have been processed so far. This is optional and may not be provided in all implementations.
458
- */
459
- bytesProcessed?: number
460
-
461
- /**
462
- * The total number of bytes to process. This is optional and may not be provided in all implementations.
463
- */
464
- totalBytes?: number
465
- }
466
-
467
- /**
468
- * Defines a time range in milliseconds for trimming operations.
469
- */
470
- export interface TimeRange {
471
- /**
472
- * The start time of the range in milliseconds.
473
- */
474
- startTimeMs: number
475
-
476
- /**
477
- * The end time of the range in milliseconds.
478
- */
479
- endTimeMs: number
480
- }
481
-
482
- /**
483
- * Options for configuring the audio trimming operation.
484
- */
485
- export interface TrimAudioOptions {
486
- /**
487
- * The URI of the audio file to trim.
488
- */
489
- fileUri: string
490
-
491
- /**
492
- * The mode of trimming to apply.
493
- * - `'single'`: Trims the audio to a single range defined by `startTimeMs` and `endTimeMs`.
494
- * - `'keep'`: Keeps the specified `ranges` and removes all other portions of the audio.
495
- * - `'remove'`: Removes the specified `ranges` and keeps the remaining portions of the audio.
496
- * @default 'single'
497
- */
498
- mode?: 'single' | 'keep' | 'remove'
499
-
500
- /**
501
- * An array of time ranges to keep or remove, depending on the `mode`.
502
- * - Required for `'keep'` and `'remove'` modes.
503
- * - Ignored when `mode` is `'single'`.
504
- */
505
- ranges?: TimeRange[]
506
-
507
- /**
508
- * The start time in milliseconds for the `'single'` mode.
509
- * - If not provided, trimming starts from the beginning of the audio (0 ms).
510
- */
511
- startTimeMs?: number
512
-
513
- /**
514
- * The end time in milliseconds for the `'single'` mode.
515
- * - If not provided, trimming extends to the end of the audio.
516
- */
517
- endTimeMs?: number
518
-
519
- /**
520
- * The name of the output file. If not provided, a default name will be generated.
521
- */
522
- outputFileName?: string
523
-
524
- /**
525
- * Configuration for the output audio format.
526
- */
527
- outputFormat?: {
528
- /**
529
- * The format of the output audio file.
530
- * - `'wav'`: Waveform Audio File Format (uncompressed).
531
- * - `'aac'`: Advanced Audio Coding (compressed). Not supported on web platforms.
532
- * - `'opus'`: Opus Interactive Audio Codec (compressed).
533
- */
534
- format: 'wav' | 'aac' | 'opus'
535
-
536
- /**
537
- * The sample rate of the output audio in Hertz (Hz).
538
- * - If not provided, the input audio's sample rate is used.
539
- */
540
- sampleRate?: number
541
-
542
- /**
543
- * The number of channels in the output audio (e.g., 1 for mono, 2 for stereo).
544
- * - If not provided, the input audio's channel count is used.
545
- */
546
- channels?: number
547
-
548
- /**
549
- * The bit depth of the output audio, applicable to PCM formats like `'wav'`.
550
- * - If not provided, the input audio's bit depth is used.
551
- */
552
- bitDepth?: number
553
-
554
- /**
555
- * The bitrate of the output audio in bits per second, applicable to compressed formats like `'aac'`.
556
- * - If not provided, a default bitrate is used based on the format.
557
- */
558
- bitrate?: number
559
- }
560
-
561
- /**
562
- * Options for decoding the input audio file.
563
- * - See `DecodingConfig` for details.
564
- */
565
- decodingOptions?: DecodingConfig
566
- }
567
-
568
- /**
569
- * Result of the audio trimming operation.
570
- */
571
- export interface TrimAudioResult {
572
- /**
573
- * The URI of the trimmed audio file.
574
- */
575
- uri: string
576
-
577
- /**
578
- * The filename of the trimmed audio file.
579
- */
580
- filename: string
581
-
582
- /**
583
- * The duration of the trimmed audio in milliseconds.
584
- */
585
- durationMs: number
586
-
587
- /**
588
- * The size of the trimmed audio file in bytes.
589
- */
590
- size: number
591
-
592
- /**
593
- * The sample rate of the trimmed audio in Hertz (Hz).
594
- */
595
- sampleRate: number
596
-
597
- /**
598
- * The number of channels in the trimmed audio (e.g., 1 for mono, 2 for stereo).
599
- */
600
- channels: number
601
-
602
- /**
603
- * The bit depth of the trimmed audio, applicable to PCM formats like `'wav'`.
604
- */
605
- bitDepth: number
606
-
607
- /**
608
- * The MIME type of the trimmed audio file (e.g., `'audio/wav'`, `'audio/mpeg'`).
609
- */
610
- mimeType: string
611
-
612
- /**
613
- * Information about compression if the output format is compressed.
614
- */
615
- compression?: {
616
- /**
617
- * The format of the compression (e.g., `'aac'`, `'mp3'`, `'opus'`).
618
- */
619
- format: string
620
-
621
- /**
622
- * The bitrate of the compressed audio in bits per second.
623
- */
624
- bitrate: number
625
-
626
- /**
627
- * The size of the compressed audio file in bytes.
628
- */
629
- size: number
630
- }
631
-
632
- /**
633
- * Information about the processing time.
634
- */
635
- processingInfo?: {
636
- /**
637
- * The time it took to process the audio in milliseconds.
638
- */
639
- durationMs: number
640
- }
641
- }