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