react-native-audio-api 0.11.0-alpha.1 → 0.11.0-nightly-bfab178-20251107

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 (355) hide show
  1. package/README.md +13 -11
  2. package/RNAudioAPI.podspec +20 -15
  3. package/android/build.gradle +33 -3
  4. package/android/src/main/cpp/audioapi/CMakeLists.txt +6 -3
  5. package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +5 -0
  6. package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +1 -0
  7. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +30 -142
  8. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +13 -40
  9. package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +4 -2
  10. package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
  11. package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +6 -0
  12. package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +31 -3
  13. package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +21 -9
  14. package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +27 -6
  15. package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +11 -0
  16. package/android/src/oldarch/NativeAudioAPIModuleSpec.java +4 -0
  17. package/common/cpp/audioapi/AudioAPIModuleInstaller.h +30 -2
  18. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +18 -0
  19. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +1 -0
  20. package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
  21. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +47 -0
  22. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +20 -0
  23. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +18 -97
  24. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +6 -18
  25. package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +1 -1
  26. package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +1 -1
  27. package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.cpp +1 -1
  28. package/common/cpp/audioapi/core/AudioNode.h +3 -2
  29. package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
  30. package/common/cpp/audioapi/core/BaseAudioContext.cpp +10 -0
  31. package/common/cpp/audioapi/core/BaseAudioContext.h +2 -0
  32. package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +69 -32
  33. package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +37 -1
  34. package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +210 -0
  35. package/common/cpp/audioapi/core/effects/ConvolverNode.h +55 -0
  36. package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +82 -36
  37. package/common/cpp/audioapi/core/inputs/AudioRecorder.h +31 -52
  38. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +14 -17
  39. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +0 -1
  40. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +8 -14
  41. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +0 -1
  42. package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +14 -18
  43. package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +2 -2
  44. package/common/cpp/audioapi/core/sources/StreamerNode.cpp +64 -64
  45. package/common/cpp/audioapi/core/sources/StreamerNode.h +38 -10
  46. package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +5 -0
  47. package/common/cpp/audioapi/core/utils/Constants.h +2 -1
  48. package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +12 -8
  49. package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.cpp +3 -3
  50. package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.h +1 -1
  51. package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
  52. package/common/cpp/audioapi/dsp/Convolver.cpp +213 -0
  53. package/common/cpp/audioapi/dsp/Convolver.h +45 -0
  54. package/common/cpp/audioapi/dsp/FFT.cpp +0 -26
  55. package/common/cpp/audioapi/dsp/FFT.h +26 -2
  56. package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +1 -1
  57. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +4 -4
  58. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +1 -1
  59. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +1 -1
  60. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +3 -1
  61. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +2 -2
  62. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/defs.h +3 -0
  63. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/packet.h +1 -1
  64. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/smpte_436m.h +254 -0
  65. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/version.h +1 -1
  66. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +6 -6
  67. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version.h +2 -2
  68. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version_major.h +2 -0
  69. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avassert.h +5 -2
  70. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
  71. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/channel_layout.h +2 -2
  72. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/csp.h +1 -1
  73. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/dict.h +1 -1
  74. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/ffversion.h +1 -1
  75. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/film_grain_params.h +1 -1
  76. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/frame.h +1 -1
  77. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hdr_dynamic_vivid_metadata.h +3 -3
  78. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext.h +1 -1
  79. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_opencl.h +1 -1
  80. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_qsv.h +0 -1
  81. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_vulkan.h +1 -1
  82. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/iamf.h +2 -2
  83. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/lfg.h +2 -2
  84. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/log.h +2 -2
  85. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/mathematics.h +1 -1
  86. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/opt.h +4 -4
  87. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rational.h +1 -1
  88. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rc4.h +1 -1
  89. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/refstruct.h +1 -1
  90. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/spherical.h +6 -0
  91. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tdrdi.h +1 -1
  92. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tx.h +1 -1
  93. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/version.h +3 -3
  94. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/video_hint.h +1 -1
  95. package/common/cpp/audioapi/external/ffmpeg_include/libswresample/swresample.h +1 -1
  96. package/common/cpp/audioapi/external/ffmpeg_include/libswresample/version.h +1 -1
  97. package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +2 -3
  98. package/common/cpp/audioapi/libs/ffmpeg/relinking.md +24 -0
  99. package/common/cpp/audioapi/utils/AlignedAllocator.hpp +50 -0
  100. package/common/cpp/audioapi/utils/AudioBus.cpp +28 -0
  101. package/common/cpp/audioapi/utils/AudioBus.h +3 -0
  102. package/common/cpp/audioapi/utils/ThreadPool.hpp +59 -1
  103. package/common/cpp/test/CMakeLists.txt +19 -14
  104. package/common/cpp/test/src/AudioParamTest.cpp +1 -1
  105. package/common/cpp/test/src/AudioScheduledSourceTest.cpp +134 -0
  106. package/common/cpp/test/src/ConstantSourceTest.cpp +1 -1
  107. package/common/cpp/test/src/GainTest.cpp +1 -1
  108. package/common/cpp/test/src/MockAudioEventHandlerRegistry.h +4 -4
  109. package/common/cpp/test/src/OscillatorTest.cpp +1 -1
  110. package/common/cpp/test/src/StereoPannerTest.cpp +1 -1
  111. package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +389 -0
  112. package/common/cpp/test/src/biquad/BiquadFilterChromium.h +64 -0
  113. package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +284 -0
  114. package/common/cpp/test/src/biquad/BiquadFilterTest.h +40 -0
  115. package/ios/audioapi/ios/AudioAPIModule.h +2 -1
  116. package/ios/audioapi/ios/AudioAPIModule.mm +13 -0
  117. package/ios/audioapi/ios/core/IOSAudioRecorder.h +10 -28
  118. package/ios/audioapi/ios/core/IOSAudioRecorder.mm +30 -117
  119. package/ios/audioapi/ios/core/NativeAudioRecorder.h +9 -4
  120. package/ios/audioapi/ios/core/NativeAudioRecorder.m +71 -29
  121. package/ios/audioapi/ios/core/utils/AudioDecoder.mm +0 -1
  122. package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
  123. package/ios/audioapi/ios/system/AudioSessionManager.h +2 -0
  124. package/ios/audioapi/ios/system/AudioSessionManager.mm +24 -0
  125. package/ios/audioapi/ios/system/LockScreenManager.h +0 -1
  126. package/ios/audioapi/ios/system/LockScreenManager.mm +6 -19
  127. package/lib/commonjs/api.js +141 -76
  128. package/lib/commonjs/api.js.map +1 -1
  129. package/lib/commonjs/api.web.js +8 -0
  130. package/lib/commonjs/api.web.js.map +1 -1
  131. package/lib/commonjs/core/AudioContext.js +1 -1
  132. package/lib/commonjs/core/AudioContext.js.map +1 -1
  133. package/lib/commonjs/core/AudioRecorder.js +13 -171
  134. package/lib/commonjs/core/AudioRecorder.js.map +1 -1
  135. package/lib/commonjs/core/BaseAudioContext.js +28 -25
  136. package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
  137. package/lib/commonjs/core/ConvolverNode.js +37 -0
  138. package/lib/commonjs/core/ConvolverNode.js.map +1 -0
  139. package/lib/commonjs/core/OfflineAudioContext.js +1 -1
  140. package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
  141. package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
  142. package/lib/commonjs/system/AudioManager.js +3 -0
  143. package/lib/commonjs/system/AudioManager.js.map +1 -1
  144. package/lib/commonjs/types.js +0 -46
  145. package/lib/commonjs/types.js.map +1 -1
  146. package/lib/commonjs/utils/index.js +19 -21
  147. package/lib/commonjs/utils/index.js.map +1 -1
  148. package/lib/commonjs/web-core/AudioContext.js +12 -0
  149. package/lib/commonjs/web-core/AudioContext.js.map +1 -1
  150. package/lib/commonjs/web-core/ConvolverNode.js +40 -0
  151. package/lib/commonjs/web-core/ConvolverNode.js.map +1 -0
  152. package/lib/commonjs/web-core/ConvolverNodeOptions.js +6 -0
  153. package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +1 -0
  154. package/lib/commonjs/web-core/OfflineAudioContext.js +12 -0
  155. package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
  156. package/lib/module/api.js +16 -15
  157. package/lib/module/api.js.map +1 -1
  158. package/lib/module/api.web.js +1 -0
  159. package/lib/module/api.web.js.map +1 -1
  160. package/lib/module/core/AudioContext.js +2 -2
  161. package/lib/module/core/AudioContext.js.map +1 -1
  162. package/lib/module/core/AudioRecorder.js +13 -171
  163. package/lib/module/core/AudioRecorder.js.map +1 -1
  164. package/lib/module/core/BaseAudioContext.js +29 -26
  165. package/lib/module/core/BaseAudioContext.js.map +1 -1
  166. package/lib/module/core/ConvolverNode.js +31 -0
  167. package/lib/module/core/ConvolverNode.js.map +1 -0
  168. package/lib/module/core/OfflineAudioContext.js +2 -2
  169. package/lib/module/core/OfflineAudioContext.js.map +1 -1
  170. package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
  171. package/lib/module/system/AudioManager.js +3 -0
  172. package/lib/module/system/AudioManager.js.map +1 -1
  173. package/lib/module/types.js +1 -45
  174. package/lib/module/types.js.map +1 -1
  175. package/lib/module/utils/index.js +15 -2
  176. package/lib/module/utils/index.js.map +1 -1
  177. package/lib/module/web-core/AudioContext.js +12 -0
  178. package/lib/module/web-core/AudioContext.js.map +1 -1
  179. package/lib/module/web-core/ConvolverNode.js +34 -0
  180. package/lib/module/web-core/ConvolverNode.js.map +1 -0
  181. package/lib/module/web-core/ConvolverNodeOptions.js +4 -0
  182. package/lib/module/web-core/ConvolverNodeOptions.js.map +1 -0
  183. package/lib/module/web-core/OfflineAudioContext.js +12 -0
  184. package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
  185. package/lib/typescript/api.d.ts +19 -17
  186. package/lib/typescript/api.d.ts.map +1 -1
  187. package/lib/typescript/api.web.d.ts +1 -0
  188. package/lib/typescript/api.web.d.ts.map +1 -1
  189. package/lib/typescript/core/AudioContext.d.ts.map +1 -1
  190. package/lib/typescript/core/AudioRecorder.d.ts +7 -62
  191. package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
  192. package/lib/typescript/core/BaseAudioContext.d.ts +3 -1
  193. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
  194. package/lib/typescript/core/ConvolverNode.d.ts +12 -0
  195. package/lib/typescript/core/ConvolverNode.d.ts.map +1 -0
  196. package/lib/typescript/events/types.d.ts +0 -16
  197. package/lib/typescript/events/types.d.ts.map +1 -1
  198. package/lib/typescript/interfaces.d.ts +9 -42
  199. package/lib/typescript/interfaces.d.ts.map +1 -1
  200. package/lib/typescript/specs/NativeAudioAPIModule.d.ts +1 -0
  201. package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
  202. package/lib/typescript/system/AudioManager.d.ts +1 -0
  203. package/lib/typescript/system/AudioManager.d.ts.map +1 -1
  204. package/lib/typescript/types.d.ts +8 -79
  205. package/lib/typescript/types.d.ts.map +1 -1
  206. package/lib/typescript/utils/index.d.ts +5 -2
  207. package/lib/typescript/utils/index.d.ts.map +1 -1
  208. package/lib/typescript/web-core/AudioContext.d.ts +3 -0
  209. package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
  210. package/lib/typescript/web-core/BaseAudioContext.d.ts +2 -0
  211. package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
  212. package/lib/typescript/web-core/ConvolverNode.d.ts +11 -0
  213. package/lib/typescript/web-core/ConvolverNode.d.ts.map +1 -0
  214. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +6 -0
  215. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +1 -0
  216. package/lib/typescript/web-core/OfflineAudioContext.d.ts +3 -0
  217. package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
  218. package/package.json +14 -5
  219. package/scripts/download-prebuilt-binaries.sh +61 -0
  220. package/scripts/rnaa_utils.rb +8 -0
  221. package/scripts/validate-worklets-version.js +28 -0
  222. package/src/api.ts +45 -18
  223. package/src/api.web.ts +1 -0
  224. package/src/core/AudioContext.ts +3 -2
  225. package/src/core/AudioRecorder.ts +24 -211
  226. package/src/core/BaseAudioContext.ts +67 -60
  227. package/src/core/ConvolverNode.ts +35 -0
  228. package/src/core/OfflineAudioContext.ts +2 -2
  229. package/src/events/types.ts +0 -18
  230. package/src/interfaces.ts +16 -52
  231. package/src/specs/NativeAudioAPIModule.ts +1 -0
  232. package/src/system/AudioManager.ts +4 -0
  233. package/src/types.ts +9 -90
  234. package/src/utils/index.ts +22 -2
  235. package/src/web-core/AudioContext.tsx +25 -0
  236. package/src/web-core/BaseAudioContext.tsx +2 -0
  237. package/src/web-core/ConvolverNode.tsx +43 -0
  238. package/src/web-core/ConvolverNodeOptions.tsx +6 -0
  239. package/src/web-core/OfflineAudioContext.tsx +25 -0
  240. package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +0 -37
  241. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +0 -187
  242. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +0 -57
  243. package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +0 -34
  244. package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +0 -133
  245. package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +0 -3
  246. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +0 -154
  247. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +0 -41
  248. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +0 -429
  249. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +0 -113
  250. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +0 -47
  251. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +0 -28
  252. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +0 -269
  253. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +0 -47
  254. package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +0 -31
  255. package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +0 -18
  256. package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
  257. package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
  258. package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
  259. package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
  260. package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
  261. package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
  262. package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
  263. package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
  264. package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
  265. package/android/src/main/jniLibs/x86/libavformat.so +0 -0
  266. package/android/src/main/jniLibs/x86/libavutil.so +0 -0
  267. package/android/src/main/jniLibs/x86/libswresample.so +0 -0
  268. package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
  269. package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
  270. package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
  271. package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
  272. package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
  273. package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
  274. package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
  275. package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
  276. package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
  277. package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
  278. package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
  279. package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
  280. package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
  281. package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
  282. package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
  283. package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
  284. package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
  285. package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
  286. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
  287. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
  288. package/common/cpp/audioapi/external/iphoneos/libcrypto.a +0 -0
  289. package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
  290. package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
  291. package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
  292. package/common/cpp/audioapi/external/iphoneos/libssl.a +0 -0
  293. package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
  294. package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
  295. package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
  296. package/common/cpp/audioapi/external/iphonesimulator/libcrypto.a +0 -0
  297. package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
  298. package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
  299. package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
  300. package/common/cpp/audioapi/external/iphonesimulator/libssl.a +0 -0
  301. package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
  302. package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
  303. package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
  304. package/common/cpp/audioapi/external/libavcodec.xcframework/Info.plist +0 -44
  305. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +0 -1
  306. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
  307. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/Info.plist +0 -1
  308. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
  309. package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +0 -44
  310. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +0 -1
  311. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
  312. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/Info.plist +0 -1
  313. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
  314. package/common/cpp/audioapi/external/libavutil.xcframework/Info.plist +0 -44
  315. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +0 -1
  316. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
  317. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/Info.plist +0 -1
  318. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
  319. package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +0 -44
  320. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +0 -1
  321. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
  322. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/Info.plist +0 -1
  323. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
  324. package/common/cpp/audioapi/external/x86/libcrypto.a +0 -0
  325. package/common/cpp/audioapi/external/x86/libogg.a +0 -0
  326. package/common/cpp/audioapi/external/x86/libopus.a +0 -0
  327. package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
  328. package/common/cpp/audioapi/external/x86/libssl.a +0 -0
  329. package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
  330. package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
  331. package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
  332. package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
  333. package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
  334. package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
  335. package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
  336. package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
  337. package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
  338. package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
  339. package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
  340. package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +0 -32
  341. package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +0 -111
  342. package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +0 -391
  343. package/ios/audioapi/ios/core/IOSAudioFileOptions.h +0 -36
  344. package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +0 -140
  345. package/ios/audioapi/ios/core/IOSAudioFileWriter.h +0 -51
  346. package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +0 -223
  347. package/ios/audioapi/ios/core/IOSRecorderCallback.h +0 -57
  348. package/ios/audioapi/ios/core/IOSRecorderCallback.mm +0 -189
  349. package/lib/commonjs/utils/bitEnums.js +0 -33
  350. package/lib/commonjs/utils/bitEnums.js.map +0 -1
  351. package/lib/module/utils/bitEnums.js +0 -27
  352. package/lib/module/utils/bitEnums.js.map +0 -1
  353. package/lib/typescript/utils/bitEnums.d.ts +0 -4
  354. package/lib/typescript/utils/bitEnums.d.ts.map +0 -1
  355. package/src/utils/bitEnums.ts +0 -51
@@ -11,6 +11,7 @@
11
11
  #pragma once
12
12
 
13
13
  #include <audioapi/core/sources/AudioScheduledSourceNode.h>
14
+ #include <audioapi/utils/AudioBus.h>
14
15
 
15
16
  #ifndef AUDIO_API_TEST_SUITE
16
17
  extern "C" {
@@ -27,8 +28,35 @@ extern "C" {
27
28
  #include <memory>
28
29
  #include <string>
29
30
  #include <atomic>
31
+ #include <utility>
32
+ #ifndef AUDIO_API_TEST_SUITE
33
+ #include <audioapi/utils/SpscChannel.hpp>
30
34
 
31
- static bool constexpr VERBOSE = false;
35
+ static constexpr audioapi::channels::spsc::OverflowStrategy STREAMER_NODE_SPSC_OVERFLOW_STRATEGY =
36
+ audioapi::channels::spsc::OverflowStrategy::WAIT_ON_FULL;
37
+ static constexpr audioapi::channels::spsc::WaitStrategy STREAMER_NODE_SPSC_WAIT_STRATEGY =
38
+ audioapi::channels::spsc::WaitStrategy::ATOMIC_WAIT;
39
+ #endif
40
+
41
+ static constexpr bool VERBOSE = false;
42
+ static constexpr int CHANNEL_CAPACITY = 32;
43
+
44
+ struct StreamingData{
45
+ audioapi::AudioBus bus;
46
+ size_t size;
47
+ StreamingData() = default;
48
+ StreamingData(audioapi::AudioBus b, size_t s) : bus(b), size(s) {}
49
+ StreamingData(const StreamingData& data) : bus(data.bus), size(data.size) {}
50
+ StreamingData(StreamingData&& data) noexcept : bus(std::move(data.bus)), size(data.size) {}
51
+ StreamingData& operator=(const StreamingData& data) {
52
+ if (this == &data) {
53
+ return *this;
54
+ }
55
+ bus = data.bus;
56
+ size = data.size;
57
+ return *this;
58
+ }
59
+ };
32
60
 
33
61
  namespace audioapi {
34
62
 
@@ -43,7 +71,6 @@ class StreamerNode : public AudioScheduledSourceNode {
43
71
  * @brief Initialize all necessary ffmpeg components for streaming audio
44
72
  */
45
73
  bool initialize(const std::string& inputUrl);
46
- void stop(double when) override;
47
74
 
48
75
  protected:
49
76
  std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus>& processingBus, int framesToProcess) override;
@@ -56,19 +83,20 @@ class StreamerNode : public AudioScheduledSourceNode {
56
83
  AVCodecParameters* codecpar_;
57
84
  AVPacket* pkt_;
58
85
  AVFrame* frame_; // Frame that is currently being processed
59
- AVFrame* pendingFrame_; // Frame that is saved if bufferedBus is full
60
- std::shared_ptr<AudioBus> bufferedBus_; // audio bus for buffering hls frames
61
- size_t bufferedBusIndex_; // index in the buffered bus where we write the next frame
62
- size_t maxBufferSize_; // maximum size of the buffered bus
63
- int audio_stream_index_; // index of the audio stream channel in the input
64
86
  SwrContext* swrCtx_;
65
87
  uint8_t** resampledData_; // weird ffmpeg way of using raw byte pointers for resampled data
88
+
89
+ std::shared_ptr<AudioBus> bufferedBus_; // audio bus for buffering hls frames
90
+ size_t bufferedBusSize_; // size of currently buffered bus
91
+ int audio_stream_index_; // index of the audio stream channel in the input
66
92
  int maxResampledSamples_;
67
- std::mutex mutex_;
93
+ size_t processedSamples_;
94
+
68
95
  std::thread streamingThread_;
69
- std::atomic<bool> streamFlag; // Flag to control the streaming thread
70
- static constexpr float BUFFER_LENGTH_SECONDS = 5.0f; // Length of the buffer in seconds
96
+ std::atomic<bool> isNodeFinished_; // Flag to control the streaming thread
71
97
  static constexpr int INITIAL_MAX_RESAMPLED_SAMPLES = 8192; // Initial size for resampled data
98
+ channels::spsc::Sender<StreamingData, STREAMER_NODE_SPSC_OVERFLOW_STRATEGY, STREAMER_NODE_SPSC_WAIT_STRATEGY> sender_;
99
+ channels::spsc::Receiver<StreamingData, STREAMER_NODE_SPSC_OVERFLOW_STRATEGY, STREAMER_NODE_SPSC_WAIT_STRATEGY> receiver_;
72
100
 
73
101
  /**
74
102
  * @brief Setting up the resampler
@@ -1,5 +1,6 @@
1
1
  #include <audioapi/core/AudioNode.h>
2
2
  #include <audioapi/core/AudioParam.h>
3
+ #include <audioapi/core/effects/ConvolverNode.h>
3
4
  #include <audioapi/core/sources/AudioScheduledSourceNode.h>
4
5
  #include <audioapi/core/utils/AudioNodeManager.h>
5
6
  #include <audioapi/core/utils/Locker.h>
@@ -221,6 +222,10 @@ inline bool AudioNodeManager::nodeCanBeDestructed(
221
222
  if constexpr (std::is_base_of_v<AudioScheduledSourceNode, U>) {
222
223
  return node.use_count() == 1 &&
223
224
  (node->isUnscheduled() || node->isFinished());
225
+ } else if constexpr (std::is_base_of_v<
226
+ ConvolverNode,
227
+ U>) { // convolver overrides disabling behavior
228
+ return node.use_count() == 1 && !node->isEnabled();
224
229
  }
225
230
  return node.use_count() == 1;
226
231
  }
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
2
 
3
+ #include <numbers>
3
4
  #include <cmath>
4
5
  #include <limits>
5
6
 
@@ -19,7 +20,7 @@ static constexpr float MOST_POSITIVE_SINGLE_FLOAT = static_cast<float>(std::nume
19
20
  static constexpr float MOST_NEGATIVE_SINGLE_FLOAT = static_cast<float>(std::numeric_limits<float>::lowest());
20
21
  static float LOG2_MOST_POSITIVE_SINGLE_FLOAT = std::log2(MOST_POSITIVE_SINGLE_FLOAT);
21
22
  static float LOG10_MOST_POSITIVE_SINGLE_FLOAT = std::log10(MOST_POSITIVE_SINGLE_FLOAT);
22
- static constexpr float PI = static_cast<float>(M_PI);
23
+ static constexpr float PI = std::numbers::pi_v<float>;
23
24
 
24
25
  // buffer sizes
25
26
  static constexpr size_t PROMISE_VENDOR_THREAD_POOL_WORKER_COUNT = 4;
@@ -5,14 +5,8 @@
5
5
  #include <string>
6
6
  #include <memory>
7
7
 
8
- #ifdef __APPLE__
9
- /// We cannot make any conditional logic inside podspec but it should automatically compile those files
10
- /// they should be accessible if someone has react-native-worklets in node_modules
11
- #if __has_include(<worklets/WorkletRuntime/WorkletRuntime.h>)
12
- #define RN_AUDIO_API_ENABLE_WORKLETS 1
13
- #else
14
- #define RN_AUDIO_API_ENABLE_WORKLETS 0
15
- #endif
8
+ #if ANDROID
9
+ #include <fbjni/detail/Environment.h>
16
10
  #endif
17
11
 
18
12
  #ifndef RN_AUDIO_API_TEST
@@ -78,4 +72,14 @@ class SerializableWorklet {
78
72
  struct RuntimeRegistry {
79
73
  std::weak_ptr<worklets::WorkletRuntime> uiRuntime;
80
74
  std::shared_ptr<worklets::WorkletRuntime> audioRuntime;
75
+
76
+ #if ANDROID
77
+ ~RuntimeRegistry() {
78
+ facebook::jni::ThreadScope::WithClassLoader(
79
+ [this]() {
80
+ uiRuntime.reset();
81
+ audioRuntime.reset();
82
+ });
83
+ }
84
+ #endif
81
85
  };
@@ -4,7 +4,7 @@ namespace audioapi {
4
4
 
5
5
  WorkletsRunner::WorkletsRunner(
6
6
  std::weak_ptr<worklets::WorkletRuntime> weakRuntime,
7
- std::shared_ptr<worklets::SerializableWorklet> shareableWorklet,
7
+ const std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet,
8
8
  bool shouldLockRuntime)
9
9
  : weakRuntime_(std::move(weakRuntime)),
10
10
  shouldLockRuntime(shouldLockRuntime) {
@@ -33,8 +33,8 @@ WorkletsRunner::WorkletsRunner(
33
33
  WorkletsRunner::WorkletsRunner(WorkletsRunner &&other)
34
34
  : weakRuntime_(std::move(other.weakRuntime_)),
35
35
  unsafeRuntimePtr(other.unsafeRuntimePtr),
36
- shouldLockRuntime(other.shouldLockRuntime),
37
- workletInitialized(other.workletInitialized) {
36
+ workletInitialized(other.workletInitialized),
37
+ shouldLockRuntime(other.shouldLockRuntime) {
38
38
  if (workletInitialized) {
39
39
  std::memcpy(&unsafeWorklet, &other.unsafeWorklet, sizeof(unsafeWorklet));
40
40
  other.workletInitialized = false;
@@ -28,7 +28,7 @@ class WorkletsRunner {
28
28
  public:
29
29
  explicit WorkletsRunner(
30
30
  std::weak_ptr<worklets::WorkletRuntime> weakRuntime,
31
- std::shared_ptr<worklets::SerializableWorklet> shareableWorklet,
31
+ const std::shared_ptr<worklets::SerializableWorklet>& shareableWorklet,
32
32
  bool shouldLockRuntime = true);
33
33
  WorkletsRunner(WorkletsRunner&&);
34
34
  ~WorkletsRunner();
@@ -30,4 +30,4 @@ float linearToDecibels(float value) {
30
30
  float decibelsToLinear(float value) {
31
31
  return pow(10, value / 20);
32
32
  }
33
- } // namespace audioapi::dsp
33
+ } // namespace audioapi::dsp
@@ -0,0 +1,213 @@
1
+ // implementation of linear convolution algorithm described in this paper:
2
+ // https://publications.rwth-aachen.de/record/466561/files/466561.pdf page 110
3
+
4
+ #if defined(__ARM_NEON)
5
+ #include <arm_neon.h>
6
+ #endif
7
+
8
+ #include <audioapi/core/sources/AudioBuffer.h>
9
+ #include <audioapi/dsp/Convolver.h>
10
+ #include <audioapi/dsp/VectorMath.h>
11
+ #include <audioapi/utils/AudioArray.h>
12
+ #include <chrono>
13
+ #include <iostream>
14
+
15
+ namespace audioapi {
16
+
17
+ Convolver::Convolver()
18
+ : _blockSize(0),
19
+ _segSize(0),
20
+ _segCount(0),
21
+ _fftComplexSize(0),
22
+ _segments(),
23
+ _segmentsIR(),
24
+ _fftBuffer(0),
25
+ _fft(nullptr),
26
+ _preMultiplied(),
27
+ _current(0),
28
+ _inputBuffer(0) {}
29
+
30
+ void Convolver::reset() {
31
+ _blockSize = 0;
32
+ _segSize = 0;
33
+ _segCount = 0;
34
+ _fftComplexSize = 0;
35
+ _current = 0;
36
+ _fft = nullptr;
37
+ _segments.clear();
38
+ _segmentsIR.clear();
39
+ _preMultiplied.clear();
40
+ _fftBuffer.zero();
41
+ _inputBuffer.zero();
42
+ }
43
+
44
+ bool Convolver::init(
45
+ size_t blockSize,
46
+ const audioapi::AudioArray &ir,
47
+ size_t irLen) {
48
+ reset();
49
+ // blockSize must be a power of two
50
+ if ((blockSize & (blockSize - 1))) {
51
+ return false;
52
+ }
53
+
54
+ // Ignore zeros at the end of the impulse response because they only waste
55
+ // computation time
56
+ _blockSize = blockSize;
57
+ _trueSegmentCount = (size_t)(std::ceil((float)irLen / (float)_blockSize));
58
+ while (irLen > 0 && ::fabs(ir[irLen - 1]) < 10e-3) {
59
+ --irLen;
60
+ }
61
+
62
+ if (irLen == 0) {
63
+ return true;
64
+ }
65
+
66
+ // The length-N is split into P = N/B length-B sub filters
67
+ _segCount = (size_t)(std::ceil((float)irLen / (float)_blockSize));
68
+ _segSize = 2 * _blockSize;
69
+ // size of the FFT is 2B, so the complex size is B+1, due to the
70
+ // complex-conjugate symmetricity
71
+ _fftComplexSize = _segSize / 2 + 1;
72
+ _fft = std::make_shared<dsp::FFT>((int)_segSize);
73
+ _fftBuffer.resize(_segSize);
74
+
75
+ // segments preparation
76
+ for (int i = 0; i < _segCount; ++i) {
77
+ aligned_vec_complex vec(_fftComplexSize, std::complex<float>(0.0f, 0.0f));
78
+ _segments.push_back(vec);
79
+ }
80
+
81
+ // ir preparation
82
+ for (int i = 0; i < _segCount; ++i) {
83
+ aligned_vec_complex segment(_fftComplexSize);
84
+ const size_t remainingSamples = irLen - (i * _blockSize);
85
+ const size_t samplesToCopy = std::min(_blockSize, remainingSamples);
86
+
87
+ if (samplesToCopy > 0) {
88
+ memcpy(
89
+ _fftBuffer.getData(),
90
+ ir.getData() + i * _blockSize,
91
+ samplesToCopy * sizeof(float));
92
+ }
93
+ // Each sub filter is zero-padded to length 2B and transformed using a
94
+ // 2B-point real-to-complex FFT.
95
+ memset(_fftBuffer.getData() + _blockSize, 0, _blockSize * sizeof(float));
96
+ _fft->doFFT(_fftBuffer.getData(), segment);
97
+ segment.at(0).imag(0.0f); // ensure DC component is real
98
+ _segmentsIR.push_back(segment);
99
+ }
100
+
101
+ _preMultiplied = aligned_vec_complex(_fftComplexSize);
102
+ _inputBuffer.resize(_segSize);
103
+ _current = 0;
104
+
105
+ return true;
106
+ }
107
+
108
+ /// @brief Fast pairwise complex multiplication using ARM NEON intrinsics
109
+ /// @param ir Impulse response
110
+ /// @param audio Input audio signal
111
+ /// @param pre Output buffer for pre-multiplied results
112
+ /// @note IMPORTANT: ir, audio, and pre must be the same size and should be
113
+ /// aligned to 16 bytes for optimal performance
114
+ void pairwise_complex_multiply_fast(
115
+ const Convolver::aligned_vec_complex &ir,
116
+ const Convolver::aligned_vec_complex &audio,
117
+ Convolver::aligned_vec_complex &pre) {
118
+ size_t n = ir.size();
119
+
120
+ /// @note Using ARM NEON intrinsics for SIMD optimization
121
+ /// This implementation is on average 2x faster than the scalar version on ARM
122
+ /// architectures With 16-byte alignment it can be even faster up to 2.5x
123
+ #ifdef __ARM_NEON
124
+ size_t j = 0;
125
+
126
+ // Main vector loop: process 4 complex samples (8 floats) per iteration using
127
+ // vld2q/vst2q deinterleave
128
+ for (; j <= n - 4; j += 4) {
129
+ // load de-interleaved real/imag for 4 complex values
130
+ float32x4x2_t ir_de = vld2q_f32(reinterpret_cast<const float *>(&ir[j]));
131
+ float32x4x2_t a_de = vld2q_f32(reinterpret_cast<const float *>(&audio[j]));
132
+ float32x4x2_t pre_de = vld2q_f32(reinterpret_cast<float *>(&pre[j]));
133
+
134
+ float32x4_t ir_re = ir_de.val[0];
135
+ float32x4_t ir_im = ir_de.val[1];
136
+ float32x4_t a_re = a_de.val[0];
137
+ float32x4_t a_im = a_de.val[1];
138
+
139
+ // real = ir_re * a_re - ir_im * a_im
140
+ float32x4_t real = vmulq_f32(ir_re, a_re);
141
+ real = vmlsq_f32(real, ir_im, a_im);
142
+ // imag = ir_re * a_im + ir_im * a_re
143
+ float32x4_t imag = vmulq_f32(ir_re, a_im);
144
+ imag = vmlaq_f32(imag, ir_im, a_re);
145
+
146
+ // accumulate into pre
147
+ float32x4_t new_re = vaddq_f32(pre_de.val[0], real);
148
+ float32x4_t new_im = vaddq_f32(pre_de.val[1], imag);
149
+
150
+ float32x4x2_t out_de;
151
+ out_de.val[0] = new_re;
152
+ out_de.val[1] = new_im;
153
+
154
+ vst2q_f32(reinterpret_cast<float *>(&pre[j]), out_de);
155
+ }
156
+
157
+ // Tail
158
+ for (; j < n; ++j) {
159
+ pre[j] += ir[j] * audio[j];
160
+ }
161
+
162
+ #else
163
+ // Fallback scalar implementation
164
+ for (size_t i = 0; i < n; ++i) {
165
+ pre[i] += ir[i] * audio[i];
166
+ }
167
+ #endif
168
+ }
169
+
170
+ void Convolver::process(float *data, float *outputData) {
171
+ // The input buffer acts as a 2B-point sliding window of the input signal.
172
+ // With each new input block, the right half of the input buffer is shifted
173
+ // to the left and the new block is stored in the right half.
174
+ memmove(
175
+ _inputBuffer.getData(),
176
+ _inputBuffer.getData() + _blockSize,
177
+ _blockSize * sizeof(float));
178
+ memcpy(_inputBuffer.getData() + _blockSize, data, _blockSize * sizeof(float));
179
+
180
+ // All contents (DFT spectra) in the FDL are shifted up by one slot.
181
+ _current = (_current > 0) ? _current - 1 : _segCount - 1;
182
+ // A 2B-point real-to-complex FFT is computed from the input buffer,
183
+ // resulting in B+1 complex-conjugate symmetric DFT coefficients. The
184
+ // result is stored in the first FDL slot.
185
+ // _current marks first FDL slot, which is the current input block.
186
+ _fft->doFFT(_inputBuffer.getData(), _segments[_current]);
187
+ _segments[_current][0].imag(0.0f); // ensure DC component is real
188
+
189
+ // The P sub filter spectra are pairwisely multiplied with the input spectra
190
+ // in the FDL. The results are accumulated in the frequency-domain.
191
+ memset(
192
+ _preMultiplied.data(),
193
+ 0,
194
+ _preMultiplied.size() * sizeof(std::complex<float>));
195
+ // this is a bottleneck of the algorithm
196
+ for (int i = 0; i < _segCount; ++i) {
197
+ const int indexAudio = (_current + i) % _segCount;
198
+ const auto &impulseResponseSegment = _segmentsIR[i];
199
+ const auto &audioSegment = _segments[indexAudio];
200
+ pairwise_complex_multiply_fast(
201
+ impulseResponseSegment, audioSegment, _preMultiplied);
202
+ }
203
+ // Of the accumulated spectral convolutions, an 2B-point complex-to-real
204
+ // IFFT is computed. From the resulting 2B samples, the left half is
205
+ // discarded and the right half is returned as the next output block.
206
+ _fft->doInverseFFT(_preMultiplied, _fftBuffer.getData());
207
+
208
+ memcpy(
209
+ outputData,
210
+ _fftBuffer.getData() + _blockSize,
211
+ _blockSize * sizeof(float));
212
+ }
213
+ } // namespace audioapi
@@ -0,0 +1,45 @@
1
+ #pragma once
2
+
3
+ #include <audioapi/utils/AudioArray.h>
4
+ #include <audioapi/dsp/FFT.h>
5
+ #include <vector>
6
+ #include <cstring>
7
+ #include <complex>
8
+ #include <memory>
9
+ #include <audioapi/utils/AlignedAllocator.hpp>
10
+
11
+ namespace audioapi {
12
+
13
+ class AudioBuffer;
14
+
15
+ class Convolver {
16
+ using aligned_vec_complex =
17
+ std::vector<std::complex<float>, AlignedAllocator<std::complex<float>, 16>>;
18
+
19
+ public:
20
+ Convolver();
21
+ bool init(size_t blockSize, const AudioArray &ir, size_t irLen);
22
+ void process(float* inputData, float* outputData);
23
+ void reset();
24
+ inline size_t getSegCount() const { return _trueSegmentCount; }
25
+
26
+ private:
27
+ size_t _trueSegmentCount;
28
+ size_t _blockSize;
29
+ size_t _segSize;
30
+ size_t _segCount;
31
+ size_t _fftComplexSize;
32
+ std::vector<aligned_vec_complex> _segments;
33
+ std::vector<aligned_vec_complex> _segmentsIR;
34
+ AudioArray _fftBuffer;
35
+ std::shared_ptr<dsp::FFT> _fft;
36
+ aligned_vec_complex _preMultiplied;
37
+ size_t _current;
38
+ AudioArray _inputBuffer;
39
+
40
+ friend void pairwise_complex_multiply_fast(
41
+ const aligned_vec_complex& ir,
42
+ const aligned_vec_complex& audio,
43
+ aligned_vec_complex& pre);
44
+ };
45
+ } // namespace audioapi
@@ -12,30 +12,4 @@ FFT::~FFT() {
12
12
  pffft_aligned_free(work_);
13
13
  }
14
14
 
15
- void FFT::doFFT(float *in, std::vector<std::complex<float>> &out) {
16
- pffft_transform_ordered(
17
- pffftSetup_,
18
- in,
19
- reinterpret_cast<float *>(&out[0]),
20
- work_,
21
- PFFFT_FORWARD);
22
-
23
- dsp::multiplyByScalar(
24
- reinterpret_cast<float *>(&out[0]),
25
- 0.5f,
26
- reinterpret_cast<float *>(&out[0]),
27
- size_ * 2);
28
- }
29
-
30
- void FFT::doInverseFFT(std::vector<std::complex<float>> &in, float *out) {
31
- pffft_transform_ordered(
32
- pffftSetup_,
33
- reinterpret_cast<float *>(&in[0]),
34
- out,
35
- work_,
36
- PFFFT_BACKWARD);
37
-
38
- dsp::multiplyByScalar(out, 1.0f / static_cast<float>(size_), out, size_);
39
- }
40
-
41
15
  } // namespace audioapi::dsp
@@ -16,8 +16,32 @@ class FFT {
16
16
  explicit FFT(int size);
17
17
  ~FFT();
18
18
 
19
- void doFFT(float *in, std::vector<std::complex<float>> &out);
20
- void doInverseFFT(std::vector<std::complex<float>> &in, float *out);
19
+ template<typename Allocator>
20
+ void doFFT(float *in, std::vector<std::complex<float>, Allocator> &out) {
21
+ pffft_transform_ordered(
22
+ pffftSetup_,
23
+ in,
24
+ reinterpret_cast<float *>(&out[0]),
25
+ work_,
26
+ PFFFT_FORWARD);
27
+ // this is a possible place for bugs and mistakes
28
+ // due to pffft implementation and how it stores results
29
+ // keep this information in mind
30
+ // out[0].real = DC component - should be pure real
31
+ // out[0].imag = Nyquist component - should be pure real
32
+ }
33
+
34
+ template<typename Allocator>
35
+ void doInverseFFT(std::vector<std::complex<float>, Allocator> &in, float *out) {
36
+ pffft_transform_ordered(
37
+ pffftSetup_,
38
+ reinterpret_cast<float *>(&in[0]),
39
+ out,
40
+ work_,
41
+ PFFFT_BACKWARD);
42
+
43
+ dsp::multiplyByScalar(out, 1.0f / static_cast<float>(size_), out, size_);
44
+ }
21
45
 
22
46
  private:
23
47
  int size_;
@@ -20,7 +20,7 @@ class AudioEventHandlerRegistry : public IAudioEventHandlerRegistry {
20
20
  explicit AudioEventHandlerRegistry(
21
21
  jsi::Runtime *runtime,
22
22
  const std::shared_ptr<react::CallInvoker> &callInvoker);
23
- ~AudioEventHandlerRegistry();
23
+ ~AudioEventHandlerRegistry() override;
24
24
 
25
25
  uint64_t registerHandler(const std::string &eventName, const std::shared_ptr<jsi::Function> &handler) override;
26
26
  void unregisterHandler(const std::string &eventName, uint64_t listenerId) override;
@@ -225,7 +225,7 @@ typedef struct RcOverride{
225
225
  #define AV_CODEC_FLAG_QPEL (1 << 4)
226
226
  /**
227
227
  * Request the encoder to output reconstructed frames, i.e.\ frames that would
228
- * be produced by decoding the encoded bistream. These frames may be retrieved
228
+ * be produced by decoding the encoded bitstream. These frames may be retrieved
229
229
  * by calling avcodec_receive_frame() immediately after a successful call to
230
230
  * avcodec_receive_packet().
231
231
  *
@@ -436,7 +436,7 @@ typedef struct AVCodecContext {
436
436
  const AVClass *av_class;
437
437
  int log_level_offset;
438
438
 
439
- enum AVMediaTypeFFMPEG codec_type; /* see AVMEDIA_TYPE_xxx */
439
+ enum AVMediaTypeFFmpeg codec_type; /* see AVMEDIA_TYPE_xxx */
440
440
  const struct AVCodec *codec;
441
441
  enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
442
442
 
@@ -1946,7 +1946,7 @@ typedef struct AVHWAccel {
1946
1946
  *
1947
1947
  * See AVMEDIA_TYPE_xxx
1948
1948
  */
1949
- enum AVMediaTypeFFMPEG type;
1949
+ enum AVMediaTypeFFmpeg type;
1950
1950
 
1951
1951
  /**
1952
1952
  * Codec implemented by the hardware accelerator.
@@ -2900,7 +2900,7 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
2900
2900
  *
2901
2901
  * @note for encoders, this function will only do something if the encoder
2902
2902
  * declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder
2903
- * will drain any remaining packets, and can then be re-used for a different
2903
+ * will drain any remaining packets, and can then be reused for a different
2904
2904
  * stream (as opposed to sending a null frame which will leave the encoder
2905
2905
  * in a permanent EOF state after draining). This can be desirable if the
2906
2906
  * cost of tearing down and replacing the encoder instance is high.
@@ -182,7 +182,7 @@ typedef struct AVCodec {
182
182
  * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
183
183
  */
184
184
  const char *long_name;
185
- enum AVMediaTypeFFMPEG type;
185
+ enum AVMediaTypeFFmpeg type;
186
186
  enum AVCodecID id;
187
187
  /**
188
188
  * Codec capabilities.
@@ -37,7 +37,7 @@
37
37
  */
38
38
  typedef struct AVCodecDescriptor {
39
39
  enum AVCodecID id;
40
- enum AVMediaTypeFFMPEG type;
40
+ enum AVMediaTypeFFmpeg type;
41
41
  /**
42
42
  * Name of the codec described by this descriptor. It is non-empty and
43
43
  * unique for each codec descriptor. It should contain alphanumeric
@@ -330,6 +330,7 @@ enum AVCodecID {
330
330
  AV_CODEC_ID_RV60,
331
331
  AV_CODEC_ID_JPEGXL_ANIM,
332
332
  AV_CODEC_ID_APV,
333
+ AV_CODEC_ID_PRORES_RAW,
333
334
 
334
335
  /* various PCM "codecs" */
335
336
  AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
@@ -602,6 +603,7 @@ enum AVCodecID {
602
603
  AV_CODEC_ID_BIN_DATA,
603
604
  AV_CODEC_ID_SMPTE_2038,
604
605
  AV_CODEC_ID_LCEVC,
606
+ AV_CODEC_ID_SMPTE_436M_ANC,
605
607
 
606
608
 
607
609
  AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
@@ -627,7 +629,7 @@ enum AVCodecID {
627
629
  /**
628
630
  * Get the type of the given codec.
629
631
  */
630
- enum AVMediaTypeFFMPEG avcodec_get_type(enum AVCodecID codec_id);
632
+ enum AVMediaTypeFFmpeg avcodec_get_type(enum AVCodecID codec_id);
631
633
 
632
634
  /**
633
635
  * Get the name of a codec.
@@ -48,7 +48,7 @@ typedef struct AVCodecParameters {
48
48
  /**
49
49
  * General type of the encoded data.
50
50
  */
51
- enum AVMediaTypeFFMPEG codec_type;
51
+ enum AVMediaTypeFFmpeg codec_type;
52
52
  /**
53
53
  * Specific type of the encoded data (the codec used).
54
54
  */
@@ -148,7 +148,7 @@ typedef struct AVCodecParameters {
148
148
  * durations. Should be set to { 0, 1 } when some frames have differing
149
149
  * durations or if the value is not known.
150
150
  *
151
- * @note This field correponds to values that are stored in codec-level
151
+ * @note This field corresponds to values that are stored in codec-level
152
152
  * headers and is typically overridden by container/transport-layer
153
153
  * timestamps, when available. It should thus be used only as a last resort,
154
154
  * when no higher-level timing information is available.
@@ -185,6 +185,9 @@
185
185
  #define AV_PROFILE_PRORES_4444 4
186
186
  #define AV_PROFILE_PRORES_XQ 5
187
187
 
188
+ #define AV_PROFILE_PRORES_RAW 0
189
+ #define AV_PROFILE_PRORES_RAW_HQ 1
190
+
188
191
  #define AV_PROFILE_ARIB_PROFILE_A 0
189
192
  #define AV_PROFILE_ARIB_PROFILE_C 1
190
193
 
@@ -142,7 +142,7 @@ enum AVPacketSideDataType {
142
142
  AV_PKT_DATA_CPB_PROPERTIES,
143
143
 
144
144
  /**
145
- * Recommmends skipping the specified number of samples
145
+ * Recommends skipping the specified number of samples
146
146
  * @code
147
147
  * u32le number of samples to skip from start of this packet
148
148
  * u32le number of samples to skip from end of this packet