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
@@ -5,7 +5,6 @@
5
5
  #include <audioapi/HostObjects/analysis/AnalyserNodeHostObject.h>
6
6
  #include <audioapi/HostObjects/destinations/AudioDestinationNodeHostObject.h>
7
7
  #include <audioapi/HostObjects/effects/BiquadFilterNodeHostObject.h>
8
- #include <audioapi/HostObjects/effects/ConvolverNodeHostObject.h>
9
8
  #include <audioapi/HostObjects/effects/GainNodeHostObject.h>
10
9
  #include <audioapi/HostObjects/effects/PeriodicWaveHostObject.h>
11
10
  #include <audioapi/HostObjects/effects/StereoPannerNodeHostObject.h>
@@ -50,7 +49,6 @@ BaseAudioContextHostObject::BaseAudioContextHostObject(
50
49
  JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createBufferQueueSource),
51
50
  JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createBuffer),
52
51
  JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createPeriodicWave),
53
- JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createConvolver),
54
52
  JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createAnalyser));
55
53
  }
56
54
 
@@ -271,20 +269,4 @@ JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createAnalyser) {
271
269
  auto analyserHostObject = std::make_shared<AnalyserNodeHostObject>(analyser);
272
270
  return jsi::Object::createFromHostObject(runtime, analyserHostObject);
273
271
  }
274
-
275
- JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createConvolver) {
276
- auto disableNormalization = args[1].getBool();
277
- std::shared_ptr<ConvolverNode> convolver;
278
- if (args[0].isUndefined()) {
279
- convolver = context_->createConvolver(nullptr, disableNormalization);
280
- } else {
281
- auto bufferHostObject =
282
- args[0].getObject(runtime).asHostObject<AudioBufferHostObject>(runtime);
283
- convolver = context_->createConvolver(
284
- bufferHostObject->audioBuffer_, disableNormalization);
285
- }
286
- auto convolverHostObject =
287
- std::make_shared<ConvolverNodeHostObject>(convolver);
288
- return jsi::Object::createFromHostObject(runtime, convolverHostObject);
289
- }
290
272
  } // namespace audioapi
@@ -41,7 +41,6 @@ class BaseAudioContextHostObject : public JsiHostObject {
41
41
  JSI_HOST_FUNCTION_DECL(createBuffer);
42
42
  JSI_HOST_FUNCTION_DECL(createPeriodicWave);
43
43
  JSI_HOST_FUNCTION_DECL(createAnalyser);
44
- JSI_HOST_FUNCTION_DECL(createConvolver);
45
44
 
46
45
  std::shared_ptr<BaseAudioContext> context_;
47
46
 
@@ -67,7 +67,7 @@ JSI_HOST_FUNCTION_IMPL(BiquadFilterNodeHostObject, getFrequencyResponse) {
67
67
  .getArrayBuffer(runtime);
68
68
  auto frequencyArray =
69
69
  reinterpret_cast<float *>(arrayBufferFrequency.data(runtime));
70
- auto length = static_cast<size_t>(arrayBufferFrequency.size(runtime));
70
+ auto length = static_cast<int>(arrayBufferFrequency.size(runtime));
71
71
 
72
72
  auto arrayBufferMag = args[1]
73
73
  .getObject(runtime)
@@ -14,35 +14,97 @@
14
14
  namespace audioapi {
15
15
 
16
16
  AudioRecorderHostObject::AudioRecorderHostObject(
17
- const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry,
18
- float sampleRate,
19
- int bufferLength) {
17
+ const std::shared_ptr<AudioEventHandlerRegistry>
18
+ &audioEventHandlerRegistry) {
20
19
  #ifdef ANDROID
21
- audioRecorder_ = std::make_shared<AndroidAudioRecorder>(
22
- sampleRate, bufferLength, audioEventHandlerRegistry);
20
+ audioRecorder_ =
21
+ std::make_shared<AndroidAudioRecorder>(audioEventHandlerRegistry);
23
22
  #else
24
- audioRecorder_ = std::make_shared<IOSAudioRecorder>(
25
- sampleRate, bufferLength, audioEventHandlerRegistry);
23
+ audioRecorder_ =
24
+ std::make_shared<IOSAudioRecorder>(audioEventHandlerRegistry);
26
25
  #endif
27
26
 
28
- addSetters(JSI_EXPORT_PROPERTY_SETTER(AudioRecorderHostObject, onAudioReady));
29
-
30
27
  addFunctions(
31
28
  JSI_EXPORT_FUNCTION(AudioRecorderHostObject, start),
32
29
  JSI_EXPORT_FUNCTION(AudioRecorderHostObject, stop),
30
+ JSI_EXPORT_FUNCTION(AudioRecorderHostObject, isRecording),
31
+ JSI_EXPORT_FUNCTION(AudioRecorderHostObject, enableFileOutput),
32
+ JSI_EXPORT_FUNCTION(AudioRecorderHostObject, disableFileOutput),
33
+ JSI_EXPORT_FUNCTION(AudioRecorderHostObject, pause),
34
+ JSI_EXPORT_FUNCTION(AudioRecorderHostObject, resume),
33
35
  JSI_EXPORT_FUNCTION(AudioRecorderHostObject, connect),
34
- JSI_EXPORT_FUNCTION(AudioRecorderHostObject, disconnect));
36
+ JSI_EXPORT_FUNCTION(AudioRecorderHostObject, disconnect),
37
+ JSI_EXPORT_FUNCTION(AudioRecorderHostObject, setOnAudioReady),
38
+ JSI_EXPORT_FUNCTION(AudioRecorderHostObject, clearOnAudioReady),
39
+ JSI_EXPORT_FUNCTION(AudioRecorderHostObject, getCurrentDuration));
40
+ }
41
+
42
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, start) {
43
+ std::string filePath = audioRecorder_->start();
44
+
45
+ return jsi::Value(runtime, jsi::String::createFromUtf8(runtime, filePath));
46
+ }
47
+
48
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, stop) {
49
+ auto [path, size, duration] = audioRecorder_->stop();
50
+ auto result = jsi::Object(runtime);
51
+
52
+ result.setProperty(
53
+ runtime, "path", jsi::String::createFromUtf8(runtime, path));
54
+ result.setProperty(runtime, "size", size);
55
+ result.setProperty(runtime, "duration", duration);
56
+
57
+ return result;
58
+ }
59
+
60
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, isRecording) {
61
+ return jsi::Value(audioRecorder_->isRecording());
35
62
  }
36
63
 
37
- JSI_PROPERTY_SETTER_IMPL(AudioRecorderHostObject, onAudioReady) {
38
- audioRecorder_->setOnAudioReadyCallbackId(
39
- std::stoull(value.getString(runtime).utf8(runtime)));
64
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, isPaused) {
65
+ return jsi::Value(audioRecorder_->isPaused());
66
+ }
67
+
68
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, enableFileOutput) {
69
+ auto options = args[0].getObject(runtime);
70
+
71
+ auto sampleRate = static_cast<float>(
72
+ options.getProperty(runtime, "sampleRate").getNumber());
73
+ auto channelCount =
74
+ static_cast<size_t>(options.getProperty(runtime, "channels").getNumber());
75
+ auto bitRate =
76
+ static_cast<size_t>(options.getProperty(runtime, "bitRate").getNumber());
77
+ auto iosFlags =
78
+ static_cast<size_t>(options.getProperty(runtime, "ios").getNumber());
79
+ auto androidFlags =
80
+ static_cast<size_t>(options.getProperty(runtime, "android").getNumber());
81
+
82
+ audioRecorder_->enableFileOutput(
83
+ sampleRate, channelCount, bitRate, iosFlags, androidFlags);
84
+ return jsi::Value::undefined();
85
+ }
86
+
87
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, disableFileOutput) {
88
+ audioRecorder_->disableFileOutput();
89
+ return jsi::Value::undefined();
90
+ }
91
+
92
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, pause) {
93
+ audioRecorder_->pause();
94
+
95
+ return jsi::Value::undefined();
96
+ }
97
+
98
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, resume) {
99
+ audioRecorder_->resume();
100
+ return jsi::Value::undefined();
40
101
  }
41
102
 
42
103
  JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, connect) {
43
104
  auto adapterNodeHostObject =
44
105
  args[0].getObject(runtime).getHostObject<RecorderAdapterNodeHostObject>(
45
106
  runtime);
107
+
46
108
  audioRecorder_->connect(
47
109
  std::static_pointer_cast<RecorderAdapterNode>(
48
110
  adapterNodeHostObject->node_));
@@ -51,19 +113,36 @@ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, connect) {
51
113
 
52
114
  JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, disconnect) {
53
115
  audioRecorder_->disconnect();
116
+
54
117
  return jsi::Value::undefined();
55
118
  }
56
119
 
57
- JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, start) {
58
- audioRecorder_->start();
120
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, setOnAudioReady) {
121
+ auto options = args[0].getObject(runtime);
122
+
123
+ auto sampleRate = static_cast<float>(
124
+ options.getProperty(runtime, "sampleRate").getNumber());
125
+ auto bufferLength = static_cast<size_t>(
126
+ options.getProperty(runtime, "bufferLength").getNumber());
127
+ auto channelCount = static_cast<size_t>(
128
+ options.getProperty(runtime, "channelCount").getNumber());
129
+ uint64_t callbackId = std::stoull(options.getProperty(runtime, "callbackId")
130
+ .getString(runtime)
131
+ .utf8(runtime));
59
132
 
133
+ audioRecorder_->setOnAudioReadyCallback(
134
+ sampleRate, bufferLength, channelCount, callbackId);
60
135
  return jsi::Value::undefined();
61
136
  }
62
137
 
63
- JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, stop) {
64
- audioRecorder_->stop();
65
-
138
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, clearOnAudioReady) {
139
+ audioRecorder_->clearOnAudioReadyCallback();
66
140
  return jsi::Value::undefined();
67
141
  }
68
142
 
143
+ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, getCurrentDuration) {
144
+ double duration = audioRecorder_->getCurrentDuration();
145
+ return jsi::Value(duration);
146
+ }
147
+
69
148
  } // namespace audioapi
@@ -6,6 +6,7 @@
6
6
  #include <utility>
7
7
  #include <vector>
8
8
  #include <cstdio>
9
+ #include <string>
9
10
 
10
11
  namespace audioapi {
11
12
  using namespace facebook;
@@ -16,18 +17,29 @@ class AudioEventHandlerRegistry;
16
17
  class AudioRecorderHostObject : public JsiHostObject {
17
18
  public:
18
19
  explicit AudioRecorderHostObject(
19
- const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry,
20
- float sampleRate,
21
- int bufferLength);
20
+ const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry);
22
21
 
23
- JSI_PROPERTY_SETTER_DECL(onAudioReady);
22
+ JSI_HOST_FUNCTION_DECL(start);
23
+ JSI_HOST_FUNCTION_DECL(stop);
24
+ JSI_HOST_FUNCTION_DECL(isRecording);
25
+ JSI_HOST_FUNCTION_DECL(isPaused);
26
+
27
+ JSI_HOST_FUNCTION_DECL(enableFileOutput);
28
+ JSI_HOST_FUNCTION_DECL(disableFileOutput);
29
+
30
+ JSI_HOST_FUNCTION_DECL(pause);
31
+ JSI_HOST_FUNCTION_DECL(resume);
24
32
 
25
33
  JSI_HOST_FUNCTION_DECL(connect);
26
34
  JSI_HOST_FUNCTION_DECL(disconnect);
27
- JSI_HOST_FUNCTION_DECL(start);
28
- JSI_HOST_FUNCTION_DECL(stop);
35
+
36
+ JSI_HOST_FUNCTION_DECL(setOnAudioReady);
37
+ JSI_HOST_FUNCTION_DECL(clearOnAudioReady);
38
+
39
+ JSI_HOST_FUNCTION_DECL(getCurrentDuration);
29
40
 
30
41
  private:
31
42
  std::shared_ptr<AudioRecorder> audioRecorder_;
32
43
  };
44
+
33
45
  } // namespace audioapi
@@ -41,7 +41,6 @@ class AudioNode : public std::enable_shared_from_this<AudioNode> {
41
41
  protected:
42
42
  friend class AudioNodeManager;
43
43
  friend class AudioDestinationNode;
44
- friend class ConvolverNode;
45
44
 
46
45
  BaseAudioContext *context_;
47
46
  std::shared_ptr<AudioBus> audioBus_;
@@ -69,10 +68,10 @@ class AudioNode : public std::enable_shared_from_this<AudioNode> {
69
68
  static std::string toString(ChannelCountMode mode);
70
69
  static std::string toString(ChannelInterpretation interpretation);
71
70
 
72
- virtual std::shared_ptr<AudioBus> processInputs(const std::shared_ptr<AudioBus>& outputBus, int framesToProcess, bool checkIsAlreadyProcessed);
73
71
  virtual std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus>&, int) = 0;
74
72
 
75
73
  bool isAlreadyProcessed();
74
+ std::shared_ptr<AudioBus> processInputs(const std::shared_ptr<AudioBus>& outputBus, int framesToProcess, bool checkIsAlreadyProcessed);
76
75
  std::shared_ptr<AudioBus> applyChannelCountMode(const std::shared_ptr<AudioBus> &processingBus);
77
76
  void mixInputsBuses(const std::shared_ptr<AudioBus>& processingBus);
78
77
 
@@ -82,7 +81,7 @@ class AudioNode : public std::enable_shared_from_this<AudioNode> {
82
81
  void disconnectParam(const std::shared_ptr<AudioParam> &param);
83
82
 
84
83
  void onInputEnabled();
85
- virtual void onInputDisabled();
84
+ void onInputDisabled();
86
85
  void onInputConnected(AudioNode *node);
87
86
  void onInputDisconnected(AudioNode *node);
88
87
 
@@ -56,7 +56,7 @@ float AudioParam::getValueAtTime(double time) {
56
56
  void AudioParam::setValueAtTime(float value, double startTime) {
57
57
  auto event = [value, startTime](AudioParam &param) {
58
58
  // Ignore events scheduled before the end of existing automation
59
- if (startTime < param.getQueueEndTime()) {
59
+ if (startTime <= param.getQueueEndTime()) {
60
60
  return;
61
61
  }
62
62
 
@@ -87,7 +87,7 @@ void AudioParam::setValueAtTime(float value, double startTime) {
87
87
  void AudioParam::linearRampToValueAtTime(float value, double endTime) {
88
88
  auto event = [value, endTime](AudioParam &param) {
89
89
  // Ignore events scheduled before the end of existing automation
90
- if (endTime < param.getQueueEndTime()) {
90
+ if (endTime <= param.getQueueEndTime()) {
91
91
  return;
92
92
  }
93
93
 
@@ -2,7 +2,6 @@
2
2
  #include <audioapi/core/analysis/AnalyserNode.h>
3
3
  #include <audioapi/core/destinations/AudioDestinationNode.h>
4
4
  #include <audioapi/core/effects/BiquadFilterNode.h>
5
- #include <audioapi/core/effects/ConvolverNode.h>
6
5
  #include <audioapi/core/effects/GainNode.h>
7
6
  #include <audioapi/core/effects/StereoPannerNode.h>
8
7
  #include <audioapi/core/effects/WorkletNode.h>
@@ -183,15 +182,6 @@ std::shared_ptr<AnalyserNode> BaseAudioContext::createAnalyser() {
183
182
  return analyser;
184
183
  }
185
184
 
186
- std::shared_ptr<ConvolverNode> BaseAudioContext::createConvolver(
187
- std::shared_ptr<AudioBuffer> buffer,
188
- bool disableNormalization) {
189
- auto convolver =
190
- std::make_shared<ConvolverNode>(this, buffer, disableNormalization);
191
- nodeManager_->addProcessingNode(convolver);
192
- return convolver;
193
- }
194
-
195
185
  AudioNodeManager *BaseAudioContext::getNodeManager() {
196
186
  return nodeManager_.get();
197
187
  }
@@ -28,7 +28,6 @@ class AudioBufferSourceNode;
28
28
  class AudioBufferQueueSourceNode;
29
29
  class AnalyserNode;
30
30
  class AudioEventHandlerRegistry;
31
- class ConvolverNode;
32
31
  class IAudioEventHandlerRegistry;
33
32
  class RecorderAdapterNode;
34
33
  class WorkletSourceNode;
@@ -77,7 +76,6 @@ class BaseAudioContext {
77
76
  bool disableNormalization,
78
77
  int length);
79
78
  std::shared_ptr<AnalyserNode> createAnalyser();
80
- std::shared_ptr<ConvolverNode> createConvolver(std::shared_ptr<AudioBuffer> buffer, bool disableNormalization);
81
79
 
82
80
  std::shared_ptr<PeriodicWave> getBasicWaveForm(OscillatorType type);
83
81
  [[nodiscard]] float getNyquistFrequency() const;
@@ -1,31 +1,3 @@
1
- /*
2
- * Copyright (C) 2010 Google Inc. All rights reserved.
3
- *
4
- * Redistribution and use in source and binary forms, with or without
5
- * modification, are permitted provided that the following conditions
6
- * are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright
9
- * notice, this list of conditions and the following disclaimer.
10
- * 2. Redistributions in binary form must reproduce the above copyright
11
- * notice, this list of conditions and the following disclaimer in the
12
- * documentation and/or other materials provided with the distribution.
13
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14
- * its contributors may be used to endorse or promote products derived
15
- * from this software without specific prior written permission.
16
- *
17
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- */
28
-
29
1
  #include <audioapi/core/BaseAudioContext.h>
30
2
  #include <audioapi/core/effects/BiquadFilterNode.h>
31
3
  #include <audioapi/utils/AudioArray.h>
@@ -41,14 +13,14 @@ BiquadFilterNode::BiquadFilterNode(BaseAudioContext *context)
41
13
  frequencyParam_ = std::make_shared<AudioParam>(
42
14
  350.0, 0.0f, context->getNyquistFrequency(), context);
43
15
  detuneParam_ = std::make_shared<AudioParam>(
44
- 0.0f,
16
+ 0.0,
45
17
  -1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
46
18
  1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
47
19
  context);
48
20
  QParam_ = std::make_shared<AudioParam>(
49
- 1.0f, MOST_NEGATIVE_SINGLE_FLOAT, MOST_POSITIVE_SINGLE_FLOAT, context);
21
+ 1.0, MOST_NEGATIVE_SINGLE_FLOAT, MOST_POSITIVE_SINGLE_FLOAT, context);
50
22
  gainParam_ = std::make_shared<AudioParam>(
51
- 0.0f,
23
+ 0.0,
52
24
  MOST_NEGATIVE_SINGLE_FLOAT,
53
25
  40 * LOG10_MOST_POSITIVE_SINGLE_FLOAT,
54
26
  context);
@@ -104,35 +76,27 @@ void BiquadFilterNode::getFrequencyResponse(
104
76
  const float *frequencyArray,
105
77
  float *magResponseOutput,
106
78
  float *phaseResponseOutput,
107
- const size_t length) {
108
- #ifndef AUDIO_API_TEST_SUITE
79
+ const int length) {
109
80
  applyFilter();
110
- #endif
111
-
112
- // Use double precision for later calculations
113
- double b0 = static_cast<double>(b0_);
114
- double b1 = static_cast<double>(b1_);
115
- double b2 = static_cast<double>(b2_);
116
- double a1 = static_cast<double>(a1_);
117
- double a2 = static_cast<double>(a2_);
118
81
 
119
- float nyquist = context_->getNyquistFrequency();
82
+ // Local copies for micro-optimization
83
+ float b0 = b0_;
84
+ float b1 = b1_;
85
+ float b2 = b2_;
86
+ float a1 = a1_;
87
+ float a2 = a2_;
120
88
 
121
89
  for (size_t i = 0; i < length; i++) {
122
- // Convert from frequency in Hz to normalized frequency [0, 1]
123
- float normalizedFreq = frequencyArray[i] / nyquist;
124
-
125
- if (normalizedFreq < 0.0f || normalizedFreq > 1.0f) {
126
- // Out-of-bounds frequencies should return NaN.
90
+ if (frequencyArray[i] < 0.0 || frequencyArray[i] > 1.0) {
127
91
  magResponseOutput[i] = std::nanf("");
128
92
  phaseResponseOutput[i] = std::nanf("");
129
93
  continue;
130
94
  }
131
95
 
132
- double omega = -PI * normalizedFreq;
133
- auto z = std::complex<double>(std::cos(omega), std::sin(omega));
96
+ auto omega = -PI * frequencyArray[i] / context_->getNyquistFrequency();
97
+ auto z = std::complex<float>(cos(omega), sin(omega));
134
98
  auto response = (b0 + (b1 + b2 * z) * z) /
135
- (std::complex<double>(1, 0) + (a1 + a2 * z) * z);
99
+ (std::complex<float>(1, 0) + (a1 + a2 * z) * z);
136
100
  magResponseOutput[i] = static_cast<float>(std::abs(response));
137
101
  phaseResponseOutput[i] =
138
102
  static_cast<float>(atan2(imag(response), real(response)));
@@ -156,16 +120,17 @@ void BiquadFilterNode::setNormalizedCoefficients(
156
120
 
157
121
  void BiquadFilterNode::setLowpassCoefficients(float frequency, float Q) {
158
122
  // Limit frequency to [0, 1] range
159
- if (frequency >= 1.0f) {
123
+ if (frequency >= 1.0) {
160
124
  setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
161
125
  return;
162
126
  }
163
127
 
164
- if (frequency <= 0.0f) {
128
+ if (frequency <= 0.0) {
165
129
  setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
166
130
  return;
167
131
  }
168
132
 
133
+ Q = std::max(0.0f, Q);
169
134
  float g = std::pow(10.0f, 0.05f * Q);
170
135
 
171
136
  float theta = PI * frequency;
@@ -178,15 +143,16 @@ void BiquadFilterNode::setLowpassCoefficients(float frequency, float Q) {
178
143
  }
179
144
 
180
145
  void BiquadFilterNode::setHighpassCoefficients(float frequency, float Q) {
181
- if (frequency >= 1.0f) {
146
+ if (frequency >= 1.0) {
182
147
  setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
183
148
  return;
184
149
  }
185
- if (frequency <= 0.0f) {
150
+ if (frequency <= 0.0) {
186
151
  setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
187
152
  return;
188
153
  }
189
154
 
155
+ Q = std::max(0.0f, Q);
190
156
  float g = std::pow(10.0f, 0.05f * Q);
191
157
 
192
158
  float theta = PI * frequency;
@@ -200,13 +166,13 @@ void BiquadFilterNode::setHighpassCoefficients(float frequency, float Q) {
200
166
 
201
167
  void BiquadFilterNode::setBandpassCoefficients(float frequency, float Q) {
202
168
  // Limit frequency to [0, 1] range
203
- if (frequency <= 0.0f || frequency >= 1.0f) {
169
+ if (frequency <= 0.0 || frequency >= 1.0) {
204
170
  setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
205
171
  return;
206
172
  }
207
173
 
208
174
  // Limit Q to positive values
209
- if (Q <= 0.0f) {
175
+ if (Q <= 0.0) {
210
176
  setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
211
177
  return;
212
178
  }
@@ -222,12 +188,12 @@ void BiquadFilterNode::setBandpassCoefficients(float frequency, float Q) {
222
188
  void BiquadFilterNode::setLowshelfCoefficients(float frequency, float gain) {
223
189
  float A = std::pow(10.0f, gain / 40.0f);
224
190
 
225
- if (frequency >= 1.0f) {
191
+ if (frequency >= 1.0) {
226
192
  setNormalizedCoefficients(A * A, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
227
193
  return;
228
194
  }
229
195
 
230
- if (frequency <= 0.0f) {
196
+ if (frequency <= 0.0) {
231
197
  setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
232
198
  return;
233
199
  }
@@ -249,12 +215,12 @@ void BiquadFilterNode::setLowshelfCoefficients(float frequency, float gain) {
249
215
  void BiquadFilterNode::setHighshelfCoefficients(float frequency, float gain) {
250
216
  float A = std::pow(10.0f, gain / 40.0f);
251
217
 
252
- if (frequency >= 1.0f) {
218
+ if (frequency >= 1.0) {
253
219
  setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
254
220
  return;
255
221
  }
256
222
 
257
- if (frequency <= 0.0f) {
223
+ if (frequency <= 0.0) {
258
224
  setNormalizedCoefficients(A * A, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
259
225
  return;
260
226
  }
@@ -281,12 +247,12 @@ void BiquadFilterNode::setPeakingCoefficients(
281
247
  float gain) {
282
248
  float A = std::pow(10.0f, gain / 40.0f);
283
249
 
284
- if (frequency <= 0.0f || frequency >= 1.0f) {
250
+ if (frequency <= 0.0 || frequency >= 1.0) {
285
251
  setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
286
252
  return;
287
253
  }
288
254
 
289
- if (Q <= 0.0f) {
255
+ if (Q <= 0.0) {
290
256
  setNormalizedCoefficients(A * A, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
291
257
  return;
292
258
  }
@@ -305,12 +271,12 @@ void BiquadFilterNode::setPeakingCoefficients(
305
271
  }
306
272
 
307
273
  void BiquadFilterNode::setNotchCoefficients(float frequency, float Q) {
308
- if (frequency <= 0.0f || frequency >= 1.0f) {
274
+ if (frequency <= 0.0 || frequency >= 1.0) {
309
275
  setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
310
276
  return;
311
277
  }
312
278
 
313
- if (Q <= 0.0f) {
279
+ if (Q <= 0.0) {
314
280
  setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
315
281
  return;
316
282
  }
@@ -324,12 +290,12 @@ void BiquadFilterNode::setNotchCoefficients(float frequency, float Q) {
324
290
  }
325
291
 
326
292
  void BiquadFilterNode::setAllpassCoefficients(float frequency, float Q) {
327
- if (frequency <= 0.0f || frequency >= 1.0f) {
293
+ if (frequency <= 0.0 || frequency >= 1.0) {
328
294
  setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
329
295
  return;
330
296
  }
331
297
 
332
- if (Q <= 0.0f) {
298
+ if (Q <= 0.0) {
333
299
  setNormalizedCoefficients(-1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
334
300
  return;
335
301
  }
@@ -352,9 +318,6 @@ void BiquadFilterNode::applyFilter() {
352
318
  auto Q = QParam_->processKRateParam(RENDER_QUANTUM_SIZE, currentTime);
353
319
  auto gain = gainParam_->processKRateParam(RENDER_QUANTUM_SIZE, currentTime);
354
320
 
355
- // NyquistFrequency is half of the sample rate.
356
- // Normalized frequency is therefore:
357
- // frequency / (sampleRate / 2) = (2 * frequency) / sampleRate
358
321
  float normalizedFrequency = frequency / context_->getNyquistFrequency();
359
322
  if (detune != 0.0f) {
360
323
  normalizedFrequency *= std::pow(2.0f, detune / 1200.0f);
@@ -1,39 +1,8 @@
1
- /*
2
- * Copyright (C) 2010 Google Inc. All rights reserved.
3
- *
4
- * Redistribution and use in source and binary forms, with or without
5
- * modification, are permitted provided that the following conditions
6
- * are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright
9
- * notice, this list of conditions and the following disclaimer.
10
- * 2. Redistributions in binary form must reproduce the above copyright
11
- * notice, this list of conditions and the following disclaimer in the
12
- * documentation and/or other materials provided with the distribution.
13
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14
- * its contributors may be used to endorse or promote products derived
15
- * from this software without specific prior written permission.
16
- *
17
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- */
28
-
29
1
  #pragma once
30
2
 
31
3
  #include <audioapi/core/AudioNode.h>
32
4
  #include <audioapi/core/AudioParam.h>
33
5
  #include <audioapi/core/types/BiquadFilterType.h>
34
- #ifdef AUDIO_API_TEST_SUITE
35
- #include <gtest/gtest_prod.h>
36
- #endif
37
6
 
38
7
  #include <algorithm>
39
8
  #include <cmath>
@@ -48,11 +17,6 @@ namespace audioapi {
48
17
  class AudioBus;
49
18
 
50
19
  class BiquadFilterNode : public AudioNode {
51
- #ifdef AUDIO_API_TEST_SUITE
52
- friend class BiquadFilterTest;
53
- FRIEND_TEST(BiquadFilterTest, GetFrequencyResponse);
54
- #endif
55
-
56
20
  public:
57
21
  explicit BiquadFilterNode(BaseAudioContext *context);
58
22
 
@@ -66,7 +30,7 @@ class BiquadFilterNode : public AudioNode {
66
30
  const float *frequencyArray,
67
31
  float *magResponseOutput,
68
32
  float *phaseResponseOutput,
69
- size_t length);
33
+ int length);
70
34
 
71
35
  protected:
72
36
  std::shared_ptr<AudioBus> processNode(