react-native-audio-api 0.10.0-nightly-e16d7ff-20251030 → 0.11.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/RNAudioAPI.podspec +11 -16
  2. package/android/build.gradle +3 -33
  3. package/android/src/main/cpp/audioapi/CMakeLists.txt +0 -6
  4. package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +0 -5
  5. package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +0 -1
  6. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +142 -28
  7. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +40 -13
  8. package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +2 -4
  9. package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
  10. package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +37 -0
  11. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +187 -0
  12. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +57 -0
  13. package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +0 -6
  14. package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +34 -0
  15. package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +133 -0
  16. package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +3 -0
  17. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +154 -0
  18. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +41 -0
  19. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +429 -0
  20. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +113 -0
  21. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +47 -0
  22. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +28 -0
  23. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +269 -0
  24. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +47 -0
  25. package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +31 -0
  26. package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +3 -29
  27. package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +9 -21
  28. package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +6 -27
  29. package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +0 -11
  30. package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +18 -0
  31. package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
  32. package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
  33. package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
  34. package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
  35. package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
  36. package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
  37. package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
  38. package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
  39. package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
  40. package/android/src/main/jniLibs/x86/libavformat.so +0 -0
  41. package/android/src/main/jniLibs/x86/libavutil.so +0 -0
  42. package/android/src/main/jniLibs/x86/libswresample.so +0 -0
  43. package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
  44. package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
  45. package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
  46. package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
  47. package/common/cpp/audioapi/AudioAPIModuleInstaller.h +2 -30
  48. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +0 -18
  49. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +0 -1
  50. package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
  51. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +97 -18
  52. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +18 -6
  53. package/common/cpp/audioapi/core/AudioNode.h +2 -3
  54. package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
  55. package/common/cpp/audioapi/core/BaseAudioContext.cpp +0 -10
  56. package/common/cpp/audioapi/core/BaseAudioContext.h +0 -2
  57. package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +32 -69
  58. package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +1 -37
  59. package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +36 -82
  60. package/common/cpp/audioapi/core/inputs/AudioRecorder.h +52 -31
  61. package/common/cpp/audioapi/core/sources/StreamerNode.cpp +58 -59
  62. package/common/cpp/audioapi/core/sources/StreamerNode.h +8 -37
  63. package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +0 -5
  64. package/common/cpp/audioapi/core/utils/Constants.h +1 -2
  65. package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +10 -0
  66. package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
  67. package/common/cpp/audioapi/dsp/FFT.cpp +26 -0
  68. package/common/cpp/audioapi/dsp/FFT.h +2 -26
  69. package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
  70. package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
  71. package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
  72. package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
  73. package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
  74. package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
  75. package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
  76. package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
  77. package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
  78. package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
  79. package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
  80. package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
  81. package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
  82. package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
  83. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
  84. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
  85. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +2 -2
  86. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +1 -1
  87. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +1 -1
  88. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +1 -1
  89. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +1 -1
  90. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +2 -2
  91. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
  92. package/common/cpp/audioapi/external/iphoneos/libcrypto.a +0 -0
  93. package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
  94. package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
  95. package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
  96. package/common/cpp/audioapi/external/iphoneos/libssl.a +0 -0
  97. package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
  98. package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
  99. package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
  100. package/common/cpp/audioapi/external/iphonesimulator/libcrypto.a +0 -0
  101. package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
  102. package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
  103. package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
  104. package/common/cpp/audioapi/external/iphonesimulator/libssl.a +0 -0
  105. package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
  106. package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
  107. package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
  108. package/common/cpp/audioapi/external/libavcodec.xcframework/Info.plist +44 -0
  109. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +1 -0
  110. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
  111. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/Info.plist +1 -0
  112. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
  113. package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +44 -0
  114. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +1 -0
  115. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
  116. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/Info.plist +1 -0
  117. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
  118. package/common/cpp/audioapi/external/libavutil.xcframework/Info.plist +44 -0
  119. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +1 -0
  120. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
  121. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/Info.plist +1 -0
  122. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
  123. package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +44 -0
  124. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +1 -0
  125. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
  126. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/Info.plist +1 -0
  127. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
  128. package/common/cpp/audioapi/external/x86/libcrypto.a +0 -0
  129. package/common/cpp/audioapi/external/x86/libogg.a +0 -0
  130. package/common/cpp/audioapi/external/x86/libopus.a +0 -0
  131. package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
  132. package/common/cpp/audioapi/external/x86/libssl.a +0 -0
  133. package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
  134. package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
  135. package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
  136. package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
  137. package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
  138. package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
  139. package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
  140. package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
  141. package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
  142. package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
  143. package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
  144. package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +3 -2
  145. package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +32 -0
  146. package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +111 -0
  147. package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +391 -0
  148. package/common/cpp/audioapi/utils/AudioBus.cpp +0 -28
  149. package/common/cpp/audioapi/utils/AudioBus.h +0 -3
  150. package/common/cpp/audioapi/utils/ThreadPool.hpp +1 -59
  151. package/common/cpp/test/CMakeLists.txt +14 -19
  152. package/ios/audioapi/ios/AudioAPIModule.h +1 -2
  153. package/ios/audioapi/ios/AudioAPIModule.mm +0 -2
  154. package/ios/audioapi/ios/core/IOSAudioFileOptions.h +36 -0
  155. package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +140 -0
  156. package/ios/audioapi/ios/core/IOSAudioFileWriter.h +51 -0
  157. package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +223 -0
  158. package/ios/audioapi/ios/core/IOSAudioRecorder.h +28 -10
  159. package/ios/audioapi/ios/core/IOSAudioRecorder.mm +117 -30
  160. package/ios/audioapi/ios/core/IOSRecorderCallback.h +57 -0
  161. package/ios/audioapi/ios/core/IOSRecorderCallback.mm +189 -0
  162. package/ios/audioapi/ios/core/NativeAudioRecorder.h +4 -9
  163. package/ios/audioapi/ios/core/NativeAudioRecorder.m +29 -71
  164. package/ios/audioapi/ios/core/utils/AudioDecoder.mm +1 -0
  165. package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
  166. package/ios/audioapi/ios/system/AudioSessionManager.mm +0 -9
  167. package/ios/audioapi/ios/system/LockScreenManager.h +1 -0
  168. package/ios/audioapi/ios/system/LockScreenManager.mm +19 -6
  169. package/lib/commonjs/api.js +76 -141
  170. package/lib/commonjs/api.js.map +1 -1
  171. package/lib/commonjs/api.web.js +0 -8
  172. package/lib/commonjs/api.web.js.map +1 -1
  173. package/lib/commonjs/core/AudioContext.js +1 -1
  174. package/lib/commonjs/core/AudioContext.js.map +1 -1
  175. package/lib/commonjs/core/AudioRecorder.js +171 -13
  176. package/lib/commonjs/core/AudioRecorder.js.map +1 -1
  177. package/lib/commonjs/core/BaseAudioContext.js +25 -28
  178. package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
  179. package/lib/commonjs/core/OfflineAudioContext.js +1 -1
  180. package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
  181. package/lib/commonjs/types.js +46 -0
  182. package/lib/commonjs/types.js.map +1 -1
  183. package/lib/commonjs/utils/bitEnums.js +33 -0
  184. package/lib/commonjs/utils/bitEnums.js.map +1 -0
  185. package/lib/commonjs/utils/index.js +21 -19
  186. package/lib/commonjs/utils/index.js.map +1 -1
  187. package/lib/commonjs/web-core/AudioContext.js +0 -12
  188. package/lib/commonjs/web-core/AudioContext.js.map +1 -1
  189. package/lib/commonjs/web-core/OfflineAudioContext.js +0 -12
  190. package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
  191. package/lib/module/api.js +15 -16
  192. package/lib/module/api.js.map +1 -1
  193. package/lib/module/api.web.js +0 -1
  194. package/lib/module/api.web.js.map +1 -1
  195. package/lib/module/core/AudioContext.js +2 -2
  196. package/lib/module/core/AudioContext.js.map +1 -1
  197. package/lib/module/core/AudioRecorder.js +171 -13
  198. package/lib/module/core/AudioRecorder.js.map +1 -1
  199. package/lib/module/core/BaseAudioContext.js +26 -29
  200. package/lib/module/core/BaseAudioContext.js.map +1 -1
  201. package/lib/module/core/OfflineAudioContext.js +2 -2
  202. package/lib/module/core/OfflineAudioContext.js.map +1 -1
  203. package/lib/module/types.js +45 -1
  204. package/lib/module/types.js.map +1 -1
  205. package/lib/module/utils/bitEnums.js +27 -0
  206. package/lib/module/utils/bitEnums.js.map +1 -0
  207. package/lib/module/utils/index.js +2 -15
  208. package/lib/module/utils/index.js.map +1 -1
  209. package/lib/module/web-core/AudioContext.js +0 -12
  210. package/lib/module/web-core/AudioContext.js.map +1 -1
  211. package/lib/module/web-core/OfflineAudioContext.js +0 -12
  212. package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
  213. package/lib/typescript/api.d.ts +17 -19
  214. package/lib/typescript/api.d.ts.map +1 -1
  215. package/lib/typescript/api.web.d.ts +0 -1
  216. package/lib/typescript/api.web.d.ts.map +1 -1
  217. package/lib/typescript/core/AudioContext.d.ts.map +1 -1
  218. package/lib/typescript/core/AudioRecorder.d.ts +62 -7
  219. package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
  220. package/lib/typescript/core/BaseAudioContext.d.ts +1 -3
  221. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
  222. package/lib/typescript/events/types.d.ts +16 -0
  223. package/lib/typescript/events/types.d.ts.map +1 -1
  224. package/lib/typescript/interfaces.d.ts +42 -9
  225. package/lib/typescript/interfaces.d.ts.map +1 -1
  226. package/lib/typescript/types.d.ts +79 -8
  227. package/lib/typescript/types.d.ts.map +1 -1
  228. package/lib/typescript/utils/bitEnums.d.ts +4 -0
  229. package/lib/typescript/utils/bitEnums.d.ts.map +1 -0
  230. package/lib/typescript/utils/index.d.ts +2 -5
  231. package/lib/typescript/utils/index.d.ts.map +1 -1
  232. package/lib/typescript/web-core/AudioContext.d.ts +0 -3
  233. package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
  234. package/lib/typescript/web-core/BaseAudioContext.d.ts +0 -2
  235. package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
  236. package/lib/typescript/web-core/OfflineAudioContext.d.ts +0 -3
  237. package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
  238. package/package.json +4 -7
  239. package/src/api.ts +18 -45
  240. package/src/api.web.ts +0 -1
  241. package/src/core/AudioContext.ts +2 -3
  242. package/src/core/AudioRecorder.ts +211 -24
  243. package/src/core/BaseAudioContext.ts +60 -67
  244. package/src/core/OfflineAudioContext.ts +2 -2
  245. package/src/events/types.ts +18 -0
  246. package/src/interfaces.ts +52 -16
  247. package/src/types.ts +90 -9
  248. package/src/utils/bitEnums.ts +51 -0
  249. package/src/utils/index.ts +2 -22
  250. package/src/web-core/AudioContext.tsx +0 -25
  251. package/src/web-core/BaseAudioContext.tsx +0 -2
  252. package/src/web-core/OfflineAudioContext.tsx +0 -25
  253. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +0 -47
  254. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +0 -20
  255. package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +0 -210
  256. package/common/cpp/audioapi/core/effects/ConvolverNode.h +0 -55
  257. package/common/cpp/audioapi/dsp/Convolver.cpp +0 -213
  258. package/common/cpp/audioapi/dsp/Convolver.h +0 -45
  259. package/common/cpp/audioapi/libs/ffmpeg/relinking.md +0 -24
  260. package/common/cpp/audioapi/utils/AlignedAllocator.hpp +0 -50
  261. package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +0 -389
  262. package/common/cpp/test/src/biquad/BiquadFilterChromium.h +0 -64
  263. package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +0 -284
  264. package/common/cpp/test/src/biquad/BiquadFilterTest.h +0 -40
  265. package/lib/commonjs/core/ConvolverNode.js +0 -37
  266. package/lib/commonjs/core/ConvolverNode.js.map +0 -1
  267. package/lib/commonjs/web-core/ConvolverNode.js +0 -40
  268. package/lib/commonjs/web-core/ConvolverNode.js.map +0 -1
  269. package/lib/commonjs/web-core/ConvolverNodeOptions.js +0 -6
  270. package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +0 -1
  271. package/lib/module/core/ConvolverNode.js +0 -31
  272. package/lib/module/core/ConvolverNode.js.map +0 -1
  273. package/lib/module/web-core/ConvolverNode.js +0 -34
  274. package/lib/module/web-core/ConvolverNode.js.map +0 -1
  275. package/lib/module/web-core/ConvolverNodeOptions.js +0 -4
  276. package/lib/module/web-core/ConvolverNodeOptions.js.map +0 -1
  277. package/lib/typescript/core/ConvolverNode.d.ts +0 -12
  278. package/lib/typescript/core/ConvolverNode.d.ts.map +0 -1
  279. package/lib/typescript/web-core/ConvolverNode.d.ts +0 -11
  280. package/lib/typescript/web-core/ConvolverNode.d.ts.map +0 -1
  281. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +0 -6
  282. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +0 -1
  283. package/scripts/download-prebuilt-binaries.sh +0 -52
  284. package/scripts/rnaa_utils.rb +0 -8
  285. package/scripts/validate-worklets-version.js +0 -28
  286. package/src/core/ConvolverNode.ts +0 -35
  287. package/src/web-core/ConvolverNode.tsx +0 -43
  288. package/src/web-core/ConvolverNodeOptions.tsx +0 -6
@@ -1,82 +1,36 @@
1
- #include <audioapi/HostObjects/sources/AudioBufferHostObject.h>
2
- #include <audioapi/core/inputs/AudioRecorder.h>
3
- #include <audioapi/core/sources/AudioBuffer.h>
4
- #include <audioapi/core/sources/RecorderAdapterNode.h>
5
- #include <audioapi/events/AudioEventHandlerRegistry.h>
6
- #include <audioapi/utils/AudioBus.h>
7
- #include <audioapi/utils/CircularAudioArray.h>
8
- #include <audioapi/utils/CircularOverflowableAudioArray.h>
9
-
10
- namespace audioapi {
11
-
12
- AudioRecorder::AudioRecorder(
13
- float sampleRate,
14
- int bufferLength,
15
- const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry)
16
- : sampleRate_(sampleRate),
17
- bufferLength_(bufferLength),
18
- audioEventHandlerRegistry_(audioEventHandlerRegistry) {
19
- constexpr int minRingBufferSize = 8192;
20
- ringBufferSize_ = std::max(2 * bufferLength, minRingBufferSize);
21
- circularBuffer_ = std::make_shared<CircularAudioArray>(ringBufferSize_);
22
- isRunning_.store(false);
23
- }
24
-
25
- void AudioRecorder::setOnAudioReadyCallbackId(uint64_t callbackId) {
26
- onAudioReadyCallbackId_ = callbackId;
27
- }
28
-
29
- void AudioRecorder::invokeOnAudioReadyCallback(
30
- const std::shared_ptr<AudioBus> &bus,
31
- int numFrames) {
32
- auto audioBuffer = std::make_shared<AudioBuffer>(bus);
33
- auto audioBufferHostObject =
34
- std::make_shared<AudioBufferHostObject>(audioBuffer);
35
-
36
- std::unordered_map<std::string, EventValue> body = {};
37
- body.insert({"buffer", audioBufferHostObject});
38
- body.insert({"numFrames", numFrames});
39
-
40
- if (audioEventHandlerRegistry_ != nullptr) {
41
- audioEventHandlerRegistry_->invokeHandlerWithEventBody(
42
- "audioReady", onAudioReadyCallbackId_, body);
43
- }
44
- }
45
-
46
- void AudioRecorder::sendRemainingData() {
47
- auto bus = std::make_shared<AudioBus>(
48
- circularBuffer_->getNumberOfAvailableFrames(), 1, sampleRate_);
49
- auto *outputChannel = bus->getChannel(0)->getData();
50
- auto availableFrames =
51
- static_cast<int>(circularBuffer_->getNumberOfAvailableFrames());
52
-
53
- circularBuffer_->pop_front(
54
- outputChannel, circularBuffer_->getNumberOfAvailableFrames());
55
-
56
- invokeOnAudioReadyCallback(bus, availableFrames);
57
- }
58
-
59
- void AudioRecorder::connect(const std::shared_ptr<RecorderAdapterNode> &node) {
60
- node->init(ringBufferSize_);
61
- adapterNodeLock_.lock();
62
- adapterNode_ = node;
63
- adapterNodeLock_.unlock();
64
- }
65
-
66
- void AudioRecorder::disconnect() {
67
- adapterNodeLock_.lock();
68
- adapterNode_ = nullptr;
69
- adapterNodeLock_.unlock();
70
- }
71
-
72
- void AudioRecorder::writeToBuffers(const float *data, int numFrames) {
73
- if (adapterNodeLock_.try_lock()) {
74
- if (adapterNode_ != nullptr) {
75
- adapterNode_->buff_->write(data, numFrames);
76
- }
77
- adapterNodeLock_.unlock();
78
- }
79
- circularBuffer_->push_back(data, numFrames);
80
- }
81
-
82
- } // namespace audioapi
1
+ // void AudioRecorder::connect(const std::shared_ptr<RecorderAdapterNode> &node)
2
+ // { node->init(); adapterNodeLock_.lock(); adapterNode_ = node;
3
+ // adapterNodeLock_.unlock();
4
+ // isConnected_.store(true);
5
+ // node->init(ringBufferSize_);
6
+ // adapterNodeLock_.lock();
7
+ // adapterNode_ = node;
8
+ // adapterNodeLock_.unlock();
9
+ // }
10
+
11
+ // void AudioRecorder::disconnect() {
12
+ // adapterNodeLock_.lock();
13
+ // adapterNode_ = nullptr;
14
+ // adapterNodeLock_.unlock();
15
+ // isConnected_.store(false);
16
+ // }
17
+
18
+ // AudioRecorder::AudioRecorder(
19
+ // const std::shared_ptr<AudioEventHandlerRegistry>
20
+ // &audioEventHandlerRegistry)
21
+ // audioEventHandlerRegistry_(audioEventHandlerRegistry) {
22
+ // constexpr int minRingBufferSize = 8192;
23
+ // ringBufferSize_ = std::max(2 * bufferLength, minRingBufferSize);
24
+
25
+ // circularBuffer_ = std::make_shared<CircularAudioArray>(ringBufferSize_);
26
+ // state_.store(RecorderState::Idle);
27
+ // }
28
+
29
+ // void AudioRecorder::writeToBuffers(const float *data, int numFrames) {
30
+ // if (adapterNodeLock_.try_lock()) {
31
+ // if (adapterNode_ != nullptr) {
32
+ // adapterNode_->buff_->write(data, numFrames);
33
+ // }
34
+ // adapterNodeLock_.unlock();
35
+ // }
36
+ // }
@@ -3,61 +3,82 @@
3
3
  #include <memory>
4
4
  #include <atomic>
5
5
  #include <mutex>
6
+ #include <string>
7
+ #include <tuple>
6
8
 
7
9
  namespace audioapi {
8
10
 
9
11
  class RecorderAdapterNode;
10
12
  class AudioBus;
11
13
  class CircularAudioArray;
12
- class CircularOverflowableAudioArray;
13
14
  class AudioEventHandlerRegistry;
14
15
 
15
16
  class AudioRecorder {
16
17
  public:
17
- explicit AudioRecorder(
18
+ enum RecorderState { Idle, Recording, Paused };
19
+ explicit AudioRecorder(const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry):
20
+ audioEventHandlerRegistry_(audioEventHandlerRegistry) {}
21
+ virtual ~AudioRecorder() = default;
22
+
23
+ virtual std::string start() = 0;
24
+ virtual std::tuple<std::string, double, double> stop() = 0;
25
+
26
+ virtual void enableFileOutput(
18
27
  float sampleRate,
19
- int bufferLength,
20
- const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry
21
- );
28
+ size_t channelCount,
29
+ size_t bitRate,
30
+ size_t iosFlags,
31
+ size_t androidFlags) = 0;
32
+ virtual void disableFileOutput() = 0;
22
33
 
23
- virtual ~AudioRecorder() = default;
34
+ virtual void pause() = 0;
35
+ virtual void resume() = 0;
36
+
37
+ void connect(const std::shared_ptr<RecorderAdapterNode> &node) {}
38
+ void disconnect() {}
24
39
 
25
- void setOnAudioReadyCallbackId(uint64_t callbackId);
26
- void invokeOnAudioReadyCallback(const std::shared_ptr<AudioBus> &bus, int numFrames);
27
- void sendRemainingData();
40
+ virtual void setOnAudioReadyCallback(
41
+ float sampleRate,
42
+ size_t bufferLength,
43
+ size_t channelCount,
44
+ uint64_t callbackId) = 0;
45
+ virtual void clearOnAudioReadyCallback() = 0;
46
+
47
+ virtual double getCurrentDuration() const = 0;
48
+
49
+ bool usesCallback() const {
50
+ return callbackOutputEnabled_.load();
51
+ }
28
52
 
29
- /// @brief
30
- /// # Connects the recorder to the adapter node.
31
- ///
32
- /// The adapter node will be used to read audio data from the recorder.
33
- /// @note Few frames of audio might not yet be written to the buffer when connecting.
34
- void connect(const std::shared_ptr<RecorderAdapterNode> &node);
53
+ bool usesFileOutput() const {
54
+ return fileOutputEnabled_.load();
55
+ }
35
56
 
36
- /// @brief
37
- /// # Disconnects the recorder from the adapter node.
38
- ///
39
- /// The adapter node will no longer be used to read audio data from the recorder.
40
- /// @note Last few frames of audio might be written to the buffer after disconnecting.
41
- void disconnect();
57
+ bool isConnected() const {
58
+ return isConnected_.load();
59
+ }
42
60
 
43
- virtual void start() = 0;
44
- virtual void stop() = 0;
61
+ bool isRecording() const {
62
+ return state_.load() == RecorderState::Recording;
63
+ }
64
+
65
+ bool isPaused() const {
66
+ return state_.load() == RecorderState::Paused;
67
+ }
45
68
 
46
69
  protected:
47
- float sampleRate_;
48
- int bufferLength_;
49
- size_t ringBufferSize_;
70
+ // size_t ringBufferSize_;
50
71
 
51
- std::atomic<bool> isRunning_;
52
- std::shared_ptr<CircularAudioArray> circularBuffer_;
72
+ std::atomic<RecorderState> state_{ RecorderState::Idle };
73
+ std::atomic<bool> fileOutputEnabled_{false};
74
+ std::atomic<bool> callbackOutputEnabled_{false};
75
+ std::atomic<bool> isConnected_{false};
76
+ // std::shared_ptr<CircularAudioArray> circularBuffer_;
53
77
 
54
78
  mutable std::mutex adapterNodeLock_;
55
79
  std::shared_ptr<RecorderAdapterNode> adapterNode_ = nullptr;
56
80
 
57
81
  std::shared_ptr<AudioEventHandlerRegistry> audioEventHandlerRegistry_;
58
- uint64_t onAudioReadyCallbackId_ = 0;
59
-
60
- void writeToBuffers(const float *data, int numFrames);
61
82
  };
62
83
 
63
84
  } // namespace audioapi
@@ -25,12 +25,14 @@ StreamerNode::StreamerNode(BaseAudioContext *context)
25
25
  codecpar_(nullptr),
26
26
  pkt_(nullptr),
27
27
  frame_(nullptr),
28
+ pendingFrame_(nullptr),
28
29
  bufferedBus_(nullptr),
30
+ bufferedBusIndex_(0),
31
+ maxBufferSize_(0),
29
32
  audio_stream_index_(-1),
30
33
  swrCtx_(nullptr),
31
34
  resampledData_(nullptr),
32
- maxResampledSamples_(0),
33
- processedSamples_(0) {}
35
+ maxResampledSamples_(0) {}
34
36
 
35
37
  StreamerNode::~StreamerNode() {
36
38
  cleanup();
@@ -64,30 +66,24 @@ bool StreamerNode::initialize(const std::string &input_url) {
64
66
  return false;
65
67
  }
66
68
 
69
+ maxBufferSize_ = BUFFER_LENGTH_SECONDS * codecCtx_->sample_rate;
70
+ // If decoding is faster than playing, we buffer few seconds of audio
71
+ bufferedBus_ = std::make_shared<AudioBus>(
72
+ maxBufferSize_, codecpar_->ch_layout.nb_channels, codecCtx_->sample_rate);
73
+
67
74
  channelCount_ = codecpar_->ch_layout.nb_channels;
68
75
  audioBus_ = std::make_shared<AudioBus>(
69
76
  RENDER_QUANTUM_SIZE, channelCount_, context_->getSampleRate());
70
77
 
71
- auto [sender, receiver] = channels::spsc::channel<
72
- StreamingData,
73
- channels::spsc::OverflowStrategy::WAIT_ON_FULL,
74
- channels::spsc::WaitStrategy::ATOMIC_WAIT>(CHANNEL_CAPACITY);
75
- sender_ = std::move(sender);
76
- receiver_ = std::move(receiver);
77
-
78
78
  streamingThread_ = std::thread(&StreamerNode::streamAudio, this);
79
- streamFlag.store(true, std::memory_order_release);
79
+ streamFlag.store(true);
80
80
  isInitialized_ = true;
81
81
  return true;
82
82
  }
83
83
 
84
84
  void StreamerNode::stop(double when) {
85
85
  AudioScheduledSourceNode::stop(when);
86
- streamFlag.store(false, std::memory_order_release);
87
- StreamingData dummy;
88
- while (receiver_.try_receive(dummy) ==
89
- channels::spsc::ResponseStatus::SUCCESS)
90
- ; // clear the receiver
86
+ streamFlag.store(false);
91
87
  }
92
88
 
93
89
  bool StreamerNode::setupResampler() {
@@ -126,22 +122,29 @@ bool StreamerNode::setupResampler() {
126
122
  }
127
123
 
128
124
  void StreamerNode::streamAudio() {
129
- while (streamFlag.load(std::memory_order_acquire)) {
130
- if (av_read_frame(fmtCtx_, pkt_) < 0) {
131
- return;
132
- }
133
- if (pkt_->stream_index == audio_stream_index_) {
134
- if (avcodec_send_packet(codecCtx_, pkt_) != 0) {
125
+ while (streamFlag.load()) {
126
+ if (pendingFrame_ != nullptr) {
127
+ if (!processFrameWithResampler(pendingFrame_)) {
135
128
  return;
136
129
  }
137
- if (avcodec_receive_frame(codecCtx_, frame_) != 0) {
130
+ } else {
131
+ if (av_read_frame(fmtCtx_, pkt_) < 0) {
138
132
  return;
139
133
  }
140
- if (!processFrameWithResampler(frame_)) {
141
- return;
134
+ if (pkt_->stream_index == audio_stream_index_) {
135
+ if (avcodec_send_packet(codecCtx_, pkt_) != 0) {
136
+ return;
137
+ }
138
+ if (avcodec_receive_frame(codecCtx_, frame_) != 0) {
139
+ return;
140
+ }
141
+ if (!processFrameWithResampler(frame_)) {
142
+ return;
143
+ }
142
144
  }
145
+ av_packet_unref(pkt_);
143
146
  }
144
- av_packet_unref(pkt_);
147
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
145
148
  }
146
149
  }
147
150
 
@@ -157,33 +160,28 @@ std::shared_ptr<AudioBus> StreamerNode::processNode(
157
160
  return processingBus;
158
161
  }
159
162
 
160
- int bufferRemaining = bufferedBusSize_ - processedSamples_;
161
- int alreadyProcessed = 0;
162
- if (bufferRemaining < framesToProcess) {
163
- if (bufferedBus_ != nullptr) {
164
- for (int ch = 0; ch < processingBus->getNumberOfChannels(); ch++) {
165
- memcpy(
166
- processingBus->getChannel(ch)->getData(),
167
- bufferedBus_->getChannel(ch)->getData() + processedSamples_,
168
- bufferRemaining * sizeof(float));
169
- }
170
- framesToProcess -= bufferRemaining;
171
- alreadyProcessed += bufferRemaining;
172
- }
173
- StreamingData data;
174
- receiver_.try_receive(data);
175
- bufferedBus_ = std::make_shared<AudioBus>(std::move(data.bus));
176
- bufferedBusSize_ = data.size;
177
- processedSamples_ = 0;
178
- }
179
- if (bufferedBus_ != nullptr) {
163
+ // If we have enough buffered data, copy to output bus
164
+ if (bufferedBusIndex_ >= framesToProcess) {
165
+ Locker locker(mutex_);
180
166
  for (int ch = 0; ch < processingBus->getNumberOfChannels(); ch++) {
181
167
  memcpy(
182
- processingBus->getChannel(ch)->getData() + alreadyProcessed,
183
- bufferedBus_->getChannel(ch)->getData() + processedSamples_,
184
- framesToProcess * sizeof(float));
168
+ processingBus->getChannel(ch)->getData(),
169
+ bufferedBus_->getChannel(ch)->getData(),
170
+ offsetLength * sizeof(float));
171
+
172
+ memmove(
173
+ bufferedBus_->getChannel(ch)->getData(),
174
+ bufferedBus_->getChannel(ch)->getData() + offsetLength,
175
+ (maxBufferSize_ - offsetLength) * sizeof(float));
185
176
  }
186
- processedSamples_ += framesToProcess;
177
+ bufferedBusIndex_ -= offsetLength;
178
+ } else {
179
+ if (VERBOSE)
180
+ printf(
181
+ "Buffer underrun: have %zu, need %zu\n",
182
+ bufferedBusIndex_,
183
+ (size_t)framesToProcess);
184
+ processingBus->zero();
187
185
  }
188
186
 
189
187
  return processingBus;
@@ -222,21 +220,22 @@ bool StreamerNode::processFrameWithResampler(AVFrame *frame) {
222
220
  return false;
223
221
  }
224
222
 
225
- // if we would like to finish dont copy anything
226
- if (!streamFlag.load(std::memory_order_acquire)) {
223
+ // Check if converted data fits in buffer
224
+ if (bufferedBusIndex_ + converted_samples > maxBufferSize_) {
225
+ pendingFrame_ = frame;
227
226
  return true;
227
+ } else {
228
+ pendingFrame_ = nullptr;
228
229
  }
229
- auto bus = AudioBus(
230
- static_cast<size_t>(converted_samples),
231
- codecCtx_->ch_layout.nb_channels,
232
- context_->getSampleRate());
230
+
231
+ // Copy converted data to our buffer
232
+ Locker locker(mutex_);
233
233
  for (int ch = 0; ch < codecCtx_->ch_layout.nb_channels; ch++) {
234
234
  auto *src = reinterpret_cast<float *>(resampledData_[ch]);
235
- float *dst = bus.getChannel(ch)->getData();
235
+ float *dst = bufferedBus_->getChannel(ch)->getData() + bufferedBusIndex_;
236
236
  memcpy(dst, src, converted_samples * sizeof(float));
237
237
  }
238
- StreamingData data{std::move(bus), static_cast<size_t>(converted_samples)};
239
- sender_.send(std::move(data));
238
+ bufferedBusIndex_ += converted_samples;
240
239
  return true;
241
240
  }
242
241
 
@@ -281,7 +280,7 @@ bool StreamerNode::setupDecoder() {
281
280
  }
282
281
 
283
282
  void StreamerNode::cleanup() {
284
- streamFlag.store(false, std::memory_order_release);
283
+ streamFlag.store(false);
285
284
  // cleanup cannot be called from the streaming thread so there is no need to
286
285
  // check if we are in the same thread
287
286
  streamingThread_.join();
@@ -11,7 +11,6 @@
11
11
  #pragma once
12
12
 
13
13
  #include <audioapi/core/sources/AudioScheduledSourceNode.h>
14
- #include <audioapi/utils/AudioBus.h>
15
14
 
16
15
  #ifndef AUDIO_API_TEST_SUITE
17
16
  extern "C" {
@@ -28,35 +27,8 @@ extern "C" {
28
27
  #include <memory>
29
28
  #include <string>
30
29
  #include <atomic>
31
- #include <utility>
32
- #ifndef AUDIO_API_TEST_SUITE
33
- #include <audioapi/utils/SpscChannel.hpp>
34
30
 
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
- };
31
+ static bool constexpr VERBOSE = false;
60
32
 
61
33
  namespace audioapi {
62
34
 
@@ -84,20 +56,19 @@ class StreamerNode : public AudioScheduledSourceNode {
84
56
  AVCodecParameters* codecpar_;
85
57
  AVPacket* pkt_;
86
58
  AVFrame* frame_; // Frame that is currently being processed
87
- SwrContext* swrCtx_;
88
- uint8_t** resampledData_; // weird ffmpeg way of using raw byte pointers for resampled data
89
-
59
+ AVFrame* pendingFrame_; // Frame that is saved if bufferedBus is full
90
60
  std::shared_ptr<AudioBus> bufferedBus_; // audio bus for buffering hls frames
91
- size_t bufferedBusSize_; // size of currently buffered bus
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
92
63
  int audio_stream_index_; // index of the audio stream channel in the input
64
+ SwrContext* swrCtx_;
65
+ uint8_t** resampledData_; // weird ffmpeg way of using raw byte pointers for resampled data
93
66
  int maxResampledSamples_;
94
- size_t processedSamples_;
95
-
67
+ std::mutex mutex_;
96
68
  std::thread streamingThread_;
97
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
98
71
  static constexpr int INITIAL_MAX_RESAMPLED_SAMPLES = 8192; // Initial size for resampled data
99
- channels::spsc::Sender<StreamingData, STREAMER_NODE_SPSC_OVERFLOW_STRATEGY, STREAMER_NODE_SPSC_WAIT_STRATEGY> sender_;
100
- channels::spsc::Receiver<StreamingData, STREAMER_NODE_SPSC_OVERFLOW_STRATEGY, STREAMER_NODE_SPSC_WAIT_STRATEGY> receiver_;
101
72
 
102
73
  /**
103
74
  * @brief Setting up the resampler
@@ -1,6 +1,5 @@
1
1
  #include <audioapi/core/AudioNode.h>
2
2
  #include <audioapi/core/AudioParam.h>
3
- #include <audioapi/core/effects/ConvolverNode.h>
4
3
  #include <audioapi/core/sources/AudioScheduledSourceNode.h>
5
4
  #include <audioapi/core/utils/AudioNodeManager.h>
6
5
  #include <audioapi/core/utils/Locker.h>
@@ -222,10 +221,6 @@ inline bool AudioNodeManager::nodeCanBeDestructed(
222
221
  if constexpr (std::is_base_of_v<AudioScheduledSourceNode, U>) {
223
222
  return node.use_count() == 1 &&
224
223
  (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();
229
224
  }
230
225
  return node.use_count() == 1;
231
226
  }
@@ -1,6 +1,5 @@
1
1
  #pragma once
2
2
 
3
- #include <numbers>
4
3
  #include <cmath>
5
4
  #include <limits>
6
5
 
@@ -20,7 +19,7 @@ static constexpr float MOST_POSITIVE_SINGLE_FLOAT = static_cast<float>(std::nume
20
19
  static constexpr float MOST_NEGATIVE_SINGLE_FLOAT = static_cast<float>(std::numeric_limits<float>::lowest());
21
20
  static float LOG2_MOST_POSITIVE_SINGLE_FLOAT = std::log2(MOST_POSITIVE_SINGLE_FLOAT);
22
21
  static float LOG10_MOST_POSITIVE_SINGLE_FLOAT = std::log10(MOST_POSITIVE_SINGLE_FLOAT);
23
- static constexpr float PI = std::numbers::pi_v<float>;
22
+ static constexpr float PI = static_cast<float>(M_PI);
24
23
 
25
24
  // buffer sizes
26
25
  static constexpr size_t PROMISE_VENDOR_THREAD_POOL_WORKER_COUNT = 4;
@@ -5,6 +5,16 @@
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
16
+ #endif
17
+
8
18
  #ifndef RN_AUDIO_API_TEST
9
19
  #define RN_AUDIO_API_TEST 0
10
20
  #endif
@@ -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
@@ -12,4 +12,30 @@ 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
+
15
41
  } // namespace audioapi::dsp
@@ -16,32 +16,8 @@ class FFT {
16
16
  explicit FFT(int size);
17
17
  ~FFT();
18
18
 
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
- }
19
+ void doFFT(float *in, std::vector<std::complex<float>> &out);
20
+ void doInverseFFT(std::vector<std::complex<float>> &in, float *out);
45
21
 
46
22
  private:
47
23
  int size_;