@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,279 +0,0 @@
1
- package net.siteed.audiostream
2
-
3
- import org.junit.Test
4
- import org.junit.Assert.*
5
- import org.junit.Before
6
- import org.junit.After
7
- import java.io.ByteArrayOutputStream
8
- import java.io.File
9
- import java.nio.ByteBuffer
10
- import java.nio.ByteOrder
11
- import kotlin.test.assertNotNull
12
-
13
- class AudioFileHandlerTest {
14
- private lateinit var tempDir: File
15
- private lateinit var audioFileHandler: AudioFileHandler
16
-
17
- @Before
18
- fun setUp() {
19
- // Create a temporary directory for testing
20
- tempDir = File(System.getProperty("java.io.tmpdir"), "audio_test_${System.currentTimeMillis()}")
21
- tempDir.mkdirs()
22
- audioFileHandler = AudioFileHandler(tempDir)
23
- }
24
-
25
- @After
26
- fun tearDown() {
27
- // Clean up temporary directory
28
- tempDir.deleteRecursively()
29
- }
30
-
31
- @Test
32
- fun testWriteWavHeader_writesCorrectHeaderFormat() {
33
- // Given
34
- val outputStream = ByteArrayOutputStream()
35
- val sampleRate = 44100
36
- val channels = 2
37
- val bitDepth = 16
38
-
39
- // When
40
- audioFileHandler.writeWavHeader(outputStream, sampleRate, channels, bitDepth)
41
- val header = outputStream.toByteArray()
42
-
43
- // Then
44
- assertEquals("WAV header should be 44 bytes", 44, header.size)
45
-
46
- // Check RIFF header
47
- assertEquals("Should start with RIFF", "RIFF", String(header.sliceArray(0..3)))
48
- assertEquals("Should contain WAVE identifier", "WAVE", String(header.sliceArray(8..11)))
49
- assertEquals("Should contain fmt chunk", "fmt ", String(header.sliceArray(12..15)))
50
- assertEquals("Should contain data chunk", "data", String(header.sliceArray(36..39)))
51
-
52
- // Check audio format (PCM = 1)
53
- val audioFormat = ByteBuffer.wrap(header.sliceArray(20..21)).order(ByteOrder.LITTLE_ENDIAN).short
54
- assertEquals("Audio format should be 1 (PCM)", 1, audioFormat.toInt())
55
-
56
- // Check channels
57
- val headerChannels = ByteBuffer.wrap(header.sliceArray(22..23)).order(ByteOrder.LITTLE_ENDIAN).short
58
- assertEquals("Channels should match", channels, headerChannels.toInt())
59
-
60
- // Check sample rate
61
- val headerSampleRate = ByteBuffer.wrap(header.sliceArray(24..27)).order(ByteOrder.LITTLE_ENDIAN).int
62
- assertEquals("Sample rate should match", sampleRate, headerSampleRate)
63
-
64
- // Check bit depth
65
- val headerBitDepth = ByteBuffer.wrap(header.sliceArray(34..35)).order(ByteOrder.LITTLE_ENDIAN).short
66
- assertEquals("Bit depth should match", bitDepth, headerBitDepth.toInt())
67
- }
68
-
69
- @Test
70
- fun testWriteWavHeader_calculatesCorrectByteRate() {
71
- // Given
72
- val outputStream = ByteArrayOutputStream()
73
- val sampleRate = 48000
74
- val channels = 1
75
- val bitDepth = 24
76
- val expectedByteRate = sampleRate * channels * bitDepth / 8
77
-
78
- // When
79
- audioFileHandler.writeWavHeader(outputStream, sampleRate, channels, bitDepth)
80
- val header = outputStream.toByteArray()
81
-
82
- // Then
83
- val byteRate = ByteBuffer.wrap(header.sliceArray(28..31)).order(ByteOrder.LITTLE_ENDIAN).int
84
- assertEquals("Byte rate should be correctly calculated", expectedByteRate, byteRate)
85
- }
86
-
87
- @Test
88
- fun testCreateAudioFile_createsFileWithCorrectExtension() {
89
- // Given
90
- val extension = "wav"
91
-
92
- // When
93
- val file = audioFileHandler.createAudioFile(extension)
94
-
95
- // Then
96
- assertNotNull("File should not be null", file)
97
- assertTrue("File should exist", file.exists())
98
- assertTrue("File should have correct extension", file.name.endsWith(".$extension"))
99
- assertTrue("File should have correct prefix", file.name.startsWith("recording_"))
100
-
101
- // Clean up
102
- file.delete()
103
- }
104
-
105
- @Test
106
- fun testCreateAudioFile_createsUniqueFiles() {
107
- // Given
108
- val extension = "wav"
109
-
110
- // When
111
- val file1 = audioFileHandler.createAudioFile(extension)
112
- Thread.sleep(10) // Small delay to ensure different timestamps
113
- val file2 = audioFileHandler.createAudioFile(extension)
114
-
115
- // Then
116
- assertNotEquals("Files should have unique names", file1.name, file2.name)
117
- assertTrue("First file should exist", file1.exists())
118
- assertTrue("Second file should exist", file2.exists())
119
-
120
- // Clean up
121
- file1.delete()
122
- file2.delete()
123
- }
124
-
125
- @Test
126
- fun testDeleteFile_deletesExistingFile() {
127
- // Given
128
- val file = audioFileHandler.createAudioFile("wav")
129
- assertTrue("File should exist before deletion", file.exists())
130
-
131
- // When
132
- val result = audioFileHandler.deleteFile(file)
133
-
134
- // Then
135
- assertTrue("Delete should return true", result)
136
- assertFalse("File should not exist after deletion", file.exists())
137
- }
138
-
139
- @Test
140
- fun testDeleteFile_handlesNullFile() {
141
- // When
142
- val result = audioFileHandler.deleteFile(null)
143
-
144
- // Then
145
- assertFalse("Delete should return false for null file", result)
146
- }
147
-
148
- @Test
149
- fun testDeleteFile_handlesNonExistentFile() {
150
- // Given
151
- val nonExistentFile = File(tempDir, "non_existent.wav")
152
- assertFalse("File should not exist", nonExistentFile.exists())
153
-
154
- // When
155
- val result = audioFileHandler.deleteFile(nonExistentFile)
156
-
157
- // Then
158
- assertFalse("Delete should return false for non-existent file", result)
159
- }
160
-
161
- @Test
162
- fun testClearAudioStorage_deletesAllFiles() {
163
- // Given
164
- val file1 = audioFileHandler.createAudioFile("wav")
165
- val file2 = audioFileHandler.createAudioFile("mp3")
166
- val file3 = audioFileHandler.createAudioFile("aac")
167
-
168
- assertTrue("File 1 should exist", file1.exists())
169
- assertTrue("File 2 should exist", file2.exists())
170
- assertTrue("File 3 should exist", file3.exists())
171
-
172
- // When
173
- audioFileHandler.clearAudioStorage()
174
-
175
- // Then
176
- assertFalse("File 1 should be deleted", file1.exists())
177
- assertFalse("File 2 should be deleted", file2.exists())
178
- assertFalse("File 3 should be deleted", file3.exists())
179
- assertEquals("Directory should be empty", 0, tempDir.listFiles()?.size ?: 0)
180
- }
181
-
182
- @Test
183
- fun testUpdateWavHeader_updatesFileSizeCorrectly() {
184
- // Given
185
- val file = audioFileHandler.createAudioFile("wav")
186
- val outputStream = file.outputStream()
187
-
188
- // Write header
189
- audioFileHandler.writeWavHeader(outputStream, 44100, 2, 16)
190
-
191
- // Write some audio data (1 second of silence)
192
- val audioDataSize = 44100 * 2 * 2 // sampleRate * channels * bytesPerSample
193
- val audioData = ByteArray(audioDataSize)
194
- outputStream.write(audioData)
195
- outputStream.close()
196
-
197
- // When
198
- audioFileHandler.updateWavHeader(file)
199
-
200
- // Then
201
- val updatedHeader = file.inputStream().use { it.readNBytes(44) }
202
-
203
- // Check file size field (bytes 4-7)
204
- val fileSize = ByteBuffer.wrap(updatedHeader.sliceArray(4..7)).order(ByteOrder.LITTLE_ENDIAN).int
205
- assertEquals("File size should be data size + 36", audioDataSize + 36, fileSize)
206
-
207
- // Check data size field (bytes 40-43)
208
- val dataSize = ByteBuffer.wrap(updatedHeader.sliceArray(40..43)).order(ByteOrder.LITTLE_ENDIAN).int
209
- assertEquals("Data size should match audio data size", audioDataSize, dataSize)
210
-
211
- // Clean up
212
- file.delete()
213
- }
214
-
215
- @Test
216
- fun testLoadRealWavFile_readsHeaderCorrectly() {
217
- // Given - Load a real WAV file from test resources
218
- val resourceStream = javaClass.classLoader?.getResourceAsStream("jfk.wav")
219
- assertNotNull("Test resource jfk.wav should exist", resourceStream)
220
-
221
- val testFile = File(tempDir, "test_jfk.wav")
222
- resourceStream?.use { input ->
223
- testFile.outputStream().use { output ->
224
- input.copyTo(output)
225
- }
226
- }
227
-
228
- // When - Read the WAV header
229
- val header = testFile.inputStream().use { it.readNBytes(44) }
230
-
231
- // Then - Validate header structure
232
- assertEquals("Should start with RIFF", "RIFF", String(header.sliceArray(0..3)))
233
- assertEquals("Should contain WAVE identifier", "WAVE", String(header.sliceArray(8..11)))
234
- assertEquals("Should contain fmt chunk", "fmt ", String(header.sliceArray(12..15)))
235
-
236
- // Extract audio properties
237
- val channels = ByteBuffer.wrap(header.sliceArray(22..23)).order(ByteOrder.LITTLE_ENDIAN).short
238
- val sampleRate = ByteBuffer.wrap(header.sliceArray(24..27)).order(ByteOrder.LITTLE_ENDIAN).int
239
- val bitDepth = ByteBuffer.wrap(header.sliceArray(34..35)).order(ByteOrder.LITTLE_ENDIAN).short
240
-
241
- // JFK.wav is known to be mono, 16kHz, 16-bit
242
- assertEquals("JFK audio should be mono", 1, channels.toInt())
243
- assertEquals("JFK audio should be 16kHz", 16000, sampleRate)
244
- assertEquals("JFK audio should be 16-bit", 16, bitDepth.toInt())
245
-
246
- // Clean up
247
- testFile.delete()
248
- }
249
-
250
- @Test
251
- fun testProcessMultipleRealWavFiles() {
252
- // Test with different real WAV files to ensure compatibility
253
- val testFiles = listOf("jfk.wav", "recorder_hello_world.wav", "osr_us_000_0010_8k.wav")
254
-
255
- for (fileName in testFiles) {
256
- val resourceStream = javaClass.classLoader?.getResourceAsStream(fileName)
257
- if (resourceStream != null) {
258
- val testFile = File(tempDir, "test_$fileName")
259
- resourceStream.use { input ->
260
- testFile.outputStream().use { output ->
261
- input.copyTo(output)
262
- }
263
- }
264
-
265
- // Verify file was created and has content
266
- assertTrue("$fileName should exist", testFile.exists())
267
- assertTrue("$fileName should have more than just header", testFile.length() > 44)
268
-
269
- // Read and validate header
270
- val header = testFile.inputStream().use { it.readNBytes(44) }
271
- assertEquals("$fileName should have RIFF header", "RIFF", String(header.sliceArray(0..3)))
272
- assertEquals("$fileName should have WAVE format", "WAVE", String(header.sliceArray(8..11)))
273
-
274
- // Clean up
275
- testFile.delete()
276
- }
277
- }
278
- }
279
- }
@@ -1,249 +0,0 @@
1
- package net.siteed.audiostream
2
-
3
- import org.junit.Test
4
- import org.junit.Assert.*
5
-
6
- /**
7
- * Unit tests for audio focus strategy configuration and logic.
8
- * These tests verify that the RecordingConfig correctly handles audioFocusStrategy
9
- * parameter and that the smart defaults work as expected.
10
- */
11
- class AudioFocusStrategyTest {
12
-
13
- @Test
14
- fun testRecordingConfigWithExplicitBackgroundStrategy() {
15
- val options = mapOf(
16
- "sampleRate" to 44100,
17
- "channels" to 1,
18
- "encoding" to "pcm_16bit",
19
- "android" to mapOf(
20
- "audioFocusStrategy" to "background"
21
- )
22
- )
23
-
24
- val result = RecordingConfig.fromMap(options)
25
- assertTrue("Config creation should succeed", result.isSuccess)
26
-
27
- val (config, _) = result.getOrThrow()
28
- assertEquals("Audio focus strategy should be background", "background", config.audioFocusStrategy)
29
- }
30
-
31
- @Test
32
- fun testRecordingConfigWithExplicitInteractiveStrategy() {
33
- val options = mapOf(
34
- "sampleRate" to 44100,
35
- "channels" to 1,
36
- "encoding" to "pcm_16bit",
37
- "android" to mapOf(
38
- "audioFocusStrategy" to "interactive"
39
- )
40
- )
41
-
42
- val result = RecordingConfig.fromMap(options)
43
- assertTrue("Config creation should succeed", result.isSuccess)
44
-
45
- val (config, _) = result.getOrThrow()
46
- assertEquals("Audio focus strategy should be interactive", "interactive", config.audioFocusStrategy)
47
- }
48
-
49
- @Test
50
- fun testRecordingConfigWithExplicitCommunicationStrategy() {
51
- val options = mapOf(
52
- "sampleRate" to 44100,
53
- "channels" to 1,
54
- "encoding" to "pcm_16bit",
55
- "android" to mapOf(
56
- "audioFocusStrategy" to "communication"
57
- )
58
- )
59
-
60
- val result = RecordingConfig.fromMap(options)
61
- assertTrue("Config creation should succeed", result.isSuccess)
62
-
63
- val (config, _) = result.getOrThrow()
64
- assertEquals("Audio focus strategy should be communication", "communication", config.audioFocusStrategy)
65
- }
66
-
67
- @Test
68
- fun testRecordingConfigWithExplicitNoneStrategy() {
69
- val options = mapOf(
70
- "sampleRate" to 44100,
71
- "channels" to 1,
72
- "encoding" to "pcm_16bit",
73
- "android" to mapOf(
74
- "audioFocusStrategy" to "none"
75
- )
76
- )
77
-
78
- val result = RecordingConfig.fromMap(options)
79
- assertTrue("Config creation should succeed", result.isSuccess)
80
-
81
- val (config, _) = result.getOrThrow()
82
- assertEquals("Audio focus strategy should be none", "none", config.audioFocusStrategy)
83
- }
84
-
85
- @Test
86
- fun testRecordingConfigWithoutAudioFocusStrategy() {
87
- val options = mapOf(
88
- "sampleRate" to 44100,
89
- "channels" to 1,
90
- "encoding" to "pcm_16bit"
91
- )
92
-
93
- val result = RecordingConfig.fromMap(options)
94
- assertTrue("Config creation should succeed", result.isSuccess)
95
-
96
- val (config, _) = result.getOrThrow()
97
- assertNull("Audio focus strategy should be null when not specified", config.audioFocusStrategy)
98
- }
99
-
100
- @Test
101
- fun testRecordingConfigWithInvalidAudioFocusStrategy() {
102
- val options = mapOf(
103
- "sampleRate" to 44100,
104
- "channels" to 1,
105
- "encoding" to "pcm_16bit",
106
- "android" to mapOf(
107
- "audioFocusStrategy" to "invalid_strategy"
108
- )
109
- )
110
-
111
- val result = RecordingConfig.fromMap(options)
112
- assertTrue("Config creation should succeed even with invalid strategy", result.isSuccess)
113
-
114
- val (config, _) = result.getOrThrow()
115
- assertEquals("Invalid audio focus strategy should be preserved", "invalid_strategy", config.audioFocusStrategy)
116
- }
117
-
118
- @Test
119
- fun testRecordingConfigWithNullAudioFocusStrategy() {
120
- val options = mapOf(
121
- "sampleRate" to 44100,
122
- "channels" to 1,
123
- "encoding" to "pcm_16bit",
124
- "android" to mapOf(
125
- "audioFocusStrategy" to null
126
- )
127
- )
128
-
129
- val result = RecordingConfig.fromMap(options)
130
- assertTrue("Config creation should succeed", result.isSuccess)
131
-
132
- val (config, _) = result.getOrThrow()
133
- assertNull("Audio focus strategy should be null", config.audioFocusStrategy)
134
- }
135
-
136
- @Test
137
- fun testRecordingConfigKeepAwakeAndBackgroundStrategy() {
138
- val options = mapOf(
139
- "sampleRate" to 44100,
140
- "channels" to 1,
141
- "encoding" to "pcm_16bit",
142
- "keepAwake" to true,
143
- "android" to mapOf(
144
- "audioFocusStrategy" to "background"
145
- )
146
- )
147
-
148
- val result = RecordingConfig.fromMap(options)
149
- assertTrue("Config creation should succeed", result.isSuccess)
150
-
151
- val (config, _) = result.getOrThrow()
152
- assertTrue("keepAwake should be true", config.keepAwake)
153
- assertEquals("Audio focus strategy should be background", "background", config.audioFocusStrategy)
154
- }
155
-
156
- @Test
157
- fun testRecordingConfigKeepAwakeFalseAndInteractiveStrategy() {
158
- val options = mapOf(
159
- "sampleRate" to 44100,
160
- "channels" to 1,
161
- "encoding" to "pcm_16bit",
162
- "keepAwake" to false,
163
- "android" to mapOf(
164
- "audioFocusStrategy" to "interactive"
165
- )
166
- )
167
-
168
- val result = RecordingConfig.fromMap(options)
169
- assertTrue("Config creation should succeed", result.isSuccess)
170
-
171
- val (config, _) = result.getOrThrow()
172
- assertFalse("keepAwake should be false", config.keepAwake)
173
- assertEquals("Audio focus strategy should be interactive", "interactive", config.audioFocusStrategy)
174
- }
175
-
176
- @Test
177
- fun testRecordingConfigWithAutoResumeAndBackgroundStrategy() {
178
- val options = mapOf(
179
- "sampleRate" to 44100,
180
- "channels" to 1,
181
- "encoding" to "pcm_16bit",
182
- "autoResumeAfterInterruption" to true,
183
- "android" to mapOf(
184
- "audioFocusStrategy" to "background"
185
- )
186
- )
187
-
188
- val result = RecordingConfig.fromMap(options)
189
- assertTrue("Config creation should succeed", result.isSuccess)
190
-
191
- val (config, _) = result.getOrThrow()
192
- assertEquals("Audio focus strategy should be background", "background", config.audioFocusStrategy)
193
- assertTrue("autoResumeAfterInterruption should be true", config.autoResumeAfterInterruption)
194
- }
195
-
196
- @Test
197
- fun testRecordingConfigWithCommunicationStrategyAndSpeechSampleRate() {
198
- val options = mapOf(
199
- "sampleRate" to 16000, // Common speech sample rate
200
- "channels" to 1,
201
- "encoding" to "pcm_16bit",
202
- "android" to mapOf(
203
- "audioFocusStrategy" to "communication"
204
- )
205
- )
206
-
207
- val result = RecordingConfig.fromMap(options)
208
- assertTrue("Config creation should succeed", result.isSuccess)
209
-
210
- val (config, _) = result.getOrThrow()
211
- assertEquals("Sample rate should be 16000", 16000, config.sampleRate)
212
- assertEquals("Audio focus strategy should be communication", "communication", config.audioFocusStrategy)
213
- }
214
-
215
- @Test
216
- fun testDefaultRecordingConfigValues() {
217
- val result = RecordingConfig.fromMap(null)
218
- assertTrue("Config creation should succeed with null input", result.isSuccess)
219
-
220
- val (config, _) = result.getOrThrow()
221
- assertNull("Default audio focus strategy should be null", config.audioFocusStrategy)
222
- assertTrue("Default keepAwake should be true", config.keepAwake)
223
- assertFalse("Default autoResumeAfterInterruption should be false", config.autoResumeAfterInterruption)
224
- }
225
-
226
- @Test
227
- fun testRecordingConfigCompleteAudioFocusConfiguration() {
228
- val options = mapOf(
229
- "sampleRate" to 44100,
230
- "channels" to 1,
231
- "encoding" to "pcm_16bit",
232
- "keepAwake" to true,
233
- "autoResumeAfterInterruption" to true,
234
- "showNotification" to true,
235
- "android" to mapOf(
236
- "audioFocusStrategy" to "background"
237
- )
238
- )
239
-
240
- val result = RecordingConfig.fromMap(options)
241
- assertTrue("Config creation should succeed", result.isSuccess)
242
-
243
- val (config, _) = result.getOrThrow()
244
- assertEquals("Audio focus strategy should be background", "background", config.audioFocusStrategy)
245
- assertTrue("keepAwake should be true", config.keepAwake)
246
- assertTrue("autoResumeAfterInterruption should be true", config.autoResumeAfterInterruption)
247
- assertTrue("showNotification should be true", config.showNotification)
248
- }
249
- }
@@ -1,151 +0,0 @@
1
- package net.siteed.audiostream
2
-
3
- import org.junit.Test
4
- import org.junit.Assert.*
5
- import org.junit.Before
6
- import java.io.File
7
-
8
- class AudioFormatTest {
9
- private lateinit var tempDir: File
10
-
11
- @Before
12
- fun setUp() {
13
- tempDir = File(System.getProperty("java.io.tmpdir"), "audio_format_test_${System.currentTimeMillis()}")
14
- tempDir.mkdirs()
15
- }
16
-
17
- @Test
18
- fun testGetFileExtension_aacDefaultsToM4a() {
19
- // Given
20
- val config = RecordingConfig(
21
- output = OutputConfig(
22
- compressed = OutputConfig.CompressedOutput(
23
- enabled = true,
24
- format = "aac",
25
- preferRawStream = false
26
- )
27
- )
28
- )
29
-
30
- // When
31
- val file = createTestFile(config, isCompressed = true)
32
-
33
- // Then
34
- assertTrue("AAC without preferRawStream should produce .m4a", file.name.endsWith(".m4a"))
35
- }
36
-
37
- @Test
38
- fun testGetFileExtension_aacWithPreferRawStreamProducesAac() {
39
- // Given
40
- val config = RecordingConfig(
41
- output = OutputConfig(
42
- compressed = OutputConfig.CompressedOutput(
43
- enabled = true,
44
- format = "aac",
45
- preferRawStream = true
46
- )
47
- )
48
- )
49
-
50
- // When
51
- val file = createTestFile(config, isCompressed = true)
52
-
53
- // Then
54
- assertTrue("AAC with preferRawStream should produce .aac", file.name.endsWith(".aac"))
55
- }
56
-
57
- @Test
58
- fun testGetFileExtension_opusProducesOpus() {
59
- // Given
60
- val config = RecordingConfig(
61
- output = OutputConfig(
62
- compressed = OutputConfig.CompressedOutput(
63
- enabled = true,
64
- format = "opus"
65
- )
66
- )
67
- )
68
-
69
- // When
70
- val file = createTestFile(config, isCompressed = true)
71
-
72
- // Then
73
- assertTrue("Opus should produce .opus", file.name.endsWith(".opus"))
74
- }
75
-
76
- @Test
77
- fun testGetFileExtension_wavForUncompressed() {
78
- // Given
79
- val config = RecordingConfig()
80
-
81
- // When
82
- val file = createTestFile(config, isCompressed = false)
83
-
84
- // Then
85
- assertTrue("Uncompressed should produce .wav", file.name.endsWith(".wav"))
86
- }
87
-
88
- @Test
89
- fun testCompressedOutput_parseFromMap() {
90
- // Given
91
- val map = mapOf(
92
- "enabled" to true,
93
- "format" to "aac",
94
- "bitrate" to 192000,
95
- "preferRawStream" to true
96
- )
97
-
98
- // When
99
- val compressed = OutputConfig.CompressedOutput(
100
- enabled = map["enabled"] as Boolean,
101
- format = map["format"] as String,
102
- bitrate = map["bitrate"] as Int,
103
- preferRawStream = map["preferRawStream"] as Boolean
104
- )
105
-
106
- // Then
107
- assertTrue("enabled should be true", compressed.enabled)
108
- assertEquals("format should be aac", "aac", compressed.format)
109
- assertEquals("bitrate should be 192000", 192000, compressed.bitrate)
110
- assertTrue("preferRawStream should be true", compressed.preferRawStream)
111
- }
112
-
113
- @Test
114
- fun testCompressedOutput_defaultValues() {
115
- // When
116
- val compressed = OutputConfig.CompressedOutput()
117
-
118
- // Then
119
- assertFalse("enabled should default to false", compressed.enabled)
120
- assertEquals("format should default to aac", "aac", compressed.format)
121
- assertEquals("bitrate should default to 128000", 128000, compressed.bitrate)
122
- assertFalse("preferRawStream should default to false", compressed.preferRawStream)
123
- }
124
-
125
- /**
126
- * Helper function to simulate file creation logic from AudioRecorderManager
127
- */
128
- private fun createTestFile(config: RecordingConfig, isCompressed: Boolean): File {
129
- val baseFilename = config.filename?.let {
130
- it.substringBeforeLast('.', it)
131
- } ?: "test_recording"
132
-
133
- val extension = if (isCompressed) {
134
- when (config.output.compressed.format.lowercase()) {
135
- "aac" -> {
136
- if (config.output.compressed.preferRawStream) {
137
- "aac" // Raw AAC stream
138
- } else {
139
- "m4a" // M4A container (new default)
140
- }
141
- }
142
- "opus" -> "opus" // Opus in OGG container
143
- else -> config.output.compressed.format.lowercase()
144
- }
145
- } else {
146
- "wav"
147
- }
148
-
149
- return File(tempDir, "$baseFilename.$extension")
150
- }
151
- }