@siteed/expo-audio-studio 2.18.6 → 3.0.1

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 (329) hide show
  1. package/README.md +13 -297
  2. package/index.d.ts +1 -0
  3. package/index.js +1 -0
  4. package/package.json +7 -136
  5. package/CHANGELOG.md +0 -501
  6. package/LICENSE +0 -21
  7. package/android/build.gradle +0 -129
  8. package/android/src/androidTest/assets/chorus.wav +0 -0
  9. package/android/src/androidTest/assets/jfk.wav +0 -0
  10. package/android/src/androidTest/assets/osr_us_000_0010_8k.wav +0 -0
  11. package/android/src/androidTest/assets/recorder_hello_world.wav +0 -0
  12. package/android/src/androidTest/java/net/siteed/audiostream/AudioProcessorInstrumentedTest.kt +0 -197
  13. package/android/src/androidTest/java/net/siteed/audiostream/AudioRecorderInstrumentedTest.kt +0 -541
  14. package/android/src/androidTest/java/net/siteed/audiostream/AudioRecorderPerformanceInstrumentedTest.kt +0 -234
  15. package/android/src/androidTest/java/net/siteed/audiostream/integration/AudioFocusStrategyIntegrationTest.kt +0 -332
  16. package/android/src/androidTest/java/net/siteed/audiostream/integration/BufferDurationIntegrationTest.kt +0 -324
  17. package/android/src/androidTest/java/net/siteed/audiostream/integration/CompressedOnlyOutputTest.kt +0 -253
  18. package/android/src/androidTest/java/net/siteed/audiostream/integration/DeviceDisconnectionFallbackTest.kt +0 -218
  19. package/android/src/androidTest/java/net/siteed/audiostream/integration/EventEmissionIntervalTest.kt +0 -120
  20. package/android/src/androidTest/java/net/siteed/audiostream/integration/M4aFormatTest.kt +0 -345
  21. package/android/src/androidTest/java/net/siteed/audiostream/integration/OutputControlIntegrationTest.kt +0 -340
  22. package/android/src/androidTest/java/net/siteed/audiostream/integration/PcmStreamingDurationTest.kt +0 -252
  23. package/android/src/androidTest/java/net/siteed/audiostream/integration/README.md +0 -95
  24. package/android/src/androidTest/java/net/siteed/audiostream/integration/run_integration_tests.sh +0 -43
  25. package/android/src/main/AndroidManifest.xml +0 -30
  26. package/android/src/main/java/net/siteed/audiostream/AudioAnalysisData.kt +0 -188
  27. package/android/src/main/java/net/siteed/audiostream/AudioDataEncoder.kt +0 -9
  28. package/android/src/main/java/net/siteed/audiostream/AudioDeviceManager.kt +0 -1741
  29. package/android/src/main/java/net/siteed/audiostream/AudioFileHandler.kt +0 -136
  30. package/android/src/main/java/net/siteed/audiostream/AudioFormatUtils.kt +0 -354
  31. package/android/src/main/java/net/siteed/audiostream/AudioNotificationsManager.kt +0 -439
  32. package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +0 -2237
  33. package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +0 -2141
  34. package/android/src/main/java/net/siteed/audiostream/AudioRecordingService.kt +0 -167
  35. package/android/src/main/java/net/siteed/audiostream/AudioTrimmer.kt +0 -1099
  36. package/android/src/main/java/net/siteed/audiostream/Constants.kt +0 -37
  37. package/android/src/main/java/net/siteed/audiostream/EventSender.kt +0 -7
  38. package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +0 -1113
  39. package/android/src/main/java/net/siteed/audiostream/FFT.kt +0 -99
  40. package/android/src/main/java/net/siteed/audiostream/Features.kt +0 -98
  41. package/android/src/main/java/net/siteed/audiostream/LogUtils.kt +0 -93
  42. package/android/src/main/java/net/siteed/audiostream/NotificationConfig.kt +0 -72
  43. package/android/src/main/java/net/siteed/audiostream/PermissionUtils.kt +0 -68
  44. package/android/src/main/java/net/siteed/audiostream/RecordingActionReceiver.kt +0 -59
  45. package/android/src/main/java/net/siteed/audiostream/RecordingConfig.kt +0 -257
  46. package/android/src/main/java/net/siteed/audiostream/WaveformConfig.kt +0 -19
  47. package/android/src/main/java/net/siteed/audiostream/WaveformRenderer.kt +0 -159
  48. package/android/src/main/res/drawable/ic_default_action_icon.xml +0 -16
  49. package/android/src/main/res/drawable/ic_microphone.xml +0 -13
  50. package/android/src/main/res/drawable/ic_pause.xml +0 -10
  51. package/android/src/main/res/drawable/ic_play.xml +0 -10
  52. package/android/src/main/res/drawable/ic_stop.xml +0 -10
  53. package/android/src/main/res/layout/notification_recording.xml +0 -37
  54. package/android/src/test/java/net/siteed/audiostream/AudioFileHandlerTest.kt +0 -279
  55. package/android/src/test/java/net/siteed/audiostream/AudioFocusStrategyTest.kt +0 -249
  56. package/android/src/test/java/net/siteed/audiostream/AudioFormatTest.kt +0 -151
  57. package/android/src/test/java/net/siteed/audiostream/AudioFormatUtilsTest.kt +0 -273
  58. package/android/src/test/java/net/siteed/audiostream/DeviceDisconnectionFallbackUnitTest.kt +0 -140
  59. package/android/src/test/resources/chorus.wav +0 -0
  60. package/android/src/test/resources/generate_test_audio.py +0 -94
  61. package/android/src/test/resources/jfk.wav +0 -0
  62. package/android/src/test/resources/osr_us_000_0010_8k.wav +0 -0
  63. package/android/src/test/resources/recorder_hello_world.wav +0 -0
  64. package/app.plugin.js +0 -3
  65. package/build/cjs/AudioAnalysis/AudioAnalysis.types.js +0 -4
  66. package/build/cjs/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
  67. package/build/cjs/AudioAnalysis/extractAudioAnalysis.js +0 -210
  68. package/build/cjs/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
  69. package/build/cjs/AudioAnalysis/extractAudioData.js +0 -21
  70. package/build/cjs/AudioAnalysis/extractAudioData.js.map +0 -1
  71. package/build/cjs/AudioAnalysis/extractMelSpectrogram.js +0 -92
  72. package/build/cjs/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
  73. package/build/cjs/AudioAnalysis/extractPreview.js +0 -28
  74. package/build/cjs/AudioAnalysis/extractPreview.js.map +0 -1
  75. package/build/cjs/AudioAnalysis/extractWaveform.js +0 -18
  76. package/build/cjs/AudioAnalysis/extractWaveform.js.map +0 -1
  77. package/build/cjs/AudioDeviceManager.js +0 -689
  78. package/build/cjs/AudioDeviceManager.js.map +0 -1
  79. package/build/cjs/AudioRecorder.provider.js +0 -78
  80. package/build/cjs/AudioRecorder.provider.js.map +0 -1
  81. package/build/cjs/ExpoAudioStream.native.js +0 -8
  82. package/build/cjs/ExpoAudioStream.native.js.map +0 -1
  83. package/build/cjs/ExpoAudioStream.types.js +0 -11
  84. package/build/cjs/ExpoAudioStream.types.js.map +0 -1
  85. package/build/cjs/ExpoAudioStream.web.js +0 -708
  86. package/build/cjs/ExpoAudioStream.web.js.map +0 -1
  87. package/build/cjs/ExpoAudioStreamModule.js +0 -718
  88. package/build/cjs/ExpoAudioStreamModule.js.map +0 -1
  89. package/build/cjs/WebRecorder.web.js +0 -777
  90. package/build/cjs/WebRecorder.web.js.map +0 -1
  91. package/build/cjs/constants/platformLimitations.js +0 -99
  92. package/build/cjs/constants/platformLimitations.js.map +0 -1
  93. package/build/cjs/constants.js +0 -17
  94. package/build/cjs/constants.js.map +0 -1
  95. package/build/cjs/events.js +0 -29
  96. package/build/cjs/events.js.map +0 -1
  97. package/build/cjs/hooks/useAudioDevices.js +0 -179
  98. package/build/cjs/hooks/useAudioDevices.js.map +0 -1
  99. package/build/cjs/index.js +0 -58
  100. package/build/cjs/index.js.map +0 -1
  101. package/build/cjs/trimAudio.js +0 -76
  102. package/build/cjs/trimAudio.js.map +0 -1
  103. package/build/cjs/useAudioRecorder.js +0 -518
  104. package/build/cjs/useAudioRecorder.js.map +0 -1
  105. package/build/cjs/utils/BlobFix.js +0 -502
  106. package/build/cjs/utils/BlobFix.js.map +0 -1
  107. package/build/cjs/utils/audioProcessing.js +0 -136
  108. package/build/cjs/utils/audioProcessing.js.map +0 -1
  109. package/build/cjs/utils/cleanNativeOptions.js +0 -22
  110. package/build/cjs/utils/cleanNativeOptions.js.map +0 -1
  111. package/build/cjs/utils/concatenateBuffers.js +0 -25
  112. package/build/cjs/utils/concatenateBuffers.js.map +0 -1
  113. package/build/cjs/utils/convertPCMToFloat32.js +0 -124
  114. package/build/cjs/utils/convertPCMToFloat32.js.map +0 -1
  115. package/build/cjs/utils/crc32.js +0 -52
  116. package/build/cjs/utils/crc32.js.map +0 -1
  117. package/build/cjs/utils/encodingToBitDepth.js +0 -17
  118. package/build/cjs/utils/encodingToBitDepth.js.map +0 -1
  119. package/build/cjs/utils/getWavFileInfo.js +0 -96
  120. package/build/cjs/utils/getWavFileInfo.js.map +0 -1
  121. package/build/cjs/utils/writeWavHeader.js +0 -88
  122. package/build/cjs/utils/writeWavHeader.js.map +0 -1
  123. package/build/cjs/workers/InlineFeaturesExtractor.web.js +0 -859
  124. package/build/cjs/workers/InlineFeaturesExtractor.web.js.map +0 -1
  125. package/build/cjs/workers/inlineAudioWebWorker.web.js +0 -184
  126. package/build/cjs/workers/inlineAudioWebWorker.web.js.map +0 -1
  127. package/build/esm/AudioAnalysis/AudioAnalysis.types.js +0 -3
  128. package/build/esm/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
  129. package/build/esm/AudioAnalysis/extractAudioAnalysis.js +0 -202
  130. package/build/esm/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
  131. package/build/esm/AudioAnalysis/extractAudioData.js +0 -14
  132. package/build/esm/AudioAnalysis/extractAudioData.js.map +0 -1
  133. package/build/esm/AudioAnalysis/extractMelSpectrogram.js +0 -89
  134. package/build/esm/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
  135. package/build/esm/AudioAnalysis/extractPreview.js +0 -25
  136. package/build/esm/AudioAnalysis/extractPreview.js.map +0 -1
  137. package/build/esm/AudioAnalysis/extractWaveform.js +0 -11
  138. package/build/esm/AudioAnalysis/extractWaveform.js.map +0 -1
  139. package/build/esm/AudioDeviceManager.js +0 -682
  140. package/build/esm/AudioDeviceManager.js.map +0 -1
  141. package/build/esm/AudioRecorder.provider.js +0 -40
  142. package/build/esm/AudioRecorder.provider.js.map +0 -1
  143. package/build/esm/ExpoAudioStream.native.js +0 -6
  144. package/build/esm/ExpoAudioStream.native.js.map +0 -1
  145. package/build/esm/ExpoAudioStream.types.js +0 -8
  146. package/build/esm/ExpoAudioStream.types.js.map +0 -1
  147. package/build/esm/ExpoAudioStream.web.js +0 -704
  148. package/build/esm/ExpoAudioStream.web.js.map +0 -1
  149. package/build/esm/ExpoAudioStreamModule.js +0 -713
  150. package/build/esm/ExpoAudioStreamModule.js.map +0 -1
  151. package/build/esm/WebRecorder.web.js +0 -773
  152. package/build/esm/WebRecorder.web.js.map +0 -1
  153. package/build/esm/constants/platformLimitations.js +0 -90
  154. package/build/esm/constants/platformLimitations.js.map +0 -1
  155. package/build/esm/constants.js +0 -14
  156. package/build/esm/constants.js.map +0 -1
  157. package/build/esm/events.js +0 -21
  158. package/build/esm/events.js.map +0 -1
  159. package/build/esm/hooks/useAudioDevices.js +0 -176
  160. package/build/esm/hooks/useAudioDevices.js.map +0 -1
  161. package/build/esm/index.js +0 -20
  162. package/build/esm/index.js.map +0 -1
  163. package/build/esm/trimAudio.js +0 -69
  164. package/build/esm/trimAudio.js.map +0 -1
  165. package/build/esm/useAudioRecorder.js +0 -512
  166. package/build/esm/useAudioRecorder.js.map +0 -1
  167. package/build/esm/utils/BlobFix.js +0 -498
  168. package/build/esm/utils/BlobFix.js.map +0 -1
  169. package/build/esm/utils/audioProcessing.js +0 -133
  170. package/build/esm/utils/audioProcessing.js.map +0 -1
  171. package/build/esm/utils/cleanNativeOptions.js +0 -19
  172. package/build/esm/utils/cleanNativeOptions.js.map +0 -1
  173. package/build/esm/utils/concatenateBuffers.js +0 -21
  174. package/build/esm/utils/concatenateBuffers.js.map +0 -1
  175. package/build/esm/utils/convertPCMToFloat32.js +0 -120
  176. package/build/esm/utils/convertPCMToFloat32.js.map +0 -1
  177. package/build/esm/utils/crc32.js +0 -50
  178. package/build/esm/utils/crc32.js.map +0 -1
  179. package/build/esm/utils/encodingToBitDepth.js +0 -13
  180. package/build/esm/utils/encodingToBitDepth.js.map +0 -1
  181. package/build/esm/utils/getWavFileInfo.js +0 -92
  182. package/build/esm/utils/getWavFileInfo.js.map +0 -1
  183. package/build/esm/utils/writeWavHeader.js +0 -84
  184. package/build/esm/utils/writeWavHeader.js.map +0 -1
  185. package/build/esm/workers/InlineFeaturesExtractor.web.js +0 -856
  186. package/build/esm/workers/InlineFeaturesExtractor.web.js.map +0 -1
  187. package/build/esm/workers/inlineAudioWebWorker.web.js +0 -181
  188. package/build/esm/workers/inlineAudioWebWorker.web.js.map +0 -1
  189. package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts +0 -196
  190. package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts.map +0 -1
  191. package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts +0 -74
  192. package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts.map +0 -1
  193. package/build/types/AudioAnalysis/extractAudioData.d.ts +0 -3
  194. package/build/types/AudioAnalysis/extractAudioData.d.ts.map +0 -1
  195. package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts +0 -14
  196. package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts.map +0 -1
  197. package/build/types/AudioAnalysis/extractPreview.d.ts +0 -11
  198. package/build/types/AudioAnalysis/extractPreview.d.ts.map +0 -1
  199. package/build/types/AudioAnalysis/extractWaveform.d.ts +0 -8
  200. package/build/types/AudioAnalysis/extractWaveform.d.ts.map +0 -1
  201. package/build/types/AudioDeviceManager.d.ts +0 -187
  202. package/build/types/AudioDeviceManager.d.ts.map +0 -1
  203. package/build/types/AudioRecorder.provider.d.ts +0 -11
  204. package/build/types/AudioRecorder.provider.d.ts.map +0 -1
  205. package/build/types/ExpoAudioStream.native.d.ts +0 -3
  206. package/build/types/ExpoAudioStream.native.d.ts.map +0 -1
  207. package/build/types/ExpoAudioStream.types.d.ts +0 -738
  208. package/build/types/ExpoAudioStream.types.d.ts.map +0 -1
  209. package/build/types/ExpoAudioStream.web.d.ts +0 -96
  210. package/build/types/ExpoAudioStream.web.d.ts.map +0 -1
  211. package/build/types/ExpoAudioStreamModule.d.ts +0 -3
  212. package/build/types/ExpoAudioStreamModule.d.ts.map +0 -1
  213. package/build/types/WebRecorder.web.d.ts +0 -198
  214. package/build/types/WebRecorder.web.d.ts.map +0 -1
  215. package/build/types/constants/platformLimitations.d.ts +0 -40
  216. package/build/types/constants/platformLimitations.d.ts.map +0 -1
  217. package/build/types/constants.d.ts +0 -11
  218. package/build/types/constants.d.ts.map +0 -1
  219. package/build/types/events.d.ts +0 -26
  220. package/build/types/events.d.ts.map +0 -1
  221. package/build/types/hooks/useAudioDevices.d.ts +0 -15
  222. package/build/types/hooks/useAudioDevices.d.ts.map +0 -1
  223. package/build/types/index.d.ts +0 -18
  224. package/build/types/index.d.ts.map +0 -1
  225. package/build/types/trimAudio.d.ts +0 -25
  226. package/build/types/trimAudio.d.ts.map +0 -1
  227. package/build/types/useAudioRecorder.d.ts +0 -22
  228. package/build/types/useAudioRecorder.d.ts.map +0 -1
  229. package/build/types/utils/BlobFix.d.ts +0 -9
  230. package/build/types/utils/BlobFix.d.ts.map +0 -1
  231. package/build/types/utils/audioProcessing.d.ts +0 -24
  232. package/build/types/utils/audioProcessing.d.ts.map +0 -1
  233. package/build/types/utils/cleanNativeOptions.d.ts +0 -15
  234. package/build/types/utils/cleanNativeOptions.d.ts.map +0 -1
  235. package/build/types/utils/concatenateBuffers.d.ts +0 -8
  236. package/build/types/utils/concatenateBuffers.d.ts.map +0 -1
  237. package/build/types/utils/convertPCMToFloat32.d.ts +0 -13
  238. package/build/types/utils/convertPCMToFloat32.d.ts.map +0 -1
  239. package/build/types/utils/crc32.d.ts +0 -7
  240. package/build/types/utils/crc32.d.ts.map +0 -1
  241. package/build/types/utils/encodingToBitDepth.d.ts +0 -5
  242. package/build/types/utils/encodingToBitDepth.d.ts.map +0 -1
  243. package/build/types/utils/getWavFileInfo.d.ts +0 -26
  244. package/build/types/utils/getWavFileInfo.d.ts.map +0 -1
  245. package/build/types/utils/writeWavHeader.d.ts +0 -34
  246. package/build/types/utils/writeWavHeader.d.ts.map +0 -1
  247. package/build/types/workers/InlineFeaturesExtractor.web.d.ts +0 -2
  248. package/build/types/workers/InlineFeaturesExtractor.web.d.ts.map +0 -1
  249. package/build/types/workers/inlineAudioWebWorker.web.d.ts +0 -2
  250. package/build/types/workers/inlineAudioWebWorker.web.d.ts.map +0 -1
  251. package/expo-module.config.json +0 -10
  252. package/ios/AudioAnalysisData.swift +0 -74
  253. package/ios/AudioDeviceManager.swift +0 -670
  254. package/ios/AudioNotificationManager.swift +0 -154
  255. package/ios/AudioProcessingHelpers.swift +0 -743
  256. package/ios/AudioProcessor.swift +0 -1151
  257. package/ios/AudioStreamError.swift +0 -7
  258. package/ios/AudioStreamManager.swift +0 -2369
  259. package/ios/AudioStreamManagerDelegate.swift +0 -16
  260. package/ios/DataPoint.swift +0 -54
  261. package/ios/DecodingConfig.swift +0 -59
  262. package/ios/ExpoAudioStream.podspec +0 -33
  263. package/ios/ExpoAudioStreamModule.swift +0 -1019
  264. package/ios/ExpoAudioStudioTests/AudioFileHandlerTests.swift +0 -338
  265. package/ios/ExpoAudioStudioTests/AudioFormatUtilsTests.swift +0 -331
  266. package/ios/ExpoAudioStudioTests/AudioTestHelpers.swift +0 -130
  267. package/ios/ExpoAudioStudioTests/CompressedOnlyOutputTests.swift +0 -294
  268. package/ios/ExpoAudioStudioTests/EventEmissionIntervalTests.swift +0 -105
  269. package/ios/ExpoAudioStudioTests/Info.plist +0 -22
  270. package/ios/ExpoAudioStudioTests/README.md +0 -39
  271. package/ios/ExpoAudioStudioTests/SimpleAudioTest.swift +0 -98
  272. package/ios/ExpoAudioStudioTests/TestAudioGenerator.swift +0 -75
  273. package/ios/FFT.swift +0 -62
  274. package/ios/Features.swift +0 -95
  275. package/ios/ISSUE_IOS.md +0 -68
  276. package/ios/Logger.swift +0 -39
  277. package/ios/NotificationExtension.swift +0 -15
  278. package/ios/RecordingResult.swift +0 -22
  279. package/ios/RecordingSettings.swift +0 -308
  280. package/ios/WaveformExtractor.swift +0 -105
  281. package/ios/tests/README.md +0 -41
  282. package/ios/tests/integration/buffer_and_fallback_test.swift +0 -178
  283. package/ios/tests/integration/buffer_duration_test.swift +0 -185
  284. package/ios/tests/integration/compressed_only_output_test.swift +0 -271
  285. package/ios/tests/integration/output_control_test.swift +0 -322
  286. package/ios/tests/integration/run_integration_tests.sh +0 -37
  287. package/ios/tests/opus_support_test_macos.swift +0 -154
  288. package/ios/tests/standalone/audio_processing_test.swift +0 -144
  289. package/ios/tests/standalone/audio_recording_test.swift +0 -277
  290. package/ios/tests/standalone/audio_streaming_test.swift +0 -249
  291. package/ios/tests/standalone/standalone_test.swift +0 -144
  292. package/plugin/build/index.cjs +0 -194
  293. package/plugin/build/index.d.cts +0 -22
  294. package/plugin/build/index.js +0 -194
  295. package/plugin/src/index.ts +0 -285
  296. package/plugin/tsconfig.json +0 -10
  297. package/plugin/tsconfig.tsbuildinfo +0 -1
  298. package/src/AudioAnalysis/AudioAnalysis.types.ts +0 -224
  299. package/src/AudioAnalysis/extractAudioAnalysis.ts +0 -344
  300. package/src/AudioAnalysis/extractAudioData.ts +0 -17
  301. package/src/AudioAnalysis/extractMelSpectrogram.ts +0 -154
  302. package/src/AudioAnalysis/extractPreview.ts +0 -34
  303. package/src/AudioAnalysis/extractWaveform.ts +0 -22
  304. package/src/AudioDeviceManager.ts +0 -803
  305. package/src/AudioRecorder.provider.tsx +0 -57
  306. package/src/ExpoAudioStream.native.ts +0 -6
  307. package/src/ExpoAudioStream.types.ts +0 -874
  308. package/src/ExpoAudioStream.web.ts +0 -905
  309. package/src/ExpoAudioStreamModule.ts +0 -990
  310. package/src/WebRecorder.web.ts +0 -1005
  311. package/src/constants/platformLimitations.ts +0 -118
  312. package/src/constants.ts +0 -18
  313. package/src/events.ts +0 -60
  314. package/src/hooks/useAudioDevices.ts +0 -213
  315. package/src/index.ts +0 -54
  316. package/src/trimAudio.ts +0 -94
  317. package/src/types/crc-32.d.ts +0 -9
  318. package/src/useAudioRecorder.tsx +0 -766
  319. package/src/utils/BlobFix.ts +0 -561
  320. package/src/utils/audioProcessing.ts +0 -205
  321. package/src/utils/cleanNativeOptions.ts +0 -18
  322. package/src/utils/concatenateBuffers.ts +0 -24
  323. package/src/utils/convertPCMToFloat32.ts +0 -170
  324. package/src/utils/crc32.ts +0 -59
  325. package/src/utils/encodingToBitDepth.ts +0 -18
  326. package/src/utils/getWavFileInfo.ts +0 -132
  327. package/src/utils/writeWavHeader.ts +0 -115
  328. package/src/workers/InlineFeaturesExtractor.web.tsx +0 -855
  329. package/src/workers/inlineAudioWebWorker.web.tsx +0 -180
@@ -1,874 +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
- /**
60
- * Audio encoding types supported by the library.
61
- *
62
- * Platform support:
63
- * - `pcm_8bit`: Android only (iOS/Web will fallback to 16-bit)
64
- * - `pcm_16bit`: All platforms
65
- * - `pcm_32bit`: All platforms
66
- *
67
- * @see {@link https://github.com/deeeed/expo-audio-stream/blob/main/packages/expo-audio-studio/docs/PLATFORM_LIMITATIONS.md | Platform Limitations}
68
- */
69
- export type EncodingType = 'pcm_32bit' | 'pcm_16bit' | 'pcm_8bit'
70
-
71
- /**
72
- * Supported audio sample rates in Hz.
73
- * All platforms support these standard rates.
74
- */
75
- export type SampleRate = 16000 | 44100 | 48000
76
-
77
- /**
78
- * Audio bit depth (bits per sample).
79
- *
80
- * Platform support:
81
- * - `8`: Android only (iOS/Web will fallback to 16)
82
- * - `16`: All platforms (recommended for compatibility)
83
- * - `32`: All platforms
84
- *
85
- * @see {@link https://github.com/deeeed/expo-audio-stream/blob/main/packages/expo-audio-studio/docs/PLATFORM_LIMITATIONS.md | Platform Limitations}
86
- */
87
- export type BitDepth = 8 | 16 | 32
88
-
89
- /**
90
- * PCM format string representation.
91
- * @deprecated Use `EncodingType` directly
92
- */
93
- export type PCMFormat = `pcm_${BitDepth}bit`
94
-
95
- export type ConsoleLike = {
96
- /** Logs a message with optional arguments */
97
- log: (message: string, ...args: unknown[]) => void
98
- /** Logs a debug message with optional arguments */
99
- debug: (message: string, ...args: unknown[]) => void
100
- /** Logs an info message with optional arguments */
101
- info: (message: string, ...args: unknown[]) => void
102
- /** Logs a warning message with optional arguments */
103
- warn: (message: string, ...args: unknown[]) => void
104
- /** Logs an error message with optional arguments */
105
- error: (message: string, ...args: unknown[]) => void
106
- }
107
-
108
- export interface Chunk {
109
- /** Transcribed text content */
110
- text: string
111
- /** Start and end timestamp in seconds [start, end] where end can be null if ongoing */
112
- timestamp: [number, number | null]
113
- }
114
-
115
- export interface TranscriberData {
116
- /** Unique identifier for the transcription */
117
- id: string
118
- /** Indicates if the transcriber is currently processing */
119
- isBusy: boolean
120
- /** Complete transcribed text */
121
- text: string
122
- /** Start time of the transcription in milliseconds */
123
- startTime: number
124
- /** End time of the transcription in milliseconds */
125
- endTime: number
126
- /** Array of transcribed text chunks with timestamps */
127
- chunks: Chunk[]
128
- }
129
-
130
- export interface AudioRecording {
131
- /** URI to the recorded audio file */
132
- fileUri: string
133
- /** Filename of the recorded audio */
134
- filename: string
135
- /** Duration of the recording in milliseconds */
136
- durationMs: number
137
- /** Size of the recording in bytes */
138
- size: number
139
- /** MIME type of the recorded audio */
140
- mimeType: string
141
- /** Number of audio channels (1 for mono, 2 for stereo) */
142
- channels: number
143
- /** Bit depth of the audio (8, 16, or 32 bits) */
144
- bitDepth: BitDepth
145
- /** Sample rate of the audio in Hz */
146
- sampleRate: SampleRate
147
- /** Timestamp when the recording was created */
148
- createdAt?: number
149
- /** Array of transcription data if available */
150
- transcripts?: TranscriberData[]
151
- /** Analysis data for the recording if processing was enabled */
152
- analysisData?: AudioAnalysis
153
- /** Information about compression if enabled, including the URI to the compressed file */
154
- compression?: CompressionInfo & {
155
- /** URI to the compressed audio file */
156
- compressedFileUri: string
157
- }
158
- }
159
-
160
- export interface StartRecordingResult {
161
- /** URI to the file being recorded */
162
- fileUri: string
163
- /** MIME type of the recording */
164
- mimeType: string
165
- /** Number of audio channels (1 for mono, 2 for stereo) */
166
- channels?: number
167
- /** Bit depth of the audio (8, 16, or 32 bits) */
168
- bitDepth?: BitDepth
169
- /** Sample rate of the audio in Hz */
170
- sampleRate?: SampleRate
171
- /** Information about compression if enabled, including the URI to the compressed file */
172
- compression?: CompressionInfo & {
173
- /** URI to the compressed audio file */
174
- compressedFileUri: string
175
- }
176
- }
177
-
178
- export interface AudioSessionConfig {
179
- /**
180
- * Audio session category that defines the audio behavior
181
- * - 'Ambient': Audio continues with silent switch, mixes with other audio
182
- * - 'SoloAmbient': Audio continues with silent switch, interrupts other audio
183
- * - 'Playback': Audio continues in background, interrupts other audio
184
- * - 'Record': Optimized for recording, interrupts other audio
185
- * - 'PlayAndRecord': Allows simultaneous playback and recording
186
- * - 'MultiRoute': Routes audio to multiple outputs simultaneously
187
- */
188
- category?:
189
- | 'Ambient'
190
- | 'SoloAmbient'
191
- | 'Playback'
192
- | 'Record'
193
- | 'PlayAndRecord'
194
- | 'MultiRoute'
195
- /**
196
- * Audio session mode that defines the behavior for specific use cases
197
- * - 'Default': Standard audio behavior
198
- * - 'VoiceChat': Optimized for voice chat applications
199
- * - 'VideoChat': Optimized for video chat applications
200
- * - 'GameChat': Optimized for in-game chat
201
- * - 'VideoRecording': Optimized for video recording
202
- * - 'Measurement': Optimized for audio measurement
203
- * - 'MoviePlayback': Optimized for movie playback
204
- * - 'SpokenAudio': Optimized for spoken audio content
205
- */
206
- mode?:
207
- | 'Default'
208
- | 'VoiceChat'
209
- | 'VideoChat'
210
- | 'GameChat'
211
- | 'VideoRecording'
212
- | 'Measurement'
213
- | 'MoviePlayback'
214
- | 'SpokenAudio'
215
- /**
216
- * Options that modify the behavior of the audio session category
217
- * - 'MixWithOthers': Allows mixing with other active audio sessions
218
- * - 'DuckOthers': Reduces the volume of other audio sessions
219
- * - 'InterruptSpokenAudioAndMixWithOthers': Interrupts spoken audio and mixes with others
220
- * - 'AllowBluetooth': Allows audio routing to Bluetooth devices
221
- * - 'AllowBluetoothA2DP': Allows audio routing to Bluetooth A2DP devices
222
- * - 'AllowAirPlay': Allows audio routing to AirPlay devices
223
- * - 'DefaultToSpeaker': Routes audio to the speaker by default
224
- */
225
- categoryOptions?: (
226
- | 'MixWithOthers'
227
- | 'DuckOthers'
228
- | 'InterruptSpokenAudioAndMixWithOthers'
229
- | 'AllowBluetooth'
230
- | 'AllowBluetoothA2DP'
231
- | 'AllowAirPlay'
232
- | 'DefaultToSpeaker'
233
- )[]
234
- }
235
-
236
- export interface IOSConfig {
237
- /** Configuration for the iOS audio session */
238
- audioSession?: AudioSessionConfig
239
- }
240
-
241
- /** Android platform specific configuration options */
242
- export interface AndroidConfig {
243
- /**
244
- * Audio focus strategy for handling interruptions and background behavior
245
- *
246
- * - `'background'`: Continue recording when app loses focus (voice recorders, transcription apps)
247
- * - `'interactive'`: Pause when losing focus, resume when gaining (music apps, games)
248
- * - `'communication'`: Maintain priority for real-time communication (video calls, voice chat)
249
- * - `'none'`: No automatic audio focus management (custom handling)
250
- *
251
- * @default 'background' when keepAwake=true, 'interactive' otherwise
252
- */
253
- audioFocusStrategy?: 'background' | 'interactive' | 'communication' | 'none'
254
- }
255
-
256
- /** Web platform specific configuration options */
257
- export interface WebConfig {
258
- // Reserved for future web-specific options
259
- }
260
-
261
- // Add new type for interruption reasons
262
- export type RecordingInterruptionReason =
263
- /** Audio focus was lost to another app */
264
- | 'audioFocusLoss'
265
- /** Audio focus was regained */
266
- | 'audioFocusGain'
267
- /** Recording was interrupted by a phone call */
268
- | 'phoneCall'
269
- /** Phone call that interrupted recording has ended */
270
- | 'phoneCallEnded'
271
- /** Recording was stopped by the system or another app */
272
- | 'recordingStopped'
273
- /** Recording device was disconnected */
274
- | 'deviceDisconnected'
275
- /** Recording switched to default device after disconnection */
276
- | 'deviceFallback'
277
- /** A new audio device was connected */
278
- | 'deviceConnected'
279
- /** Device switching failed */
280
- | 'deviceSwitchFailed'
281
-
282
- // Add new interface for interruption events
283
- export interface RecordingInterruptionEvent {
284
- /** The reason for the recording interruption */
285
- reason: RecordingInterruptionReason
286
- /** Indicates whether the recording is paused due to the interruption */
287
- isPaused: boolean
288
- }
289
-
290
- export interface AudioDeviceCapabilities {
291
- /** Supported sample rates for the device */
292
- sampleRates: number[]
293
- /** Supported channel counts for the device */
294
- channelCounts: number[]
295
- /** Supported bit depths for the device */
296
- bitDepths: number[]
297
- /** Whether the device supports echo cancellation */
298
- hasEchoCancellation?: boolean
299
- /** Whether the device supports noise suppression */
300
- hasNoiseSuppression?: boolean
301
- /** Whether the device supports automatic gain control */
302
- hasAutomaticGainControl?: boolean
303
- }
304
-
305
- export interface AudioDevice {
306
- /** Unique identifier for the device */
307
- id: string
308
- /** Human-readable name of the device */
309
- name: string
310
- /** Device type (builtin_mic, bluetooth, etc.) */
311
- type: string
312
- /** Whether this is the system default device */
313
- isDefault: boolean
314
- /** Audio capabilities for the device */
315
- capabilities: AudioDeviceCapabilities
316
- /** Whether the device is currently available */
317
- isAvailable: boolean
318
- }
319
-
320
- /** Defines how recording should behave when a device becomes unavailable */
321
- export const DeviceDisconnectionBehavior = {
322
- /** Pause recording when device disconnects */
323
- PAUSE: 'pause',
324
- /** Switch to default device and continue recording */
325
- FALLBACK: 'fallback',
326
- } as const
327
-
328
- /** Type for DeviceDisconnectionBehavior values */
329
- export type DeviceDisconnectionBehaviorType =
330
- (typeof DeviceDisconnectionBehavior)[keyof typeof DeviceDisconnectionBehavior]
331
-
332
- /**
333
- * Configuration for audio output files during recording
334
- */
335
- export interface OutputConfig {
336
- /**
337
- * Configuration for the primary (uncompressed) output file
338
- */
339
- primary?: {
340
- /** Whether to create the primary output file (default: true) */
341
- enabled?: boolean
342
- /** Format for the primary output (currently only 'wav' is supported) */
343
- format?: 'wav'
344
- }
345
-
346
- /**
347
- * Configuration for the compressed output file
348
- */
349
- compressed?: {
350
- /** Whether to create a compressed output file (default: false) */
351
- enabled?: boolean
352
- /**
353
- * Format for compression
354
- * - 'aac': Advanced Audio Coding - supported on all platforms
355
- * - 'opus': Opus encoding - supported on Android and Web; on iOS will automatically fall back to AAC
356
- */
357
- format?: 'aac' | 'opus'
358
- /** Bitrate for compression in bits per second (default: 128000) */
359
- bitrate?: number
360
- /**
361
- * Prefer raw stream over container format (Android only)
362
- * - true: Use raw AAC stream (.aac files) like in v2.10.6
363
- * - false/undefined: Use M4A container (.m4a files) for better seeking support
364
- * Note: iOS always produces M4A containers and ignores this flag
365
- */
366
- preferRawStream?: boolean
367
- }
368
-
369
- // Future enhancement: Post-processing pipeline
370
- // postProcessing?: {
371
- // normalize?: boolean
372
- // trimSilence?: boolean
373
- // noiseReduction?: boolean
374
- // customProcessors?: AudioProcessor[]
375
- // }
376
- }
377
-
378
- export interface RecordingConfig {
379
- /** Sample rate for recording in Hz (16000, 44100, or 48000) */
380
- sampleRate?: SampleRate
381
-
382
- /** Number of audio channels (1 for mono, 2 for stereo) */
383
- channels?: 1 | 2
384
-
385
- /**
386
- * Encoding type for the recording.
387
- *
388
- * Platform limitations:
389
- * - `pcm_8bit`: Android only (iOS/Web will fallback to `pcm_16bit` with warning)
390
- * - `pcm_16bit`: All platforms (recommended for cross-platform compatibility)
391
- * - `pcm_32bit`: All platforms
392
- *
393
- * The library will automatically validate and adjust the encoding based on
394
- * platform capabilities. A warning will be logged if fallback is required.
395
- *
396
- * @default 'pcm_16bit'
397
- * @see {@link EncodingType}
398
- * @see {@link https://github.com/deeeed/expo-audio-stream/blob/main/packages/expo-audio-studio/docs/PLATFORM_LIMITATIONS.md | Platform Limitations}
399
- */
400
- encoding?: EncodingType
401
-
402
- /** Interval in milliseconds at which to emit recording data (minimum: 10ms) */
403
- interval?: number
404
-
405
- /** Interval in milliseconds at which to emit analysis data (minimum: 10ms) */
406
- intervalAnalysis?: number
407
-
408
- /** Keep the device awake while recording (default is false) */
409
- keepAwake?: boolean
410
-
411
- /** Show a notification during recording (default is false) */
412
- showNotification?: boolean
413
-
414
- /** Show waveform in the notification (Android only, when showNotification is true) */
415
- showWaveformInNotification?: boolean
416
-
417
- /** Configuration for the notification */
418
- notification?: NotificationConfig
419
-
420
- /** Enable audio processing (default is false) */
421
- enableProcessing?: boolean
422
-
423
- /** iOS-specific configuration */
424
- ios?: IOSConfig
425
-
426
- /** Android-specific configuration */
427
- android?: AndroidConfig
428
-
429
- /** Web-specific configuration options */
430
- web?: WebConfig
431
-
432
- /** Duration of each segment in milliseconds for analysis (default: 100) */
433
- segmentDurationMs?: number
434
-
435
- /** Feature options to extract during audio processing */
436
- features?: AudioFeaturesOptions
437
-
438
- /** Callback function to handle audio stream data */
439
- onAudioStream?: (_: AudioDataEvent) => Promise<void>
440
-
441
- /** Callback function to handle audio features extraction results */
442
- onAudioAnalysis?: (_: AudioAnalysisEvent) => Promise<void>
443
-
444
- /**
445
- * Configuration for audio output files
446
- *
447
- * Examples:
448
- * - Primary only (default): `{ primary: { enabled: true } }`
449
- * - Compressed only: `{ primary: { enabled: false }, compressed: { enabled: true, format: 'aac' } }`
450
- * - Both outputs: `{ compressed: { enabled: true } }`
451
- * - Streaming only: `{ primary: { enabled: false } }`
452
- */
453
- output?: OutputConfig
454
-
455
- /** Whether to automatically resume recording after an interruption (default is false) */
456
- autoResumeAfterInterruption?: boolean
457
-
458
- /** Optional callback to handle recording interruptions */
459
- onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void
460
-
461
- /** Optional directory path where output files will be saved */
462
- outputDirectory?: string // If not provided, uses default app directory
463
- /** Optional filename for the recording (uses UUID if not provided) */
464
- filename?: string // If not provided, uses UUID
465
-
466
- /** ID of the device to use for recording (if not specified, uses default) */
467
- deviceId?: string
468
-
469
- /** How to handle device disconnection during recording */
470
- deviceDisconnectionBehavior?: DeviceDisconnectionBehaviorType
471
-
472
- /**
473
- * Buffer duration in seconds. Controls the size of audio buffers
474
- * used during recording. Smaller values reduce latency but increase
475
- * CPU usage. Larger values improve efficiency but increase latency.
476
- *
477
- * Platform Notes:
478
- * - iOS/macOS: Minimum effective 0.1s, uses accumulation below
479
- * - Android: Respects all sizes within hardware limits
480
- * - Web: Fully configurable
481
- *
482
- * Default: undefined (uses platform default ~23ms at 44.1kHz)
483
- * Recommended: 0.01 - 0.5 seconds
484
- * Optimal iOS: >= 0.1 seconds
485
- */
486
- bufferDurationSeconds?: number
487
- }
488
-
489
- export interface NotificationConfig {
490
- /** Title of the notification */
491
- title?: string
492
-
493
- /** Main text content of the notification */
494
- text?: string
495
-
496
- /** Icon to be displayed in the notification (resource name or URI) */
497
- icon?: string
498
-
499
- /** Android-specific notification configuration */
500
- android?: {
501
- /** Unique identifier for the notification channel */
502
- channelId?: string
503
-
504
- /** User-visible name of the notification channel */
505
- channelName?: string
506
-
507
- /** User-visible description of the notification channel */
508
- channelDescription?: string
509
-
510
- /** Unique identifier for this notification */
511
- notificationId?: number
512
-
513
- /** List of actions that can be performed from the notification */
514
- actions?: NotificationAction[]
515
-
516
- /** Configuration for the waveform visualization in the notification */
517
- waveform?: WaveformConfig
518
-
519
- /** Color of the notification LED (if device supports it) */
520
- lightColor?: string
521
-
522
- /** Priority of the notification (affects how it's displayed) */
523
- priority?: 'min' | 'low' | 'default' | 'high' | 'max'
524
-
525
- /** Accent color for the notification (used for the app icon and buttons) */
526
- accentColor?: string
527
-
528
- /** Whether to show pause/resume actions in the notification (default: true) */
529
- showPauseResumeActions?: boolean
530
- }
531
-
532
- /** iOS-specific notification configuration */
533
- ios?: {
534
- /** Identifier for the notification category (used for grouping similar notifications) */
535
- categoryIdentifier?: string
536
- }
537
- }
538
-
539
- export interface NotificationAction {
540
- /** Display title for the action */
541
- title: string
542
-
543
- /** Unique identifier for the action */
544
- identifier: string
545
-
546
- /** Icon to be displayed for the action (Android only) */
547
- icon?: string
548
- }
549
-
550
- export interface WaveformConfig {
551
- /** The color of the waveform (e.g., "#FFFFFF" for white) */
552
- color?: string // The color of the waveform (e.g., "#FFFFFF" for white)
553
- /** Opacity of the waveform (0.0 - 1.0) */
554
- opacity?: number // Opacity of the waveform (0.0 - 1.0)
555
- /** Width of the waveform line (default: 1.5) */
556
- strokeWidth?: number // Width of the waveform line (default: 1.5)
557
- /** Drawing style: "stroke" for outline, "fill" for solid */
558
- style?: 'stroke' | 'fill' // Drawing style: "stroke" for outline, "fill" for solid
559
- /** Whether to mirror the waveform (symmetrical display) */
560
- mirror?: boolean // Whether to mirror the waveform (symmetrical display)
561
- /** Height of the waveform view in dp (default: 64) */
562
- height?: number // Height of the waveform view in dp (default: 64)
563
- }
564
-
565
- export interface ExtractAudioDataOptions {
566
- /** URI of the audio file to extract data from */
567
- fileUri: string
568
- /** Start time in milliseconds (for time-based range) */
569
- startTimeMs?: number
570
- /** End time in milliseconds (for time-based range) */
571
- endTimeMs?: number
572
- /** Start position in bytes (for byte-based range) */
573
- position?: number
574
- /** Length in bytes to extract (for byte-based range) */
575
- length?: number
576
- /** Include normalized audio data in [-1, 1] range */
577
- includeNormalizedData?: boolean
578
- /** Include base64 encoded string representation of the audio data */
579
- includeBase64Data?: boolean
580
- /** Include WAV header in the PCM data (makes it a valid WAV file) */
581
- includeWavHeader?: boolean
582
- /** Logger for debugging - can pass console directly. */
583
- logger?: ConsoleLike
584
- /** Compute the checksum of the PCM data */
585
- computeChecksum?: boolean
586
- /** Target config for the normalized audio (Android and Web) */
587
- decodingOptions?: DecodingConfig
588
- }
589
-
590
- export interface ExtractedAudioData {
591
- /** Raw PCM audio data */
592
- pcmData: Uint8Array
593
- /** Normalized audio data in [-1, 1] range (when includeNormalizedData is true) */
594
- normalizedData?: Float32Array
595
- /** Base64 encoded string representation of the audio data (when includeBase64Data is true) */
596
- base64Data?: string
597
- /** Sample rate in Hz (e.g., 44100, 48000) */
598
- sampleRate: number
599
- /** Number of audio channels (1 for mono, 2 for stereo) */
600
- channels: number
601
- /** Bits per sample (8, 16, or 32) */
602
- bitDepth: BitDepth
603
- /** Duration of the audio in milliseconds */
604
- durationMs: number
605
- /** PCM format identifier (e.g., "pcm_16bit") */
606
- format: PCMFormat
607
- /** Total number of audio samples per channel */
608
- samples: number
609
- /** Whether the pcmData includes a WAV header */
610
- hasWavHeader?: boolean
611
- /** CRC32 Checksum of PCM data */
612
- checksum?: number
613
- }
614
-
615
- export interface UseAudioRecorderState {
616
- /**
617
- * Prepares recording with the specified configuration without starting it.
618
- *
619
- * This method eliminates the latency between calling startRecording and the actual recording beginning.
620
- * It pre-initializes all audio resources, requests permissions, and sets up audio sessions in advance,
621
- * allowing for true zero-latency recording start when startRecording is called later.
622
- *
623
- * Technical benefits:
624
- * - Eliminates audio pipeline initialization delay (50-300ms depending on platform)
625
- * - Pre-allocates audio buffers to avoid memory allocation during recording start
626
- * - Initializes audio hardware in advance (particularly important on iOS)
627
- * - Requests and verifies permissions before the critical recording moment
628
- *
629
- * Use this method when:
630
- * - You need zero-latency recording start (e.g., voice commands, musical applications)
631
- * - You're building time-sensitive applications where missing initial audio would be problematic
632
- * - You want to prepare resources during app initialization, screen loading, or preceding user interaction
633
- * - You need to ensure recording starts reliably and instantly on all platforms
634
- *
635
- * @param config - The recording configuration, identical to what you would pass to startRecording
636
- * @returns A promise that resolves when preparation is complete
637
- *
638
- * @example
639
- * // Prepare during component mounting
640
- * useEffect(() => {
641
- * prepareRecording({
642
- * sampleRate: 44100,
643
- * channels: 1,
644
- * encoding: 'pcm_16bit',
645
- * });
646
- * }, []);
647
- *
648
- * // Later when user taps record button, it starts with zero latency
649
- * const handleRecordPress = () => startRecording({
650
- * sampleRate: 44100,
651
- * channels: 1,
652
- * encoding: 'pcm_16bit',
653
- * });
654
- */
655
- prepareRecording: (_: RecordingConfig) => Promise<void>
656
- /** Starts recording with the specified configuration */
657
- startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>
658
- /** Stops the current recording and returns the recording data */
659
- stopRecording: () => Promise<AudioRecording | null>
660
- /** Pauses the current recording */
661
- pauseRecording: () => Promise<void>
662
- /** Resumes a paused recording */
663
- resumeRecording: () => Promise<void>
664
- /** Indicates whether recording is currently active */
665
- isRecording: boolean
666
- /** Indicates whether recording is in a paused state */
667
- isPaused: boolean
668
- /** Duration of the current recording in milliseconds */
669
- durationMs: number // Duration of the recording
670
- /** Size of the recorded audio in bytes */
671
- size: number // Size in bytes of the recorded audio
672
- /** Information about compression if enabled */
673
- compression?: CompressionInfo
674
- /** Analysis data for the recording if processing was enabled */
675
- analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag
676
- /** Optional callback to handle recording interruptions */
677
- onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void
678
- }
679
-
680
- /**
681
- * Represents an event emitted during the trimming process to report progress.
682
- */
683
- export interface TrimProgressEvent {
684
- /**
685
- * The percentage of the trimming process that has been completed, ranging from 0 to 100.
686
- */
687
- progress: number
688
-
689
- /**
690
- * The number of bytes that have been processed so far. This is optional and may not be provided in all implementations.
691
- */
692
- bytesProcessed?: number
693
-
694
- /**
695
- * The total number of bytes to process. This is optional and may not be provided in all implementations.
696
- */
697
- totalBytes?: number
698
- }
699
-
700
- /**
701
- * Defines a time range in milliseconds for trimming operations.
702
- */
703
- export interface TimeRange {
704
- /**
705
- * The start time of the range in milliseconds.
706
- */
707
- startTimeMs: number
708
-
709
- /**
710
- * The end time of the range in milliseconds.
711
- */
712
- endTimeMs: number
713
- }
714
-
715
- /**
716
- * Options for configuring the audio trimming operation.
717
- */
718
- export interface TrimAudioOptions {
719
- /**
720
- * The URI of the audio file to trim.
721
- */
722
- fileUri: string
723
-
724
- /**
725
- * The mode of trimming to apply.
726
- * - `'single'`: Trims the audio to a single range defined by `startTimeMs` and `endTimeMs`.
727
- * - `'keep'`: Keeps the specified `ranges` and removes all other portions of the audio.
728
- * - `'remove'`: Removes the specified `ranges` and keeps the remaining portions of the audio.
729
- * @default 'single'
730
- */
731
- mode?: 'single' | 'keep' | 'remove'
732
-
733
- /**
734
- * An array of time ranges to keep or remove, depending on the `mode`.
735
- * - Required for `'keep'` and `'remove'` modes.
736
- * - Ignored when `mode` is `'single'`.
737
- */
738
- ranges?: TimeRange[]
739
-
740
- /**
741
- * The start time in milliseconds for the `'single'` mode.
742
- * - If not provided, trimming starts from the beginning of the audio (0 ms).
743
- */
744
- startTimeMs?: number
745
-
746
- /**
747
- * The end time in milliseconds for the `'single'` mode.
748
- * - If not provided, trimming extends to the end of the audio.
749
- */
750
- endTimeMs?: number
751
-
752
- /**
753
- * The name of the output file. If not provided, a default name will be generated.
754
- */
755
- outputFileName?: string
756
-
757
- /**
758
- * Configuration for the output audio format.
759
- */
760
- outputFormat?: {
761
- /**
762
- * The format of the output audio file.
763
- * - `'wav'`: Waveform Audio File Format (uncompressed).
764
- * - `'aac'`: Advanced Audio Coding (compressed). Not supported on web platforms.
765
- * - `'opus'`: Opus Interactive Audio Codec (compressed).
766
- */
767
- format: 'wav' | 'aac' | 'opus'
768
-
769
- /**
770
- * The sample rate of the output audio in Hertz (Hz).
771
- * - If not provided, the input audio's sample rate is used.
772
- */
773
- sampleRate?: number
774
-
775
- /**
776
- * The number of channels in the output audio (e.g., 1 for mono, 2 for stereo).
777
- * - If not provided, the input audio's channel count is used.
778
- */
779
- channels?: number
780
-
781
- /**
782
- * The bit depth of the output audio, applicable to PCM formats like `'wav'`.
783
- * - If not provided, the input audio's bit depth is used.
784
- */
785
- bitDepth?: number
786
-
787
- /**
788
- * The bitrate of the output audio in bits per second, applicable to compressed formats like `'aac'`.
789
- * - If not provided, a default bitrate is used based on the format.
790
- */
791
- bitrate?: number
792
- }
793
-
794
- /**
795
- * Options for decoding the input audio file.
796
- * - See `DecodingConfig` for details.
797
- */
798
- decodingOptions?: DecodingConfig
799
- }
800
-
801
- /**
802
- * Result of the audio trimming operation.
803
- */
804
- export interface TrimAudioResult {
805
- /**
806
- * The URI of the trimmed audio file.
807
- */
808
- uri: string
809
-
810
- /**
811
- * The filename of the trimmed audio file.
812
- */
813
- filename: string
814
-
815
- /**
816
- * The duration of the trimmed audio in milliseconds.
817
- */
818
- durationMs: number
819
-
820
- /**
821
- * The size of the trimmed audio file in bytes.
822
- */
823
- size: number
824
-
825
- /**
826
- * The sample rate of the trimmed audio in Hertz (Hz).
827
- */
828
- sampleRate: number
829
-
830
- /**
831
- * The number of channels in the trimmed audio (e.g., 1 for mono, 2 for stereo).
832
- */
833
- channels: number
834
-
835
- /**
836
- * The bit depth of the trimmed audio, applicable to PCM formats like `'wav'`.
837
- */
838
- bitDepth: number
839
-
840
- /**
841
- * The MIME type of the trimmed audio file (e.g., `'audio/wav'`, `'audio/mpeg'`).
842
- */
843
- mimeType: string
844
-
845
- /**
846
- * Information about compression if the output format is compressed.
847
- */
848
- compression?: {
849
- /**
850
- * The format of the compression (e.g., `'aac'`, `'mp3'`, `'opus'`).
851
- */
852
- format: string
853
-
854
- /**
855
- * The bitrate of the compressed audio in bits per second.
856
- */
857
- bitrate: number
858
-
859
- /**
860
- * The size of the compressed audio file in bytes.
861
- */
862
- size: number
863
- }
864
-
865
- /**
866
- * Information about the processing time.
867
- */
868
- processingInfo?: {
869
- /**
870
- * The time it took to process the audio in milliseconds.
871
- */
872
- durationMs: number
873
- }
874
- }