react-native-audio-api 0.12.0-nightly-0d1a19d-20260120 → 0.12.0-nightly-6993a06-20260122

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 (379) hide show
  1. package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +16 -2
  2. package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +7 -3
  3. package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionManager.kt +6 -6
  4. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +52 -49
  5. package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.cpp +18 -0
  6. package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.h +4 -0
  7. package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.cpp +6 -0
  8. package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.h +1 -0
  9. package/common/cpp/audioapi/HostObjects/utils/NodeOptions.h +111 -0
  10. package/common/cpp/audioapi/HostObjects/utils/NodeOptionsParser.h +262 -0
  11. package/common/cpp/audioapi/core/AudioNode.cpp +13 -6
  12. package/common/cpp/audioapi/core/AudioNode.h +2 -0
  13. package/common/cpp/audioapi/core/BaseAudioContext.cpp +42 -44
  14. package/common/cpp/audioapi/core/BaseAudioContext.h +32 -21
  15. package/common/cpp/audioapi/core/analysis/AnalyserNode.cpp +8 -6
  16. package/common/cpp/audioapi/core/analysis/AnalyserNode.h +2 -1
  17. package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +7 -8
  18. package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +4 -1
  19. package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +5 -9
  20. package/common/cpp/audioapi/core/effects/ConvolverNode.h +2 -2
  21. package/common/cpp/audioapi/core/effects/DelayNode.cpp +5 -4
  22. package/common/cpp/audioapi/core/effects/DelayNode.h +2 -1
  23. package/common/cpp/audioapi/core/effects/GainNode.cpp +4 -3
  24. package/common/cpp/audioapi/core/effects/GainNode.h +2 -1
  25. package/common/cpp/audioapi/core/effects/IIRFilterNode.cpp +6 -6
  26. package/common/cpp/audioapi/core/effects/IIRFilterNode.h +3 -2
  27. package/common/cpp/audioapi/core/effects/StereoPannerNode.cpp +3 -3
  28. package/common/cpp/audioapi/core/effects/StereoPannerNode.h +4 -1
  29. package/common/cpp/audioapi/core/effects/WaveShaperNode.cpp +4 -3
  30. package/common/cpp/audioapi/core/effects/WaveShaperNode.h +4 -1
  31. package/common/cpp/audioapi/core/sources/AudioBuffer.cpp +3 -2
  32. package/common/cpp/audioapi/core/sources/AudioBuffer.h +2 -1
  33. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +16 -22
  34. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +2 -1
  35. package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +38 -20
  36. package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +9 -1
  37. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +10 -8
  38. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +5 -2
  39. package/common/cpp/audioapi/core/sources/ConstantSourceNode.cpp +5 -8
  40. package/common/cpp/audioapi/core/sources/ConstantSourceNode.h +4 -1
  41. package/common/cpp/audioapi/core/sources/OscillatorNode.cpp +21 -16
  42. package/common/cpp/audioapi/core/sources/OscillatorNode.h +4 -1
  43. package/common/cpp/audioapi/core/sources/StreamerNode.cpp +4 -2
  44. package/common/cpp/audioapi/core/sources/StreamerNode.h +11 -1
  45. package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +8 -2
  46. package/common/cpp/test/src/ConstantSourceTest.cpp +3 -2
  47. package/common/cpp/test/src/DelayTest.cpp +12 -5
  48. package/common/cpp/test/src/GainTest.cpp +3 -2
  49. package/common/cpp/test/src/IIRFilterTest.cpp +3 -2
  50. package/common/cpp/test/src/OscillatorTest.cpp +2 -1
  51. package/common/cpp/test/src/StereoPannerTest.cpp +3 -2
  52. package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +10 -9
  53. package/common/cpp/test/src/core/effects/WaveShaperNodeTest.cpp +4 -3
  54. package/ios/audioapi/ios/AudioAPIModule.h +2 -2
  55. package/ios/audioapi/ios/AudioAPIModule.mm +3 -3
  56. package/ios/audioapi/ios/system/AudioEngine.mm +3 -1
  57. package/ios/audioapi/ios/system/AudioSessionManager.h +1 -0
  58. package/ios/audioapi/ios/system/{NotificationManager.h → SystemNotificationManager.h} +1 -1
  59. package/ios/audioapi/ios/system/{NotificationManager.mm → SystemNotificationManager.mm} +9 -4
  60. package/lib/commonjs/api.js +11 -3
  61. package/lib/commonjs/api.js.map +1 -1
  62. package/lib/commonjs/api.web.js +4 -10
  63. package/lib/commonjs/api.web.js.map +1 -1
  64. package/lib/commonjs/core/AnalyserNode.js +11 -0
  65. package/lib/commonjs/core/AnalyserNode.js.map +1 -1
  66. package/lib/commonjs/core/AudioBuffer.js +20 -6
  67. package/lib/commonjs/core/AudioBuffer.js.map +1 -1
  68. package/lib/commonjs/core/AudioBufferQueueSourceNode.js +24 -0
  69. package/lib/commonjs/core/AudioBufferQueueSourceNode.js.map +1 -1
  70. package/lib/commonjs/core/AudioBufferSourceNode.js +9 -6
  71. package/lib/commonjs/core/AudioBufferSourceNode.js.map +1 -1
  72. package/lib/commonjs/core/AudioScheduledSourceNode.js.map +1 -1
  73. package/lib/commonjs/core/BaseAudioContext.js +52 -65
  74. package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
  75. package/lib/commonjs/core/BiquadFilterNode.js +7 -1
  76. package/lib/commonjs/core/BiquadFilterNode.js.map +1 -1
  77. package/lib/commonjs/core/ConstantSourceNode.js +7 -1
  78. package/lib/commonjs/core/ConstantSourceNode.js.map +1 -1
  79. package/lib/commonjs/core/ConvolverNode.js +9 -3
  80. package/lib/commonjs/core/ConvolverNode.js.map +1 -1
  81. package/lib/commonjs/core/DelayNode.js +7 -1
  82. package/lib/commonjs/core/DelayNode.js.map +1 -1
  83. package/lib/commonjs/core/GainNode.js +9 -3
  84. package/lib/commonjs/core/GainNode.js.map +1 -1
  85. package/lib/commonjs/core/IIRFilterNode.js +9 -0
  86. package/lib/commonjs/core/IIRFilterNode.js.map +1 -1
  87. package/lib/commonjs/core/OscillatorNode.js +10 -7
  88. package/lib/commonjs/core/OscillatorNode.js.map +1 -1
  89. package/lib/commonjs/core/PeriodicWave.js +30 -2
  90. package/lib/commonjs/core/PeriodicWave.js.map +1 -1
  91. package/lib/commonjs/core/RecorderAdapterNode.js +3 -0
  92. package/lib/commonjs/core/RecorderAdapterNode.js.map +1 -1
  93. package/lib/commonjs/core/StereoPannerNode.js +7 -1
  94. package/lib/commonjs/core/StereoPannerNode.js.map +1 -1
  95. package/lib/commonjs/core/StreamerNode.js +25 -1
  96. package/lib/commonjs/core/StreamerNode.js.map +1 -1
  97. package/lib/commonjs/core/WaveShaperNode.js +12 -0
  98. package/lib/commonjs/core/WaveShaperNode.js.map +1 -1
  99. package/lib/commonjs/core/WorkletNode.js +13 -1
  100. package/lib/commonjs/core/WorkletNode.js.map +1 -1
  101. package/lib/commonjs/core/WorkletProcessingNode.js +14 -1
  102. package/lib/commonjs/core/WorkletProcessingNode.js.map +1 -1
  103. package/lib/commonjs/core/WorkletSourceNode.js +13 -1
  104. package/lib/commonjs/core/WorkletSourceNode.js.map +1 -1
  105. package/lib/commonjs/defaults.js +78 -0
  106. package/lib/commonjs/defaults.js.map +1 -0
  107. package/lib/commonjs/options-validators.js +40 -0
  108. package/lib/commonjs/options-validators.js.map +1 -0
  109. package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
  110. package/lib/commonjs/specs/NativeAudioAPIModule.web.js.map +1 -1
  111. package/lib/commonjs/system/AudioManager.js +7 -2
  112. package/lib/commonjs/system/AudioManager.js.map +1 -1
  113. package/lib/commonjs/types.js.map +1 -1
  114. package/lib/commonjs/web-core/AnalyserNode.js +2 -1
  115. package/lib/commonjs/web-core/AnalyserNode.js.map +1 -1
  116. package/lib/commonjs/web-core/AudioBuffer.js +14 -6
  117. package/lib/commonjs/web-core/AudioBuffer.js.map +1 -1
  118. package/lib/commonjs/web-core/AudioBufferSourceNode.js +276 -89
  119. package/lib/commonjs/web-core/AudioBufferSourceNode.js.map +1 -1
  120. package/lib/commonjs/web-core/AudioContext.js +33 -32
  121. package/lib/commonjs/web-core/AudioContext.js.map +1 -1
  122. package/lib/commonjs/web-core/AudioNode.js +4 -0
  123. package/lib/commonjs/web-core/AudioNode.js.map +1 -1
  124. package/lib/commonjs/web-core/AudioScheduledSourceNode.js +4 -2
  125. package/lib/commonjs/web-core/AudioScheduledSourceNode.js.map +1 -1
  126. package/lib/commonjs/web-core/BiquadFilterNode.js +2 -1
  127. package/lib/commonjs/web-core/BiquadFilterNode.js.map +1 -1
  128. package/lib/commonjs/web-core/ConstantSourceNode.js +2 -1
  129. package/lib/commonjs/web-core/ConstantSourceNode.js.map +1 -1
  130. package/lib/commonjs/web-core/ConvolverNode.js +3 -5
  131. package/lib/commonjs/web-core/ConvolverNode.js.map +1 -1
  132. package/lib/commonjs/web-core/DelayNode.js +7 -1
  133. package/lib/commonjs/web-core/DelayNode.js.map +1 -1
  134. package/lib/commonjs/web-core/GainNode.js +2 -1
  135. package/lib/commonjs/web-core/GainNode.js.map +1 -1
  136. package/lib/commonjs/web-core/IIRFilterNode.js +12 -0
  137. package/lib/commonjs/web-core/IIRFilterNode.js.map +1 -1
  138. package/lib/commonjs/web-core/OfflineAudioContext.js +33 -32
  139. package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
  140. package/lib/commonjs/web-core/OscillatorNode.js +2 -1
  141. package/lib/commonjs/web-core/OscillatorNode.js.map +1 -1
  142. package/lib/commonjs/web-core/PeriodicWave.js +6 -1
  143. package/lib/commonjs/web-core/PeriodicWave.js.map +1 -1
  144. package/lib/commonjs/web-core/StereoPannerNode.js +2 -1
  145. package/lib/commonjs/web-core/StereoPannerNode.js.map +1 -1
  146. package/lib/module/api.js +2 -1
  147. package/lib/module/api.js.map +1 -1
  148. package/lib/module/api.web.js +2 -1
  149. package/lib/module/api.web.js.map +1 -1
  150. package/lib/module/core/AnalyserNode.js +11 -0
  151. package/lib/module/core/AnalyserNode.js.map +1 -1
  152. package/lib/module/core/AudioBuffer.js +19 -6
  153. package/lib/module/core/AudioBuffer.js.map +1 -1
  154. package/lib/module/core/AudioBufferQueueSourceNode.js +24 -0
  155. package/lib/module/core/AudioBufferQueueSourceNode.js.map +1 -1
  156. package/lib/module/core/AudioBufferSourceNode.js +9 -6
  157. package/lib/module/core/AudioBufferSourceNode.js.map +1 -1
  158. package/lib/module/core/AudioScheduledSourceNode.js.map +1 -1
  159. package/lib/module/core/BaseAudioContext.js +52 -65
  160. package/lib/module/core/BaseAudioContext.js.map +1 -1
  161. package/lib/module/core/BiquadFilterNode.js +7 -1
  162. package/lib/module/core/BiquadFilterNode.js.map +1 -1
  163. package/lib/module/core/ConstantSourceNode.js +7 -1
  164. package/lib/module/core/ConstantSourceNode.js.map +1 -1
  165. package/lib/module/core/ConvolverNode.js +9 -3
  166. package/lib/module/core/ConvolverNode.js.map +1 -1
  167. package/lib/module/core/DelayNode.js +7 -1
  168. package/lib/module/core/DelayNode.js.map +1 -1
  169. package/lib/module/core/GainNode.js +9 -3
  170. package/lib/module/core/GainNode.js.map +1 -1
  171. package/lib/module/core/IIRFilterNode.js +9 -0
  172. package/lib/module/core/IIRFilterNode.js.map +1 -1
  173. package/lib/module/core/OscillatorNode.js +10 -7
  174. package/lib/module/core/OscillatorNode.js.map +1 -1
  175. package/lib/module/core/PeriodicWave.js +29 -2
  176. package/lib/module/core/PeriodicWave.js.map +1 -1
  177. package/lib/module/core/RecorderAdapterNode.js +3 -0
  178. package/lib/module/core/RecorderAdapterNode.js.map +1 -1
  179. package/lib/module/core/StereoPannerNode.js +7 -1
  180. package/lib/module/core/StereoPannerNode.js.map +1 -1
  181. package/lib/module/core/StreamerNode.js +25 -1
  182. package/lib/module/core/StreamerNode.js.map +1 -1
  183. package/lib/module/core/WaveShaperNode.js +12 -0
  184. package/lib/module/core/WaveShaperNode.js.map +1 -1
  185. package/lib/module/core/WorkletNode.js +13 -1
  186. package/lib/module/core/WorkletNode.js.map +1 -1
  187. package/lib/module/core/WorkletProcessingNode.js +14 -1
  188. package/lib/module/core/WorkletProcessingNode.js.map +1 -1
  189. package/lib/module/core/WorkletSourceNode.js +13 -1
  190. package/lib/module/core/WorkletSourceNode.js.map +1 -1
  191. package/lib/module/defaults.js +74 -0
  192. package/lib/module/defaults.js.map +1 -0
  193. package/lib/module/options-validators.js +36 -0
  194. package/lib/module/options-validators.js.map +1 -0
  195. package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
  196. package/lib/module/specs/NativeAudioAPIModule.web.js.map +1 -1
  197. package/lib/module/system/AudioManager.js +7 -2
  198. package/lib/module/system/AudioManager.js.map +1 -1
  199. package/lib/module/types.js.map +1 -1
  200. package/lib/module/web-core/AnalyserNode.js +2 -1
  201. package/lib/module/web-core/AnalyserNode.js.map +1 -1
  202. package/lib/module/web-core/AudioBuffer.js +13 -6
  203. package/lib/module/web-core/AudioBuffer.js.map +1 -1
  204. package/lib/module/web-core/AudioBufferSourceNode.js +277 -90
  205. package/lib/module/web-core/AudioBufferSourceNode.js.map +1 -1
  206. package/lib/module/web-core/AudioContext.js +33 -32
  207. package/lib/module/web-core/AudioContext.js.map +1 -1
  208. package/lib/module/web-core/AudioNode.js +4 -0
  209. package/lib/module/web-core/AudioNode.js.map +1 -1
  210. package/lib/module/web-core/AudioScheduledSourceNode.js +4 -2
  211. package/lib/module/web-core/AudioScheduledSourceNode.js.map +1 -1
  212. package/lib/module/web-core/BiquadFilterNode.js +2 -1
  213. package/lib/module/web-core/BiquadFilterNode.js.map +1 -1
  214. package/lib/module/web-core/ConstantSourceNode.js +2 -1
  215. package/lib/module/web-core/ConstantSourceNode.js.map +1 -1
  216. package/lib/module/web-core/ConvolverNode.js +3 -5
  217. package/lib/module/web-core/ConvolverNode.js.map +1 -1
  218. package/lib/module/web-core/DelayNode.js +7 -1
  219. package/lib/module/web-core/DelayNode.js.map +1 -1
  220. package/lib/module/web-core/GainNode.js +2 -1
  221. package/lib/module/web-core/GainNode.js.map +1 -1
  222. package/lib/module/web-core/IIRFilterNode.js +12 -0
  223. package/lib/module/web-core/IIRFilterNode.js.map +1 -1
  224. package/lib/module/web-core/OfflineAudioContext.js +33 -32
  225. package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
  226. package/lib/module/web-core/OscillatorNode.js +2 -1
  227. package/lib/module/web-core/OscillatorNode.js.map +1 -1
  228. package/lib/module/web-core/PeriodicWave.js +6 -1
  229. package/lib/module/web-core/PeriodicWave.js.map +1 -1
  230. package/lib/module/web-core/StereoPannerNode.js +2 -1
  231. package/lib/module/web-core/StereoPannerNode.js.map +1 -1
  232. package/lib/typescript/api.d.ts +2 -1
  233. package/lib/typescript/api.d.ts.map +1 -1
  234. package/lib/typescript/api.web.d.ts +2 -1
  235. package/lib/typescript/api.web.d.ts.map +1 -1
  236. package/lib/typescript/core/AnalyserNode.d.ts +3 -1
  237. package/lib/typescript/core/AnalyserNode.d.ts.map +1 -1
  238. package/lib/typescript/core/AudioBuffer.d.ts +3 -0
  239. package/lib/typescript/core/AudioBuffer.d.ts.map +1 -1
  240. package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts +8 -0
  241. package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts.map +1 -1
  242. package/lib/typescript/core/AudioBufferSourceNode.d.ts +3 -2
  243. package/lib/typescript/core/AudioBufferSourceNode.d.ts.map +1 -1
  244. package/lib/typescript/core/AudioScheduledSourceNode.d.ts +3 -3
  245. package/lib/typescript/core/AudioScheduledSourceNode.d.ts.map +1 -1
  246. package/lib/typescript/core/BaseAudioContext.d.ts +10 -6
  247. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
  248. package/lib/typescript/core/BiquadFilterNode.d.ts +2 -3
  249. package/lib/typescript/core/BiquadFilterNode.d.ts.map +1 -1
  250. package/lib/typescript/core/ConstantSourceNode.d.ts +2 -2
  251. package/lib/typescript/core/ConstantSourceNode.d.ts.map +1 -1
  252. package/lib/typescript/core/ConvolverNode.d.ts +2 -2
  253. package/lib/typescript/core/ConvolverNode.d.ts.map +1 -1
  254. package/lib/typescript/core/DelayNode.d.ts +2 -2
  255. package/lib/typescript/core/DelayNode.d.ts.map +1 -1
  256. package/lib/typescript/core/GainNode.d.ts +2 -2
  257. package/lib/typescript/core/GainNode.d.ts.map +1 -1
  258. package/lib/typescript/core/IIRFilterNode.d.ts +3 -0
  259. package/lib/typescript/core/IIRFilterNode.d.ts.map +1 -1
  260. package/lib/typescript/core/OscillatorNode.d.ts +2 -6
  261. package/lib/typescript/core/OscillatorNode.d.ts.map +1 -1
  262. package/lib/typescript/core/PeriodicWave.d.ts +4 -1
  263. package/lib/typescript/core/PeriodicWave.d.ts.map +1 -1
  264. package/lib/typescript/core/RecorderAdapterNode.d.ts +2 -0
  265. package/lib/typescript/core/RecorderAdapterNode.d.ts.map +1 -1
  266. package/lib/typescript/core/StereoPannerNode.d.ts +2 -2
  267. package/lib/typescript/core/StereoPannerNode.d.ts.map +1 -1
  268. package/lib/typescript/core/StreamerNode.d.ts +5 -0
  269. package/lib/typescript/core/StreamerNode.d.ts.map +1 -1
  270. package/lib/typescript/core/WaveShaperNode.d.ts +3 -0
  271. package/lib/typescript/core/WaveShaperNode.d.ts.map +1 -1
  272. package/lib/typescript/core/WorkletNode.d.ts +3 -0
  273. package/lib/typescript/core/WorkletNode.d.ts.map +1 -1
  274. package/lib/typescript/core/WorkletProcessingNode.d.ts +3 -0
  275. package/lib/typescript/core/WorkletProcessingNode.d.ts.map +1 -1
  276. package/lib/typescript/core/WorkletSourceNode.d.ts +3 -0
  277. package/lib/typescript/core/WorkletSourceNode.d.ts.map +1 -1
  278. package/lib/typescript/defaults.d.ts +16 -0
  279. package/lib/typescript/defaults.d.ts.map +1 -0
  280. package/lib/typescript/events/types.d.ts +6 -4
  281. package/lib/typescript/events/types.d.ts.map +1 -1
  282. package/lib/typescript/interfaces.d.ts +17 -15
  283. package/lib/typescript/interfaces.d.ts.map +1 -1
  284. package/lib/typescript/options-validators.d.ts +6 -0
  285. package/lib/typescript/options-validators.d.ts.map +1 -0
  286. package/lib/typescript/specs/NativeAudioAPIModule.d.ts +2 -1
  287. package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
  288. package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts +2 -2
  289. package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts.map +1 -1
  290. package/lib/typescript/system/AudioManager.d.ts +2 -2
  291. package/lib/typescript/system/AudioManager.d.ts.map +1 -1
  292. package/lib/typescript/system/types.d.ts +2 -1
  293. package/lib/typescript/system/types.d.ts.map +1 -1
  294. package/lib/typescript/types.d.ts +80 -11
  295. package/lib/typescript/types.d.ts.map +1 -1
  296. package/lib/typescript/web-core/AnalyserNode.d.ts +2 -2
  297. package/lib/typescript/web-core/AnalyserNode.d.ts.map +1 -1
  298. package/lib/typescript/web-core/AudioBuffer.d.ts +3 -0
  299. package/lib/typescript/web-core/AudioBuffer.d.ts.map +1 -1
  300. package/lib/typescript/web-core/AudioBufferSourceNode.d.ts +24 -15
  301. package/lib/typescript/web-core/AudioBufferSourceNode.d.ts.map +1 -1
  302. package/lib/typescript/web-core/AudioContext.d.ts +5 -6
  303. package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
  304. package/lib/typescript/web-core/AudioNode.d.ts +2 -2
  305. package/lib/typescript/web-core/AudioNode.d.ts.map +1 -1
  306. package/lib/typescript/web-core/AudioScheduledSourceNode.d.ts +2 -0
  307. package/lib/typescript/web-core/AudioScheduledSourceNode.d.ts.map +1 -1
  308. package/lib/typescript/web-core/BaseAudioContext.d.ts +3 -3
  309. package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
  310. package/lib/typescript/web-core/BiquadFilterNode.d.ts +2 -2
  311. package/lib/typescript/web-core/BiquadFilterNode.d.ts.map +1 -1
  312. package/lib/typescript/web-core/ConstantSourceNode.d.ts +2 -1
  313. package/lib/typescript/web-core/ConstantSourceNode.d.ts.map +1 -1
  314. package/lib/typescript/web-core/ConvolverNode.d.ts +2 -1
  315. package/lib/typescript/web-core/ConvolverNode.d.ts.map +1 -1
  316. package/lib/typescript/web-core/DelayNode.d.ts +2 -1
  317. package/lib/typescript/web-core/DelayNode.d.ts.map +1 -1
  318. package/lib/typescript/web-core/GainNode.d.ts +2 -1
  319. package/lib/typescript/web-core/GainNode.d.ts.map +1 -1
  320. package/lib/typescript/web-core/IIRFilterNode.d.ts +3 -0
  321. package/lib/typescript/web-core/IIRFilterNode.d.ts.map +1 -1
  322. package/lib/typescript/web-core/OfflineAudioContext.d.ts +5 -6
  323. package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
  324. package/lib/typescript/web-core/OscillatorNode.d.ts +2 -2
  325. package/lib/typescript/web-core/OscillatorNode.d.ts.map +1 -1
  326. package/lib/typescript/web-core/PeriodicWave.d.ts +3 -1
  327. package/lib/typescript/web-core/PeriodicWave.d.ts.map +1 -1
  328. package/lib/typescript/web-core/StereoPannerNode.d.ts +2 -1
  329. package/lib/typescript/web-core/StereoPannerNode.d.ts.map +1 -1
  330. package/package.json +1 -1
  331. package/src/api.ts +3 -1
  332. package/src/api.web.ts +1 -2
  333. package/src/core/AnalyserNode.ts +16 -1
  334. package/src/core/AudioBuffer.ts +26 -6
  335. package/src/core/AudioBufferQueueSourceNode.ts +46 -0
  336. package/src/core/AudioBufferSourceNode.ts +12 -10
  337. package/src/core/AudioScheduledSourceNode.ts +4 -4
  338. package/src/core/BaseAudioContext.ts +48 -151
  339. package/src/core/BiquadFilterNode.ts +9 -2
  340. package/src/core/ConstantSourceNode.ts +9 -1
  341. package/src/core/ConvolverNode.ts +11 -3
  342. package/src/core/DelayNode.ts +5 -2
  343. package/src/core/GainNode.ts +10 -3
  344. package/src/core/IIRFilterNode.ts +12 -0
  345. package/src/core/OscillatorNode.ts +13 -13
  346. package/src/core/PeriodicWave.ts +36 -2
  347. package/src/core/RecorderAdapterNode.ts +5 -0
  348. package/src/core/StereoPannerNode.ts +9 -1
  349. package/src/core/StreamerNode.ts +29 -1
  350. package/src/core/WaveShaperNode.ts +17 -0
  351. package/src/core/WorkletNode.ts +30 -1
  352. package/src/core/WorkletProcessingNode.ts +39 -1
  353. package/src/core/WorkletSourceNode.ts +36 -1
  354. package/src/defaults.ts +100 -0
  355. package/src/events/types.ts +6 -4
  356. package/src/interfaces.ts +40 -24
  357. package/src/options-validators.ts +66 -0
  358. package/src/specs/NativeAudioAPIModule.ts +6 -1
  359. package/src/specs/NativeAudioAPIModule.web.ts +6 -2
  360. package/src/system/AudioManager.ts +8 -2
  361. package/src/system/types.ts +7 -1
  362. package/src/types.ts +96 -12
  363. package/src/web-core/AnalyserNode.tsx +15 -6
  364. package/src/web-core/AudioBuffer.tsx +20 -6
  365. package/src/web-core/AudioBufferSourceNode.tsx +393 -148
  366. package/src/web-core/AudioContext.tsx +22 -72
  367. package/src/web-core/AudioNode.tsx +6 -2
  368. package/src/web-core/AudioScheduledSourceNode.tsx +6 -1
  369. package/src/web-core/BaseAudioContext.tsx +3 -7
  370. package/src/web-core/BiquadFilterNode.tsx +6 -2
  371. package/src/web-core/ConstantSourceNode.tsx +3 -1
  372. package/src/web-core/ConvolverNode.tsx +8 -8
  373. package/src/web-core/DelayNode.tsx +5 -1
  374. package/src/web-core/GainNode.tsx +3 -1
  375. package/src/web-core/IIRFilterNode.tsx +15 -0
  376. package/src/web-core/OfflineAudioContext.tsx +19 -67
  377. package/src/web-core/OscillatorNode.tsx +3 -2
  378. package/src/web-core/PeriodicWave.tsx +11 -1
  379. package/src/web-core/StereoPannerNode.tsx +9 -1
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/BaseAudioContext.h>
2
3
  #include <audioapi/core/effects/ConvolverNode.h>
3
4
  #include <audioapi/core/sources/AudioBuffer.h>
@@ -11,23 +12,18 @@
11
12
  #include <vector>
12
13
 
13
14
  namespace audioapi {
14
- ConvolverNode::ConvolverNode(
15
- std::shared_ptr<BaseAudioContext> context,
16
- const std::shared_ptr<AudioBuffer> &buffer,
17
- bool disableNormalization)
18
- : AudioNode(context),
15
+ ConvolverNode::ConvolverNode(std::shared_ptr<BaseAudioContext> context, const ConvolverOptions &options)
16
+ : AudioNode(context, options),
19
17
  gainCalibrationSampleRate_(context->getSampleRate()),
20
18
  remainingSegments_(0),
21
19
  internalBufferIndex_(0),
22
- normalize_(!disableNormalization),
20
+ normalize_(!options.disableNormalization),
23
21
  signalledToStop_(false),
24
22
  scaleFactor_(1.0f),
25
23
  intermediateBus_(nullptr),
26
24
  buffer_(nullptr),
27
25
  internalBuffer_(nullptr) {
28
- channelCount_ = 2;
29
- channelCountMode_ = ChannelCountMode::CLAMPED_MAX;
30
- setBuffer(buffer);
26
+ setBuffer(options.bus);
31
27
  audioBus_ =
32
28
  std::make_shared<AudioBus>(RENDER_QUANTUM_SIZE, channelCount_, context->getSampleRate());
33
29
  requiresTailProcessing_ = true;
@@ -17,13 +17,13 @@ namespace audioapi {
17
17
 
18
18
  class AudioBus;
19
19
  class AudioBuffer;
20
+ class ConvolverOptions;
20
21
 
21
22
  class ConvolverNode : public AudioNode {
22
23
  public:
23
24
  explicit ConvolverNode(
24
25
  std::shared_ptr<BaseAudioContext> context,
25
- const std::shared_ptr<AudioBuffer> &buffer,
26
- bool disableNormalization);
26
+ const ConvolverOptions &options);
27
27
 
28
28
  [[nodiscard]] bool getNormalize_() const;
29
29
  [[nodiscard]] const std::shared_ptr<AudioBuffer> &getBuffer() const;
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/BaseAudioContext.h>
2
3
  #include <audioapi/core/effects/DelayNode.h>
3
4
  #include <audioapi/dsp/VectorMath.h>
@@ -7,13 +8,13 @@
7
8
 
8
9
  namespace audioapi {
9
10
 
10
- DelayNode::DelayNode(std::shared_ptr<BaseAudioContext> context, float maxDelayTime)
11
- : AudioNode(context),
12
- delayTimeParam_(std::make_shared<AudioParam>(0, 0, maxDelayTime, context)),
11
+ DelayNode::DelayNode(std::shared_ptr<BaseAudioContext> context, const DelayOptions &options)
12
+ : AudioNode(context, options),
13
+ delayTimeParam_(std::make_shared<AudioParam>(options.delayTime, 0, options.maxDelayTime, context)),
13
14
  delayBuffer_(
14
15
  std::make_shared<AudioBus>(
15
16
  static_cast<size_t>(
16
- maxDelayTime * context->getSampleRate() +
17
+ options.maxDelayTime * context->getSampleRate() +
17
18
  1), // +1 to enable delayTime equal to maxDelayTime
18
19
  channelCount_,
19
20
  context->getSampleRate())) {
@@ -9,10 +9,11 @@
9
9
  namespace audioapi {
10
10
 
11
11
  class AudioBus;
12
+ class DelayOptions;
12
13
 
13
14
  class DelayNode : public AudioNode {
14
15
  public:
15
- explicit DelayNode(std::shared_ptr<BaseAudioContext> context, float maxDelayTime);
16
+ explicit DelayNode(std::shared_ptr<BaseAudioContext> context, const DelayOptions &options);
16
17
 
17
18
  [[nodiscard]] std::shared_ptr<AudioParam> getDelayTimeParam() const;
18
19
 
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/BaseAudioContext.h>
2
3
  #include <audioapi/core/effects/GainNode.h>
3
4
  #include <audioapi/dsp/VectorMath.h>
@@ -7,11 +8,11 @@
7
8
 
8
9
  namespace audioapi {
9
10
 
10
- GainNode::GainNode(std::shared_ptr<BaseAudioContext> context)
11
- : AudioNode(context),
11
+ GainNode::GainNode(std::shared_ptr<BaseAudioContext> context, const GainOptions &options)
12
+ : AudioNode(context, options),
12
13
  gainParam_(
13
14
  std::make_shared<AudioParam>(
14
- 1.0,
15
+ options.gain,
15
16
  MOST_NEGATIVE_SINGLE_FLOAT,
16
17
  MOST_POSITIVE_SINGLE_FLOAT,
17
18
  context)) {
@@ -8,10 +8,11 @@
8
8
  namespace audioapi {
9
9
 
10
10
  class AudioBus;
11
+ class GainOptions;
11
12
 
12
13
  class GainNode : public AudioNode {
13
14
  public:
14
- explicit GainNode(std::shared_ptr<BaseAudioContext> context);
15
+ explicit GainNode(std::shared_ptr<BaseAudioContext> context, const GainOptions &options);
15
16
 
16
17
  [[nodiscard]] std::shared_ptr<AudioParam> getGainParam() const;
17
18
 
@@ -23,6 +23,7 @@
23
23
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
24
  */
25
25
 
26
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
26
27
  #include <audioapi/core/BaseAudioContext.h>
27
28
  #include <audioapi/core/effects/IIRFilterNode.h>
28
29
  #include <audioapi/core/utils/Constants.h>
@@ -30,16 +31,15 @@
30
31
  #include <audioapi/utils/AudioBus.h>
31
32
  #include <algorithm>
32
33
  #include <memory>
34
+ #include <utility>
33
35
  #include <vector>
34
36
 
35
37
  namespace audioapi {
36
38
 
37
- IIRFilterNode::IIRFilterNode(
38
- std::shared_ptr<BaseAudioContext> context,
39
- const std::vector<float> &feedforward,
40
- const std::vector<float> &feedback)
41
- : AudioNode(context), feedforward_(feedforward), feedback_(feedback) {
42
- channelCountMode_ = ChannelCountMode::MAX;
39
+ IIRFilterNode::IIRFilterNode(std::shared_ptr<BaseAudioContext> context, const IIRFilterOptions &options)
40
+ : AudioNode(context, options),
41
+ feedforward_(std::move(options.feedforward)),
42
+ feedback_(std::move(options.feedback)) {
43
43
 
44
44
  int maxChannels = MAX_CHANNEL_COUNT;
45
45
  xBuffers_.resize(maxChannels);
@@ -33,13 +33,14 @@
33
33
 
34
34
  namespace audioapi {
35
35
 
36
+ class IIRFilterOptions;
37
+
36
38
  class IIRFilterNode : public AudioNode {
37
39
 
38
40
  public:
39
41
  explicit IIRFilterNode(
40
42
  std::shared_ptr<BaseAudioContext> context,
41
- const std::vector<float> &feedforward,
42
- const std::vector<float> &feedback);
43
+ const IIRFilterOptions &options);
43
44
 
44
45
  void getFrequencyResponse(
45
46
  const float *frequencyArray,
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/BaseAudioContext.h>
2
3
  #include <audioapi/core/effects/StereoPannerNode.h>
3
4
  #include <audioapi/core/utils/Constants.h>
@@ -9,9 +10,8 @@
9
10
 
10
11
  namespace audioapi {
11
12
 
12
- StereoPannerNode::StereoPannerNode(std::shared_ptr<BaseAudioContext> context)
13
- : AudioNode(context), panParam_(std::make_shared<AudioParam>(0.0, -1.0f, 1.0f, context)) {
14
- channelCountMode_ = ChannelCountMode::CLAMPED_MAX;
13
+ StereoPannerNode::StereoPannerNode(std::shared_ptr<BaseAudioContext> context, const StereoPannerOptions &options)
14
+ : AudioNode(context, options), panParam_(std::make_shared<AudioParam>(options.pan, -1.0f, 1.0f, context)) {
15
15
  isInitialized_ = true;
16
16
  }
17
17
 
@@ -10,10 +10,13 @@
10
10
  namespace audioapi {
11
11
 
12
12
  class AudioBus;
13
+ class StereoPannerOptions;
13
14
 
14
15
  class StereoPannerNode : public AudioNode {
15
16
  public:
16
- explicit StereoPannerNode(std::shared_ptr<BaseAudioContext> context);
17
+ explicit StereoPannerNode(
18
+ std::shared_ptr<BaseAudioContext> context,
19
+ const StereoPannerOptions &options);
17
20
 
18
21
  [[nodiscard]] std::shared_ptr<AudioParam> getPanParam() const;
19
22
 
@@ -3,6 +3,7 @@
3
3
  #include <audioapi/dsp/VectorMath.h>
4
4
  #include <audioapi/utils/AudioArray.h>
5
5
  #include <audioapi/utils/AudioBus.h>
6
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
6
7
 
7
8
  #include <algorithm>
8
9
  #include <memory>
@@ -10,14 +11,14 @@
10
11
 
11
12
  namespace audioapi {
12
13
 
13
- WaveShaperNode::WaveShaperNode(std::shared_ptr<BaseAudioContext> context)
14
- : AudioNode(context), oversample_(OverSampleType::OVERSAMPLE_NONE) {
14
+ WaveShaperNode::WaveShaperNode(std::shared_ptr<BaseAudioContext> context, const WaveShaperOptions &options)
15
+ : AudioNode(context, options), oversample_(options.oversample) {
15
16
 
16
17
  waveShapers_.reserve(6);
17
18
  for (int i = 0; i < channelCount_; i++) {
18
19
  waveShapers_.emplace_back(std::make_unique<WaveShaper>(nullptr));
19
20
  }
20
-
21
+ setCurve(options.curve);
21
22
  // to change after graph processing improvement - should be max
22
23
  channelCountMode_ = ChannelCountMode::CLAMPED_MAX;
23
24
  isInitialized_ = true;
@@ -16,10 +16,13 @@ namespace audioapi {
16
16
 
17
17
  class AudioBus;
18
18
  class AudioArray;
19
+ class WaveShaperOptions;
19
20
 
20
21
  class WaveShaperNode : public AudioNode {
21
22
  public:
22
- explicit WaveShaperNode(std::shared_ptr<BaseAudioContext> context);
23
+ explicit WaveShaperNode(
24
+ std::shared_ptr<BaseAudioContext> context,
25
+ const WaveShaperOptions &options);
23
26
 
24
27
  [[nodiscard]] std::string getOversample() const;
25
28
  [[nodiscard]] std::shared_ptr<AudioArray> getCurve() const;
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/sources/AudioBuffer.h>
2
3
  #include <audioapi/utils/AudioArray.h>
3
4
  #include <audioapi/utils/AudioBus.h>
@@ -8,8 +9,8 @@
8
9
 
9
10
  namespace audioapi {
10
11
 
11
- AudioBuffer::AudioBuffer(int numberOfChannels, size_t length, float sampleRate)
12
- : bus_(std::make_shared<AudioBus>(length, numberOfChannels, sampleRate)) {}
12
+ AudioBuffer::AudioBuffer(const AudioBufferOptions &options)
13
+ : bus_(std::make_shared<AudioBus>(options.length, options.numberOfChannels, options.sampleRate)) {}
13
14
 
14
15
  AudioBuffer::AudioBuffer(std::shared_ptr<AudioBus> bus) {
15
16
  bus_ = std::move(bus);
@@ -10,10 +10,11 @@
10
10
  namespace audioapi {
11
11
 
12
12
  class AudioBus;
13
+ class AudioBufferOptions;
13
14
 
14
15
  class AudioBuffer {
15
16
  public:
16
- explicit AudioBuffer(int numberOfChannels, size_t length, float sampleRate);
17
+ explicit AudioBuffer(const AudioBufferOptions &options);
17
18
  explicit AudioBuffer(std::shared_ptr<AudioBus> bus);
18
19
 
19
20
  [[nodiscard]] size_t getLength() const;
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/AudioParam.h>
2
3
  #include <audioapi/core/BaseAudioContext.h>
3
4
  #include <audioapi/core/sources/AudioBufferBaseSourceNode.h>
@@ -12,29 +13,22 @@
12
13
  namespace audioapi {
13
14
  AudioBufferBaseSourceNode::AudioBufferBaseSourceNode(
14
15
  std::shared_ptr<BaseAudioContext> context,
15
- bool pitchCorrection)
16
+ const BaseAudioBufferSourceOptions &options)
16
17
  : AudioScheduledSourceNode(context),
17
- pitchCorrection_(pitchCorrection),
18
- stretch_(std::make_shared<signalsmith::stretch::SignalsmithStretch<float>>()),
19
- playbackRateBus_(
20
- std::make_shared<AudioBus>(
21
- RENDER_QUANTUM_SIZE * 3,
22
- channelCount_,
23
- context->getSampleRate())),
24
- detuneParam_(
25
- std::make_shared<AudioParam>(
26
- 0.0,
27
- MOST_NEGATIVE_SINGLE_FLOAT,
28
- MOST_POSITIVE_SINGLE_FLOAT,
29
- context)),
30
- playbackRateParam_(
31
- std::make_shared<AudioParam>(
32
- 1.0,
33
- MOST_NEGATIVE_SINGLE_FLOAT,
34
- MOST_POSITIVE_SINGLE_FLOAT,
35
- context)),
36
- vReadIndex_(0.0),
37
- onPositionChangedInterval_(static_cast<int>(context->getSampleRate() * 0.1f)) {}
18
+ pitchCorrection_(options.pitchCorrection),
19
+ vReadIndex_(0.0) {
20
+ onPositionChangedInterval_ = static_cast<int>(context->getSampleRate() * 0.1);
21
+
22
+ detuneParam_ = std::make_shared<AudioParam>(
23
+ options.detune, MOST_NEGATIVE_SINGLE_FLOAT, MOST_POSITIVE_SINGLE_FLOAT, context);
24
+ playbackRateParam_ = std::make_shared<AudioParam>(
25
+ options.playbackRate, MOST_NEGATIVE_SINGLE_FLOAT, MOST_POSITIVE_SINGLE_FLOAT, context);
26
+
27
+ playbackRateBus_ =
28
+ std::make_shared<AudioBus>(RENDER_QUANTUM_SIZE * 3, channelCount_, context->getSampleRate());
29
+
30
+ stretch_ = std::make_shared<signalsmith::stretch::SignalsmithStretch<float>>();
31
+ }
38
32
 
39
33
  std::shared_ptr<AudioParam> AudioBufferBaseSourceNode::getDetuneParam() const {
40
34
  return detuneParam_;
@@ -11,12 +11,13 @@ namespace audioapi {
11
11
 
12
12
  class AudioBus;
13
13
  class AudioParam;
14
+ class BaseAudioBufferSourceOptions;
14
15
 
15
16
  class AudioBufferBaseSourceNode : public AudioScheduledSourceNode {
16
17
  public:
17
18
  explicit AudioBufferBaseSourceNode(
18
19
  std::shared_ptr<BaseAudioContext> context,
19
- bool pitchCorrection);
20
+ const BaseAudioBufferSourceOptions &options);
20
21
 
21
22
  [[nodiscard]] std::shared_ptr<AudioParam> getDetuneParam() const;
22
23
  [[nodiscard]] std::shared_ptr<AudioParam> getPlaybackRateParam() const;
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/AudioParam.h>
2
3
  #include <audioapi/core/BaseAudioContext.h>
3
4
  #include <audioapi/core/sources/AudioBufferQueueSourceNode.h>
@@ -18,19 +19,21 @@
18
19
  namespace audioapi {
19
20
 
20
21
  AudioBufferQueueSourceNode::AudioBufferQueueSourceNode(
21
- std::shared_ptr<BaseAudioContext> context,
22
- bool pitchCorrection)
23
- : AudioBufferBaseSourceNode(context, pitchCorrection), buffers_() {
22
+ std::shared_ptr<BaseAudioContext> context,
23
+ const BaseAudioBufferSourceOptions &options)
24
+ : AudioBufferBaseSourceNode(context, options) {
25
+ buffers_ = {};
24
26
  stretch_->presetDefault(channelCount_, context->getSampleRate());
25
27
 
26
- if (pitchCorrection) {
28
+ if (options.pitchCorrection) {
27
29
  // If pitch correction is enabled, add extra frames at the end
28
30
  // to compensate for processing latency.
29
31
  addExtraTailFrames_ = true;
30
32
 
31
33
  int extraTailFrames = static_cast<int>(stretch_->inputLatency() + stretch_->outputLatency());
32
- tailBuffer_ =
33
- std::make_shared<AudioBuffer>(channelCount_, extraTailFrames, context->getSampleRate());
34
+ auto audioBufferOptions = AudioBufferOptions(
35
+ extraTailFrames, static_cast<size_t>(channelCount_), context->getSampleRate());
36
+ tailBuffer_ = std::make_shared<AudioBuffer>(audioBufferOptions);
34
37
 
35
38
  tailBuffer_->bus_->zero();
36
39
  }
@@ -75,6 +78,10 @@ std::string AudioBufferQueueSourceNode::enqueueBuffer(const std::shared_ptr<Audi
75
78
  auto locker = Locker(getBufferLock());
76
79
  buffers_.emplace(bufferId_, buffer);
77
80
 
81
+ if (tailBuffer_ != nullptr) {
82
+ addExtraTailFrames_ = true;
83
+ }
84
+
78
85
  return std::to_string(bufferId_++);
79
86
  }
80
87
 
@@ -122,6 +129,14 @@ void AudioBufferQueueSourceNode::disable() {
122
129
  buffers_ = {};
123
130
  }
124
131
 
132
+ void AudioBufferQueueSourceNode::setOnBufferEndedCallbackId(uint64_t callbackId) {
133
+ auto oldCallbackId = onBufferEndedCallbackId_.exchange(callbackId, std::memory_order_acq_rel);
134
+
135
+ if (oldCallbackId != 0) {
136
+ audioEventHandlerRegistry_->unregisterHandler("bufferEnded", oldCallbackId);
137
+ }
138
+ }
139
+
125
140
  std::shared_ptr<AudioBus> AudioBufferQueueSourceNode::processNode(
126
141
  const std::shared_ptr<AudioBus> &processingBus,
127
142
  int framesToProcess) {
@@ -155,6 +170,18 @@ double AudioBufferQueueSourceNode::getCurrentPosition() const {
155
170
  }
156
171
  }
157
172
 
173
+ void AudioBufferQueueSourceNode::sendOnBufferEndedEvent(size_t bufferId, bool isLastBufferInQueue) {
174
+ auto onBufferEndedCallbackId = onBufferEndedCallbackId_.load(std::memory_order_acquire);
175
+
176
+ if (onBufferEndedCallbackId != 0) {
177
+ std::unordered_map<std::string, EventValue> body =
178
+ {{"bufferId", std::to_string(bufferId)}, {"isLastBufferInQueue", isLastBufferInQueue}};
179
+
180
+ audioEventHandlerRegistry_->invokeHandlerWithEventBody(
181
+ "bufferEnded", onBufferEndedCallbackId, body);
182
+ }
183
+ }
184
+
158
185
  /**
159
186
  * Helper functions
160
187
  */
@@ -193,20 +220,15 @@ void AudioBufferQueueSourceNode::processWithoutInterpolation(
193
220
  playedBuffersDuration_ += buffer->getDuration();
194
221
  buffers_.pop();
195
222
 
196
- std::unordered_map<std::string, EventValue> body = {
197
- {"bufferId", std::to_string(bufferId)}, {"isLast", buffers_.empty()}};
198
- if (std::shared_ptr<BaseAudioContext> context = context_.lock()) {
199
- context->audioEventHandlerRegistry_->invokeHandlerWithEventBody(
200
- "ended", onEndedCallbackId_, body);
223
+ if (!(buffers_.empty() && addExtraTailFrames_)) {
224
+ sendOnBufferEndedEvent(bufferId, buffers_.empty());
201
225
  }
202
226
 
203
227
  if (buffers_.empty()) {
204
228
  if (addExtraTailFrames_) {
205
- buffers_.emplace(bufferId_, tailBuffer_);
206
- bufferId_++;
207
-
229
+ buffers_.emplace(bufferId, tailBuffer_);
208
230
  addExtraTailFrames_ = false;
209
- } else if (buffers_.empty()) {
231
+ } else {
210
232
  processingBus->zero(writeIndex, framesLeft);
211
233
  readIndex = 0;
212
234
 
@@ -281,11 +303,7 @@ void AudioBufferQueueSourceNode::processWithInterpolation(
281
303
  playedBuffersDuration_ += buffer->getDuration();
282
304
  buffers_.pop();
283
305
 
284
- std::unordered_map<std::string, EventValue> body = {{"bufferId", std::to_string(bufferId)}};
285
- if (std::shared_ptr<BaseAudioContext> context = context_.lock()) {
286
- context->audioEventHandlerRegistry_->invokeHandlerWithEventBody(
287
- "ended", onEndedCallbackId_, body);
288
- }
306
+ sendOnBufferEndedEvent(bufferId, buffers_.empty());
289
307
 
290
308
  if (buffers_.empty()) {
291
309
  processingBus->zero(writeIndex, framesLeft);
@@ -14,12 +14,13 @@ namespace audioapi {
14
14
 
15
15
  class AudioBus;
16
16
  class AudioParam;
17
+ class BaseAudioBufferSourceOptions;
17
18
 
18
19
  class AudioBufferQueueSourceNode : public AudioBufferBaseSourceNode {
19
20
  public:
20
21
  explicit AudioBufferQueueSourceNode(
21
22
  std::shared_ptr<BaseAudioContext> context,
22
- bool pitchCorrection);
23
+ const BaseAudioBufferSourceOptions &options);
23
24
  ~AudioBufferQueueSourceNode() override;
24
25
 
25
26
  void stop(double when) override;
@@ -33,12 +34,17 @@ class AudioBufferQueueSourceNode : public AudioBufferBaseSourceNode {
33
34
  void clearBuffers();
34
35
  void disable() override;
35
36
 
37
+ void setOnBufferEndedCallbackId(uint64_t callbackId);
38
+
36
39
  protected:
37
40
  std::shared_ptr<AudioBus> processNode(
38
41
  const std::shared_ptr<AudioBus> &processingBus,
39
42
  int framesToProcess) override;
43
+
40
44
  double getCurrentPosition() const override;
41
45
 
46
+ void sendOnBufferEndedEvent(size_t bufferId, bool isLastBufferInQueue);
47
+
42
48
  private:
43
49
  // User provided buffers
44
50
  std::queue<std::pair<size_t, std::shared_ptr<AudioBuffer>>> buffers_;
@@ -50,6 +56,8 @@ class AudioBufferQueueSourceNode : public AudioBufferBaseSourceNode {
50
56
 
51
57
  double playedBuffersDuration_ = 0;
52
58
 
59
+ std::atomic<uint64_t> onBufferEndedCallbackId_ = 0; // 0 means no callback
60
+
53
61
  void processWithoutInterpolation(
54
62
  const std::shared_ptr<AudioBus> &processingBus,
55
63
  size_t startOffset,
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/AudioParam.h>
2
3
  #include <audioapi/core/BaseAudioContext.h>
3
4
  #include <audioapi/core/sources/AudioBufferSourceNode.h>
@@ -14,14 +15,15 @@ namespace audioapi {
14
15
 
15
16
  AudioBufferSourceNode::AudioBufferSourceNode(
16
17
  std::shared_ptr<BaseAudioContext> context,
17
- bool pitchCorrection)
18
- : AudioBufferBaseSourceNode(context, pitchCorrection),
19
- loop_(false),
18
+ const AudioBufferSourceOptions &options)
19
+ : AudioBufferBaseSourceNode(context, options),
20
+ loop_(options.loop),
20
21
  loopSkip_(false),
21
- loopStart_(0),
22
- loopEnd_(0),
23
- buffer_(nullptr),
24
- alignedBus_(nullptr) {
22
+ loopStart_(options.loopStart),
23
+ loopEnd_(options.loopEnd) {
24
+ buffer_ = std::shared_ptr<AudioBuffer>(options.buffer);
25
+ alignedBus_ = std::shared_ptr<AudioBus>(nullptr);
26
+
25
27
  isInitialized_ = true;
26
28
  }
27
29
 
@@ -322,7 +324,7 @@ void AudioBufferSourceNode::processWithInterpolation(
322
324
  }
323
325
  }
324
326
 
325
- double AudioBufferSourceNode::getVirtualStartFrame(float sampleRate) {
327
+ double AudioBufferSourceNode::getVirtualStartFrame(float sampleRate) const {
326
328
  auto loopStartFrame = loopStart_ * sampleRate;
327
329
  return loop_ && loopStartFrame >= 0 && loopStart_ < loopEnd_ ? loopStartFrame : 0.0;
328
330
  }
@@ -13,10 +13,13 @@ namespace audioapi {
13
13
 
14
14
  class AudioBus;
15
15
  class AudioParam;
16
+ class AudioBufferSourceOptions;
16
17
 
17
18
  class AudioBufferSourceNode : public AudioBufferBaseSourceNode {
18
19
  public:
19
- explicit AudioBufferSourceNode(std::shared_ptr<BaseAudioContext> context, bool pitchCorrection);
20
+ explicit AudioBufferSourceNode(
21
+ std::shared_ptr<BaseAudioContext> context,
22
+ const AudioBufferSourceOptions &options);
20
23
  ~AudioBufferSourceNode() override;
21
24
 
22
25
  [[nodiscard]] bool getLoop() const;
@@ -69,7 +72,7 @@ class AudioBufferSourceNode : public AudioBufferBaseSourceNode {
69
72
  size_t offsetLength,
70
73
  float playbackRate) override;
71
74
 
72
- double getVirtualStartFrame(float sampleRate);
75
+ double getVirtualStartFrame(float sampleRate) const;
73
76
  double getVirtualEndFrame(float sampleRate);
74
77
  };
75
78
 
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/BaseAudioContext.h>
2
3
  #include <audioapi/core/sources/ConstantSourceNode.h>
3
4
  #include <audioapi/dsp/AudioUtils.h>
@@ -6,14 +7,10 @@
6
7
  #include <memory>
7
8
 
8
9
  namespace audioapi {
9
- ConstantSourceNode::ConstantSourceNode(std::shared_ptr<BaseAudioContext> context)
10
- : AudioScheduledSourceNode(context),
11
- offsetParam_(
12
- std::make_shared<AudioParam>(
13
- 1.0,
14
- MOST_NEGATIVE_SINGLE_FLOAT,
15
- MOST_POSITIVE_SINGLE_FLOAT,
16
- context)) {
10
+ ConstantSourceNode::ConstantSourceNode(std::shared_ptr<BaseAudioContext> context, const ConstantSourceOptions &options)
11
+ : AudioScheduledSourceNode(context) {
12
+ offsetParam_ = std::make_shared<AudioParam>(
13
+ options.offset, MOST_NEGATIVE_SINGLE_FLOAT, MOST_POSITIVE_SINGLE_FLOAT, context);
17
14
  isInitialized_ = true;
18
15
  }
19
16
 
@@ -10,10 +10,13 @@
10
10
  namespace audioapi {
11
11
 
12
12
  class AudioBus;
13
+ class ConstantSourceOptions;
13
14
 
14
15
  class ConstantSourceNode : public AudioScheduledSourceNode {
15
16
  public:
16
- explicit ConstantSourceNode(std::shared_ptr<BaseAudioContext> context);
17
+ explicit ConstantSourceNode(
18
+ std::shared_ptr<BaseAudioContext> context,
19
+ const ConstantSourceOptions &options);
17
20
 
18
21
  [[nodiscard]] std::shared_ptr<AudioParam> getOffsetParam() const;
19
22
 
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/BaseAudioContext.h>
2
3
  #include <audioapi/core/sources/OscillatorNode.h>
3
4
  #include <audioapi/dsp/AudioUtils.h>
@@ -8,23 +9,27 @@
8
9
 
9
10
  namespace audioapi {
10
11
 
11
- OscillatorNode::OscillatorNode(std::shared_ptr<BaseAudioContext> context)
12
- : AudioScheduledSourceNode(context),
13
- frequencyParam_(
14
- std::make_shared<AudioParam>(
15
- 444.0,
16
- -context->getNyquistFrequency(),
17
- context->getNyquistFrequency(),
18
- context)),
19
- detuneParam_(
20
- std::make_shared<AudioParam>(
21
- 0.0,
22
- -1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
23
- 1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
24
- context)),
25
- type_(OscillatorType::SINE),
26
- periodicWave_(context->getBasicWaveForm(type_)) {
12
+ OscillatorNode::OscillatorNode(std::shared_ptr<BaseAudioContext> context, const OscillatorOptions &options)
13
+ : AudioScheduledSourceNode(context) {
14
+ frequencyParam_ = std::make_shared<AudioParam>(
15
+ options.frequency,
16
+ -context->getNyquistFrequency(),
17
+ context->getNyquistFrequency(),
18
+ context);
19
+ detuneParam_ = std::make_shared<AudioParam>(
20
+ options.detune,
21
+ -1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
22
+ 1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
23
+ context);
24
+ type_ = options.type;
25
+ if (options.periodicWave) {
26
+ periodicWave_ = options.periodicWave;
27
+ } else {
28
+ periodicWave_ = context->getBasicWaveForm(type_);
29
+ }
30
+
27
31
  audioBus_ = std::make_shared<AudioBus>(RENDER_QUANTUM_SIZE, 1, context->getSampleRate());
32
+
28
33
  isInitialized_ = true;
29
34
  }
30
35