@siteed/expo-audio-studio 2.18.6 → 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 (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 +6 -135
  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,344 +0,0 @@
1
- // packages/expo-audio-stream/src/AudioAnalysis/extractAudioAnalysis.ts
2
- /**
3
- * This module provides functions for extracting and analyzing audio data.
4
- * - `extractAudioAnalysis`: For detailed analysis with customizable ranges and decoding options.
5
- * - `extractWavAudioAnalysis`: For analyzing WAV files without decoding, preserving original PCM values.
6
- * - `extractPreview`: For generating quick previews of audio waveforms, optimized for UI rendering.
7
- */
8
- import { ConsoleLike } from '../ExpoAudioStream.types'
9
- import ExpoAudioStreamModule from '../ExpoAudioStreamModule'
10
- import { isWeb } from '../constants'
11
- import {
12
- AudioAnalysis,
13
- AudioFeaturesOptions,
14
- DataPoint,
15
- DecodingConfig,
16
- } from './AudioAnalysis.types'
17
- import { processAudioBuffer } from '../utils/audioProcessing'
18
- import { cleanNativeOptions } from '../utils/cleanNativeOptions'
19
- import { convertPCMToFloat32 } from '../utils/convertPCMToFloat32'
20
- import crc32 from '../utils/crc32'
21
- import { getWavFileInfo, WavFileInfo } from '../utils/getWavFileInfo'
22
- import { InlineFeaturesExtractor } from '../workers/InlineFeaturesExtractor.web'
23
-
24
- function calculateCRC32ForDataPoint(data: Float32Array): number {
25
- // Convert float array to byte array for CRC32
26
- const byteArray = new Uint8Array(data.length * 4)
27
- const dataView = new DataView(byteArray.buffer)
28
-
29
- for (let i = 0; i < data.length; i++) {
30
- dataView.setFloat32(i * 4, data[i], true)
31
- }
32
-
33
- return crc32.buf(byteArray)
34
- }
35
-
36
- export interface ExtractWavAudioAnalysisProps {
37
- fileUri?: string // should provide either fileUri or arrayBuffer
38
- wavMetadata?: WavFileInfo
39
- arrayBuffer?: ArrayBuffer
40
- bitDepth?: number
41
- durationMs?: number
42
- sampleRate?: number
43
- numberOfChannels?: number
44
- position?: number // Optional number of bytes to skip. Default is 0
45
- length?: number // Optional number of bytes to read.
46
- segmentDurationMs?: number // Optional number of points per second. Use to reduce the number of points and compute the number of datapoints to return.
47
- features?: AudioFeaturesOptions
48
- featuresExtratorUrl?: string
49
- logger?: ConsoleLike
50
- decodingOptions?: DecodingConfig
51
- }
52
-
53
- // Define base options interface with common properties
54
- interface BaseExtractOptions {
55
- fileUri?: string
56
- arrayBuffer?: ArrayBuffer
57
- /**
58
- * Duration of each analysis segment in milliseconds. Defaults to 100ms if not specified.
59
- */
60
- segmentDurationMs?: number
61
- features?: AudioFeaturesOptions
62
- decodingOptions?: DecodingConfig
63
- logger?: ConsoleLike
64
- }
65
-
66
- // Time-based range options
67
- interface TimeRangeOptions extends BaseExtractOptions {
68
- startTimeMs?: number
69
- endTimeMs?: number
70
- position?: never
71
- length?: never
72
- }
73
-
74
- // Byte-based range options
75
- interface ByteRangeOptions extends BaseExtractOptions {
76
- position?: number
77
- length?: number
78
- startTimeMs?: never
79
- endTimeMs?: never
80
- }
81
-
82
- /**
83
- * Options for extracting audio analysis.
84
- * - For time-based analysis, provide `startTimeMs` and `endTimeMs`.
85
- * - For byte-based analysis, provide `position` and `length`.
86
- * - Do not mix time and byte ranges.
87
- */
88
- export type ExtractAudioAnalysisProps = TimeRangeOptions | ByteRangeOptions
89
-
90
- /**
91
- * Extracts detailed audio analysis from the specified audio file or buffer.
92
- * Supports either time-based or byte-based ranges for flexibility in analysis.
93
- *
94
- * @param props - The options for extraction, including file URI, ranges, and decoding settings.
95
- * @returns A promise that resolves to the audio analysis data.
96
- * @throws {Error} If both time and byte ranges are provided or if required parameters are missing.
97
- */
98
- export async function extractAudioAnalysis(
99
- props: ExtractAudioAnalysisProps
100
- ): Promise<AudioAnalysis> {
101
- const {
102
- fileUri,
103
- arrayBuffer,
104
- decodingOptions,
105
- logger,
106
- segmentDurationMs = 100,
107
- features,
108
- } = props
109
-
110
- if (isWeb) {
111
- try {
112
- // Create AudioContext here
113
- const audioContext = new (window.AudioContext ||
114
- (window as any).webkitAudioContext)({
115
- sampleRate: decodingOptions?.targetSampleRate ?? 16000,
116
- })
117
-
118
- try {
119
- const processedBuffer = await processAudioBuffer({
120
- arrayBuffer,
121
- fileUri,
122
- targetSampleRate:
123
- decodingOptions?.targetSampleRate ?? 16000,
124
- targetChannels: decodingOptions?.targetChannels ?? 1,
125
- normalizeAudio: decodingOptions?.normalizeAudio ?? false,
126
- startTimeMs:
127
- 'startTimeMs' in props ? props.startTimeMs : undefined,
128
- endTimeMs:
129
- 'endTimeMs' in props ? props.endTimeMs : undefined,
130
- position: 'position' in props ? props.position : undefined,
131
- length: 'length' in props ? props.length : undefined,
132
- audioContext, // Pass the context we created
133
- logger,
134
- })
135
-
136
- const channelData = processedBuffer.buffer.getChannelData(0)
137
-
138
- // Create and initialize the worker
139
- const blob = new Blob([InlineFeaturesExtractor], {
140
- type: 'application/javascript',
141
- })
142
- const workerUrl = URL.createObjectURL(blob)
143
- const worker = new Worker(workerUrl)
144
-
145
- return new Promise((resolve, reject) => {
146
- worker.onmessage = (event) => {
147
- if (event.data.error) {
148
- reject(new Error(event.data.error))
149
- return
150
- }
151
-
152
- const result: AudioAnalysis = event.data.result
153
- // Calculate CRC32 after worker completes if requested
154
- if (features?.crc32) {
155
- const samplesPerSegment = Math.floor(
156
- (processedBuffer.sampleRate *
157
- segmentDurationMs) /
158
- 1000
159
- )
160
-
161
- result.dataPoints = result.dataPoints.map(
162
- (point: DataPoint, index: number) => {
163
- const startSample =
164
- index * samplesPerSegment
165
- const segmentData = channelData.slice(
166
- startSample,
167
- startSample + samplesPerSegment
168
- )
169
-
170
- return {
171
- ...point,
172
- features: {
173
- ...point.features,
174
- crc32: calculateCRC32ForDataPoint(
175
- segmentData
176
- ),
177
- },
178
- }
179
- }
180
- )
181
- }
182
-
183
- URL.revokeObjectURL(workerUrl)
184
- worker.terminate()
185
- resolve(result)
186
- }
187
-
188
- worker.onerror = (error) => {
189
- URL.revokeObjectURL(workerUrl)
190
- worker.terminate()
191
- reject(error)
192
- }
193
-
194
- worker.postMessage({
195
- channelData,
196
- sampleRate: processedBuffer.sampleRate,
197
- segmentDurationMs,
198
- bitDepth: decodingOptions?.targetBitDepth ?? 32,
199
- numberOfChannels: processedBuffer.channels,
200
- fullAudioDurationMs: processedBuffer.durationMs,
201
- // enableLogging: !!logger,
202
- features,
203
- })
204
- })
205
- } finally {
206
- await audioContext.close()
207
- }
208
- } catch (error) {
209
- logger?.error('Failed to process audio:', error)
210
- throw error
211
- }
212
- } else {
213
- // Strip non-serializable fields — logger and arrayBuffer cause
214
- // "Cannot convert '[object Object]' to a Kotlin type" on Android.
215
- const {
216
- logger: _logger,
217
- arrayBuffer: _arrayBuffer,
218
- ...nativeOptions
219
- } = props
220
- // Clean undefined values to avoid Android Kotlin bridge crash
221
- return await ExpoAudioStreamModule.extractAudioAnalysis(
222
- cleanNativeOptions(nativeOptions)
223
- )
224
- }
225
- }
226
-
227
- /**
228
- * Analyzes WAV files without decoding, preserving original PCM values.
229
- * Use this function when you need to ensure the analysis matches other software by avoiding any transformations.
230
- *
231
- * @param props - The options for WAV analysis, including file URI and range.
232
- * @returns A promise that resolves to the audio analysis data.
233
- */
234
- export const extractRawWavAnalysis = async ({
235
- fileUri,
236
- segmentDurationMs = 100, // Default to 100ms
237
- arrayBuffer,
238
- bitDepth,
239
- durationMs,
240
- sampleRate,
241
- numberOfChannels,
242
- features,
243
- logger,
244
- position = 0,
245
- length,
246
- }: ExtractWavAudioAnalysisProps): Promise<AudioAnalysis> => {
247
- if (isWeb) {
248
- if (!arrayBuffer && !fileUri) {
249
- throw new Error('Either arrayBuffer or fileUri must be provided')
250
- }
251
-
252
- if (!arrayBuffer) {
253
- logger?.log(`fetching fileUri`, fileUri)
254
- const response = await fetch(fileUri!)
255
-
256
- if (!response.ok) {
257
- throw new Error(
258
- `Failed to fetch fileUri: ${response.statusText}`
259
- )
260
- }
261
-
262
- arrayBuffer = await response.arrayBuffer()
263
- logger?.log(`fetched fileUri`, arrayBuffer.byteLength, arrayBuffer)
264
- }
265
-
266
- // Create a new copy of the ArrayBuffer to avoid detachment issues
267
- const bufferCopy = arrayBuffer.slice(0)
268
- logger?.log(
269
- `extractAudioAnalysis bitDepth=${bitDepth} len=${bufferCopy.byteLength}`,
270
- bufferCopy.slice(0, 100)
271
- )
272
-
273
- let actualBitDepth = bitDepth
274
- if (!actualBitDepth) {
275
- logger?.log(
276
- `extractAudioAnalysis bitDepth not provided -- getting wav file info`
277
- )
278
- const fileInfo = await getWavFileInfo(bufferCopy)
279
- actualBitDepth = fileInfo.bitDepth
280
- }
281
- logger?.log(`extractAudioAnalysis actualBitDepth=${actualBitDepth}`)
282
-
283
- const {
284
- pcmValues: channelData,
285
- min,
286
- max,
287
- } = await convertPCMToFloat32({
288
- buffer: arrayBuffer,
289
- bitDepth: actualBitDepth,
290
- })
291
- logger?.log(
292
- `extractAudioAnalysis convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`
293
- )
294
-
295
- // Apply position and length constraints to channelData if specified
296
- const startIndex = position
297
- const endIndex = length ? startIndex + length : channelData.length
298
- const constrainedChannelData = channelData.slice(startIndex, endIndex)
299
-
300
- return new Promise((resolve, reject) => {
301
- const blob = new Blob([InlineFeaturesExtractor], {
302
- type: 'application/javascript',
303
- })
304
- const url = URL.createObjectURL(blob)
305
- const worker = new Worker(url)
306
-
307
- worker.onmessage = (event) => {
308
- resolve(event.data.result)
309
- }
310
-
311
- worker.onerror = (error) => {
312
- reject(error)
313
- }
314
-
315
- worker.postMessage({
316
- command: 'process',
317
- channelData: constrainedChannelData,
318
- sampleRate,
319
- segmentDurationMs,
320
- logger,
321
- bitDepth,
322
- fullAudioDurationMs: durationMs,
323
- numberOfChannels,
324
- })
325
- })
326
- } else {
327
- if (!fileUri) {
328
- throw new Error('fileUri is required')
329
- }
330
- logger?.log(`extractAudioAnalysis`, {
331
- fileUri,
332
- segmentDurationMs,
333
- })
334
- const res = await ExpoAudioStreamModule.extractAudioAnalysis({
335
- fileUri,
336
- segmentDurationMs,
337
- features,
338
- position,
339
- length,
340
- })
341
- logger?.log(`extractAudioAnalysis`, res)
342
- return res
343
- }
344
- }
@@ -1,17 +0,0 @@
1
- import { ExtractAudioDataOptions } from '../ExpoAudioStream.types'
2
- import ExpoAudioStreamModule from '../ExpoAudioStreamModule'
3
- import { isWeb } from '../constants'
4
- import { cleanNativeOptions } from '../utils/cleanNativeOptions'
5
-
6
- export const extractAudioData = async (props: ExtractAudioDataOptions) => {
7
- if (isWeb) {
8
- // Web implementation handles logger natively in ExpoAudioStreamModule.ts
9
- return await ExpoAudioStreamModule.extractAudioData(props)
10
- }
11
- // Native: only pass serializable fields — logger causes crash on Android
12
- const { logger: _logger, ...nativeOptions } = props
13
- // Clean undefined values to avoid Android Kotlin bridge crash
14
- return await ExpoAudioStreamModule.extractAudioData(
15
- cleanNativeOptions(nativeOptions)
16
- )
17
- }
@@ -1,154 +0,0 @@
1
- /**
2
- * @experimental This feature is experimental and currently only available on Android.
3
- * The API may change in future versions. The web implementation is a placeholder.
4
- */
5
-
6
- import { ExpoAudioStreamModule } from '..'
7
- import { isWeb } from '../constants'
8
- import {
9
- ExtractMelSpectrogramOptions,
10
- MelSpectrogram,
11
- } from './AudioAnalysis.types'
12
- import {
13
- processAudioBuffer,
14
- ProcessedAudioData,
15
- } from '../utils/audioProcessing'
16
- import { cleanNativeOptions } from '../utils/cleanNativeOptions'
17
-
18
- /**
19
- * Extracts a mel spectrogram from audio data
20
- *
21
- * @experimental This feature is experimental and currently only available on Android.
22
- * The iOS implementation will throw an "UNSUPPORTED_PLATFORM" error.
23
- * The web implementation is a placeholder that returns dummy data.
24
- */
25
- export async function extractMelSpectrogram(
26
- options: ExtractMelSpectrogramOptions
27
- ): Promise<MelSpectrogram> {
28
- const {
29
- fileUri,
30
- arrayBuffer,
31
- windowSizeMs,
32
- hopLengthMs,
33
- nMels,
34
- fMin = 0,
35
- fMax,
36
- windowType = 'hann',
37
- normalize = false,
38
- logScale = true,
39
- decodingOptions,
40
- startTimeMs,
41
- endTimeMs,
42
- logger,
43
- } = options
44
-
45
- if (isWeb) {
46
- // Create audio context
47
- const audioContext = new (window.AudioContext ||
48
- (window as any).webkitAudioContext)()
49
-
50
- try {
51
- // Process audio data using the existing utility
52
- const processedAudio: ProcessedAudioData = await processAudioBuffer(
53
- {
54
- arrayBuffer,
55
- fileUri,
56
- targetSampleRate:
57
- decodingOptions?.targetSampleRate || 16000,
58
- targetChannels: decodingOptions?.targetChannels || 1,
59
- normalizeAudio: decodingOptions?.normalizeAudio ?? false,
60
- startTimeMs,
61
- endTimeMs,
62
- audioContext,
63
- logger: options.logger,
64
- }
65
- )
66
-
67
- // Calculate window and hop size in samples
68
- const sampleRate = processedAudio.sampleRate
69
- const windowSize = Math.floor((windowSizeMs * sampleRate) / 1000)
70
- const hopLength = Math.floor((hopLengthMs * sampleRate) / 1000)
71
- const maxFreq = fMax || sampleRate / 2
72
-
73
- // Extract the mel spectrogram from the processed audio
74
- const spectrogram = computeMelSpectrogram(
75
- processedAudio.channelData,
76
- sampleRate,
77
- nMels,
78
- windowSize,
79
- hopLength,
80
- fMin,
81
- maxFreq,
82
- windowType,
83
- normalize,
84
- logScale
85
- )
86
-
87
- const timeSteps = spectrogram.length
88
-
89
- return {
90
- spectrogram,
91
- sampleRate,
92
- nMels,
93
- timeSteps,
94
- durationMs: processedAudio.durationMs,
95
- }
96
- } catch (error) {
97
- logger?.error('Error extracting mel spectrogram:', error)
98
- throw error
99
- } finally {
100
- // Close the audio context
101
- await audioContext.close()
102
- }
103
- }
104
- // Strip logger/arrayBuffer (non-serializable) then clean undefined values
105
- // to avoid Android "Cannot convert '[object Object]' to Kotlin type" crash
106
- const {
107
- logger: _logger,
108
- arrayBuffer: _arrayBuffer,
109
- ...nativeOptions
110
- } = options
111
- return ExpoAudioStreamModule.extractMelSpectrogram(
112
- cleanNativeOptions(nativeOptions)
113
- )
114
- }
115
-
116
- /**
117
- * Computes a mel spectrogram from audio data
118
- *
119
- * @experimental This is a placeholder implementation that returns dummy data.
120
- * The actual implementation will be added in a future version.
121
- */
122
- function computeMelSpectrogram(
123
- audioData: Float32Array,
124
- sampleRate: number,
125
- nMels: number,
126
- windowSize: number,
127
- hopLength: number,
128
- fMin: number,
129
- fMax: number,
130
- windowType: 'hann' | 'hamming',
131
- normalize: boolean,
132
- logScale: boolean
133
- ): number[][] {
134
- // Placeholder for the actual implementation
135
- // This would include:
136
- // 1. Windowing the audio data using the specified window type
137
- // 2. Computing the STFT (Short-Time Fourier Transform)
138
- // 3. Converting to power spectrogram
139
- // 4. Applying mel filterbanks
140
- // 5. Taking the logarithm if logScale is true
141
- // 6. Normalizing if normalize is true
142
-
143
- // For now, return a dummy implementation
144
- const numFrames =
145
- Math.floor((audioData.length - windowSize) / hopLength) + 1
146
- const spectrogram: number[][] = []
147
-
148
- // Create dummy mel spectrogram data
149
- for (let i = 0; i < numFrames; i++) {
150
- spectrogram.push(Array(nMels).fill(0))
151
- }
152
-
153
- return spectrogram
154
- }
@@ -1,34 +0,0 @@
1
- import { PreviewOptions, AudioAnalysis } from './AudioAnalysis.types'
2
- import { extractAudioAnalysis } from './extractAudioAnalysis'
3
-
4
- /**
5
- * Generates a simplified preview of the audio waveform for quick visualization.
6
- * Ideal for UI rendering with a specified number of points.
7
- *
8
- * @param options - The options for the preview, including file URI and time range.
9
- * @returns A promise that resolves to the audio preview data.
10
- */
11
- export async function extractPreview({
12
- fileUri,
13
- numberOfPoints = 100,
14
- startTimeMs = 0,
15
- endTimeMs = 30000, // First 30 seconds
16
- decodingOptions,
17
- logger,
18
- }: PreviewOptions): Promise<AudioAnalysis> {
19
- const durationMs = endTimeMs - startTimeMs
20
- const segmentDurationMs = Math.floor(durationMs / numberOfPoints)
21
-
22
- // Call extractAudioAnalysis with calculated parameters
23
- const analysis = await extractAudioAnalysis({
24
- fileUri,
25
- startTimeMs,
26
- endTimeMs,
27
- logger,
28
- segmentDurationMs,
29
- decodingOptions,
30
- })
31
-
32
- // Transform the result into AudioPreview format
33
- return analysis
34
- }
@@ -1,22 +0,0 @@
1
- import ExpoAudioStreamModule from '../ExpoAudioStreamModule'
2
-
3
- export interface ExtractWaveformProps {
4
- fileUri: string
5
- numberOfSamples: number
6
- offset?: number
7
- length?: number
8
- }
9
- export const extractWaveform = async ({
10
- fileUri,
11
- numberOfSamples,
12
- offset = 0,
13
- length,
14
- }: ExtractWaveformProps): Promise<unknown> => {
15
- const res = await ExpoAudioStreamModule.extractAudioAnalysis({
16
- fileUri,
17
- numberOfSamples,
18
- offset,
19
- length,
20
- })
21
- return res
22
- }