react-native-audio-api 0.12.0-nightly-0d1a19d-20260120 → 0.12.0-nightly-75589dc-20260121

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 (332) hide show
  1. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +52 -49
  2. package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.cpp +6 -0
  3. package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.h +1 -0
  4. package/common/cpp/audioapi/HostObjects/utils/NodeOptions.h +111 -0
  5. package/common/cpp/audioapi/HostObjects/utils/NodeOptionsParser.h +262 -0
  6. package/common/cpp/audioapi/core/AudioNode.cpp +13 -6
  7. package/common/cpp/audioapi/core/AudioNode.h +2 -0
  8. package/common/cpp/audioapi/core/BaseAudioContext.cpp +42 -44
  9. package/common/cpp/audioapi/core/BaseAudioContext.h +32 -21
  10. package/common/cpp/audioapi/core/analysis/AnalyserNode.cpp +8 -6
  11. package/common/cpp/audioapi/core/analysis/AnalyserNode.h +2 -1
  12. package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +7 -8
  13. package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +4 -1
  14. package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +5 -9
  15. package/common/cpp/audioapi/core/effects/ConvolverNode.h +2 -2
  16. package/common/cpp/audioapi/core/effects/DelayNode.cpp +5 -4
  17. package/common/cpp/audioapi/core/effects/DelayNode.h +2 -1
  18. package/common/cpp/audioapi/core/effects/GainNode.cpp +4 -3
  19. package/common/cpp/audioapi/core/effects/GainNode.h +2 -1
  20. package/common/cpp/audioapi/core/effects/IIRFilterNode.cpp +6 -6
  21. package/common/cpp/audioapi/core/effects/IIRFilterNode.h +3 -2
  22. package/common/cpp/audioapi/core/effects/StereoPannerNode.cpp +3 -3
  23. package/common/cpp/audioapi/core/effects/StereoPannerNode.h +4 -1
  24. package/common/cpp/audioapi/core/effects/WaveShaperNode.cpp +4 -3
  25. package/common/cpp/audioapi/core/effects/WaveShaperNode.h +4 -1
  26. package/common/cpp/audioapi/core/sources/AudioBuffer.cpp +3 -2
  27. package/common/cpp/audioapi/core/sources/AudioBuffer.h +2 -1
  28. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +16 -22
  29. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +2 -1
  30. package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +9 -6
  31. package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +2 -1
  32. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +9 -7
  33. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +4 -1
  34. package/common/cpp/audioapi/core/sources/ConstantSourceNode.cpp +5 -8
  35. package/common/cpp/audioapi/core/sources/ConstantSourceNode.h +4 -1
  36. package/common/cpp/audioapi/core/sources/OscillatorNode.cpp +21 -16
  37. package/common/cpp/audioapi/core/sources/OscillatorNode.h +4 -1
  38. package/common/cpp/audioapi/core/sources/StreamerNode.cpp +4 -2
  39. package/common/cpp/audioapi/core/sources/StreamerNode.h +11 -1
  40. package/common/cpp/test/src/ConstantSourceTest.cpp +3 -2
  41. package/common/cpp/test/src/DelayTest.cpp +12 -5
  42. package/common/cpp/test/src/GainTest.cpp +3 -2
  43. package/common/cpp/test/src/IIRFilterTest.cpp +3 -2
  44. package/common/cpp/test/src/OscillatorTest.cpp +2 -1
  45. package/common/cpp/test/src/StereoPannerTest.cpp +3 -2
  46. package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +10 -9
  47. package/common/cpp/test/src/core/effects/WaveShaperNodeTest.cpp +4 -3
  48. package/lib/commonjs/api.js +11 -3
  49. package/lib/commonjs/api.js.map +1 -1
  50. package/lib/commonjs/api.web.js +4 -10
  51. package/lib/commonjs/api.web.js.map +1 -1
  52. package/lib/commonjs/core/AnalyserNode.js +11 -0
  53. package/lib/commonjs/core/AnalyserNode.js.map +1 -1
  54. package/lib/commonjs/core/AudioBuffer.js +20 -6
  55. package/lib/commonjs/core/AudioBuffer.js.map +1 -1
  56. package/lib/commonjs/core/AudioBufferQueueSourceNode.js +9 -0
  57. package/lib/commonjs/core/AudioBufferQueueSourceNode.js.map +1 -1
  58. package/lib/commonjs/core/AudioBufferSourceNode.js +9 -0
  59. package/lib/commonjs/core/AudioBufferSourceNode.js.map +1 -1
  60. package/lib/commonjs/core/BaseAudioContext.js +52 -65
  61. package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
  62. package/lib/commonjs/core/BiquadFilterNode.js +7 -1
  63. package/lib/commonjs/core/BiquadFilterNode.js.map +1 -1
  64. package/lib/commonjs/core/ConstantSourceNode.js +7 -1
  65. package/lib/commonjs/core/ConstantSourceNode.js.map +1 -1
  66. package/lib/commonjs/core/ConvolverNode.js +9 -3
  67. package/lib/commonjs/core/ConvolverNode.js.map +1 -1
  68. package/lib/commonjs/core/DelayNode.js +7 -1
  69. package/lib/commonjs/core/DelayNode.js.map +1 -1
  70. package/lib/commonjs/core/GainNode.js +9 -3
  71. package/lib/commonjs/core/GainNode.js.map +1 -1
  72. package/lib/commonjs/core/IIRFilterNode.js +9 -0
  73. package/lib/commonjs/core/IIRFilterNode.js.map +1 -1
  74. package/lib/commonjs/core/OscillatorNode.js +10 -1
  75. package/lib/commonjs/core/OscillatorNode.js.map +1 -1
  76. package/lib/commonjs/core/PeriodicWave.js +30 -2
  77. package/lib/commonjs/core/PeriodicWave.js.map +1 -1
  78. package/lib/commonjs/core/RecorderAdapterNode.js +3 -0
  79. package/lib/commonjs/core/RecorderAdapterNode.js.map +1 -1
  80. package/lib/commonjs/core/StereoPannerNode.js +7 -1
  81. package/lib/commonjs/core/StereoPannerNode.js.map +1 -1
  82. package/lib/commonjs/core/StreamerNode.js +25 -1
  83. package/lib/commonjs/core/StreamerNode.js.map +1 -1
  84. package/lib/commonjs/core/WaveShaperNode.js +12 -0
  85. package/lib/commonjs/core/WaveShaperNode.js.map +1 -1
  86. package/lib/commonjs/core/WorkletNode.js +13 -1
  87. package/lib/commonjs/core/WorkletNode.js.map +1 -1
  88. package/lib/commonjs/core/WorkletProcessingNode.js +14 -1
  89. package/lib/commonjs/core/WorkletProcessingNode.js.map +1 -1
  90. package/lib/commonjs/core/WorkletSourceNode.js +13 -1
  91. package/lib/commonjs/core/WorkletSourceNode.js.map +1 -1
  92. package/lib/commonjs/defaults.js +78 -0
  93. package/lib/commonjs/defaults.js.map +1 -0
  94. package/lib/commonjs/options-validators.js +40 -0
  95. package/lib/commonjs/options-validators.js.map +1 -0
  96. package/lib/commonjs/types.js.map +1 -1
  97. package/lib/commonjs/web-core/AnalyserNode.js +2 -1
  98. package/lib/commonjs/web-core/AnalyserNode.js.map +1 -1
  99. package/lib/commonjs/web-core/AudioBuffer.js +14 -6
  100. package/lib/commonjs/web-core/AudioBuffer.js.map +1 -1
  101. package/lib/commonjs/web-core/AudioBufferSourceNode.js +276 -89
  102. package/lib/commonjs/web-core/AudioBufferSourceNode.js.map +1 -1
  103. package/lib/commonjs/web-core/AudioContext.js +33 -32
  104. package/lib/commonjs/web-core/AudioContext.js.map +1 -1
  105. package/lib/commonjs/web-core/AudioNode.js +4 -0
  106. package/lib/commonjs/web-core/AudioNode.js.map +1 -1
  107. package/lib/commonjs/web-core/BiquadFilterNode.js +2 -1
  108. package/lib/commonjs/web-core/BiquadFilterNode.js.map +1 -1
  109. package/lib/commonjs/web-core/ConstantSourceNode.js +2 -1
  110. package/lib/commonjs/web-core/ConstantSourceNode.js.map +1 -1
  111. package/lib/commonjs/web-core/ConvolverNode.js +3 -5
  112. package/lib/commonjs/web-core/ConvolverNode.js.map +1 -1
  113. package/lib/commonjs/web-core/DelayNode.js +7 -1
  114. package/lib/commonjs/web-core/DelayNode.js.map +1 -1
  115. package/lib/commonjs/web-core/GainNode.js +2 -1
  116. package/lib/commonjs/web-core/GainNode.js.map +1 -1
  117. package/lib/commonjs/web-core/IIRFilterNode.js +12 -0
  118. package/lib/commonjs/web-core/IIRFilterNode.js.map +1 -1
  119. package/lib/commonjs/web-core/OfflineAudioContext.js +33 -32
  120. package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
  121. package/lib/commonjs/web-core/OscillatorNode.js +2 -1
  122. package/lib/commonjs/web-core/OscillatorNode.js.map +1 -1
  123. package/lib/commonjs/web-core/PeriodicWave.js +6 -1
  124. package/lib/commonjs/web-core/PeriodicWave.js.map +1 -1
  125. package/lib/commonjs/web-core/StereoPannerNode.js +2 -1
  126. package/lib/commonjs/web-core/StereoPannerNode.js.map +1 -1
  127. package/lib/module/api.js +2 -1
  128. package/lib/module/api.js.map +1 -1
  129. package/lib/module/api.web.js +2 -1
  130. package/lib/module/api.web.js.map +1 -1
  131. package/lib/module/core/AnalyserNode.js +11 -0
  132. package/lib/module/core/AnalyserNode.js.map +1 -1
  133. package/lib/module/core/AudioBuffer.js +19 -6
  134. package/lib/module/core/AudioBuffer.js.map +1 -1
  135. package/lib/module/core/AudioBufferQueueSourceNode.js +9 -0
  136. package/lib/module/core/AudioBufferQueueSourceNode.js.map +1 -1
  137. package/lib/module/core/AudioBufferSourceNode.js +9 -0
  138. package/lib/module/core/AudioBufferSourceNode.js.map +1 -1
  139. package/lib/module/core/BaseAudioContext.js +52 -65
  140. package/lib/module/core/BaseAudioContext.js.map +1 -1
  141. package/lib/module/core/BiquadFilterNode.js +7 -1
  142. package/lib/module/core/BiquadFilterNode.js.map +1 -1
  143. package/lib/module/core/ConstantSourceNode.js +7 -1
  144. package/lib/module/core/ConstantSourceNode.js.map +1 -1
  145. package/lib/module/core/ConvolverNode.js +9 -3
  146. package/lib/module/core/ConvolverNode.js.map +1 -1
  147. package/lib/module/core/DelayNode.js +7 -1
  148. package/lib/module/core/DelayNode.js.map +1 -1
  149. package/lib/module/core/GainNode.js +9 -3
  150. package/lib/module/core/GainNode.js.map +1 -1
  151. package/lib/module/core/IIRFilterNode.js +9 -0
  152. package/lib/module/core/IIRFilterNode.js.map +1 -1
  153. package/lib/module/core/OscillatorNode.js +10 -1
  154. package/lib/module/core/OscillatorNode.js.map +1 -1
  155. package/lib/module/core/PeriodicWave.js +29 -2
  156. package/lib/module/core/PeriodicWave.js.map +1 -1
  157. package/lib/module/core/RecorderAdapterNode.js +3 -0
  158. package/lib/module/core/RecorderAdapterNode.js.map +1 -1
  159. package/lib/module/core/StereoPannerNode.js +7 -1
  160. package/lib/module/core/StereoPannerNode.js.map +1 -1
  161. package/lib/module/core/StreamerNode.js +25 -1
  162. package/lib/module/core/StreamerNode.js.map +1 -1
  163. package/lib/module/core/WaveShaperNode.js +12 -0
  164. package/lib/module/core/WaveShaperNode.js.map +1 -1
  165. package/lib/module/core/WorkletNode.js +13 -1
  166. package/lib/module/core/WorkletNode.js.map +1 -1
  167. package/lib/module/core/WorkletProcessingNode.js +14 -1
  168. package/lib/module/core/WorkletProcessingNode.js.map +1 -1
  169. package/lib/module/core/WorkletSourceNode.js +13 -1
  170. package/lib/module/core/WorkletSourceNode.js.map +1 -1
  171. package/lib/module/defaults.js +74 -0
  172. package/lib/module/defaults.js.map +1 -0
  173. package/lib/module/options-validators.js +36 -0
  174. package/lib/module/options-validators.js.map +1 -0
  175. package/lib/module/types.js.map +1 -1
  176. package/lib/module/web-core/AnalyserNode.js +2 -1
  177. package/lib/module/web-core/AnalyserNode.js.map +1 -1
  178. package/lib/module/web-core/AudioBuffer.js +13 -6
  179. package/lib/module/web-core/AudioBuffer.js.map +1 -1
  180. package/lib/module/web-core/AudioBufferSourceNode.js +277 -90
  181. package/lib/module/web-core/AudioBufferSourceNode.js.map +1 -1
  182. package/lib/module/web-core/AudioContext.js +33 -32
  183. package/lib/module/web-core/AudioContext.js.map +1 -1
  184. package/lib/module/web-core/AudioNode.js +4 -0
  185. package/lib/module/web-core/AudioNode.js.map +1 -1
  186. package/lib/module/web-core/BiquadFilterNode.js +2 -1
  187. package/lib/module/web-core/BiquadFilterNode.js.map +1 -1
  188. package/lib/module/web-core/ConstantSourceNode.js +2 -1
  189. package/lib/module/web-core/ConstantSourceNode.js.map +1 -1
  190. package/lib/module/web-core/ConvolverNode.js +3 -5
  191. package/lib/module/web-core/ConvolverNode.js.map +1 -1
  192. package/lib/module/web-core/DelayNode.js +7 -1
  193. package/lib/module/web-core/DelayNode.js.map +1 -1
  194. package/lib/module/web-core/GainNode.js +2 -1
  195. package/lib/module/web-core/GainNode.js.map +1 -1
  196. package/lib/module/web-core/IIRFilterNode.js +12 -0
  197. package/lib/module/web-core/IIRFilterNode.js.map +1 -1
  198. package/lib/module/web-core/OfflineAudioContext.js +33 -32
  199. package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
  200. package/lib/module/web-core/OscillatorNode.js +2 -1
  201. package/lib/module/web-core/OscillatorNode.js.map +1 -1
  202. package/lib/module/web-core/PeriodicWave.js +6 -1
  203. package/lib/module/web-core/PeriodicWave.js.map +1 -1
  204. package/lib/module/web-core/StereoPannerNode.js +2 -1
  205. package/lib/module/web-core/StereoPannerNode.js.map +1 -1
  206. package/lib/typescript/api.d.ts +2 -1
  207. package/lib/typescript/api.d.ts.map +1 -1
  208. package/lib/typescript/api.web.d.ts +2 -1
  209. package/lib/typescript/api.web.d.ts.map +1 -1
  210. package/lib/typescript/core/AnalyserNode.d.ts +3 -1
  211. package/lib/typescript/core/AnalyserNode.d.ts.map +1 -1
  212. package/lib/typescript/core/AudioBuffer.d.ts +3 -0
  213. package/lib/typescript/core/AudioBuffer.d.ts.map +1 -1
  214. package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts +3 -0
  215. package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts.map +1 -1
  216. package/lib/typescript/core/AudioBufferSourceNode.d.ts +3 -0
  217. package/lib/typescript/core/AudioBufferSourceNode.d.ts.map +1 -1
  218. package/lib/typescript/core/BaseAudioContext.d.ts +10 -6
  219. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
  220. package/lib/typescript/core/BiquadFilterNode.d.ts +2 -3
  221. package/lib/typescript/core/BiquadFilterNode.d.ts.map +1 -1
  222. package/lib/typescript/core/ConstantSourceNode.d.ts +2 -2
  223. package/lib/typescript/core/ConstantSourceNode.d.ts.map +1 -1
  224. package/lib/typescript/core/ConvolverNode.d.ts +2 -2
  225. package/lib/typescript/core/ConvolverNode.d.ts.map +1 -1
  226. package/lib/typescript/core/DelayNode.d.ts +2 -2
  227. package/lib/typescript/core/DelayNode.d.ts.map +1 -1
  228. package/lib/typescript/core/GainNode.d.ts +2 -2
  229. package/lib/typescript/core/GainNode.d.ts.map +1 -1
  230. package/lib/typescript/core/IIRFilterNode.d.ts +3 -0
  231. package/lib/typescript/core/IIRFilterNode.d.ts.map +1 -1
  232. package/lib/typescript/core/OscillatorNode.d.ts +2 -3
  233. package/lib/typescript/core/OscillatorNode.d.ts.map +1 -1
  234. package/lib/typescript/core/PeriodicWave.d.ts +4 -1
  235. package/lib/typescript/core/PeriodicWave.d.ts.map +1 -1
  236. package/lib/typescript/core/RecorderAdapterNode.d.ts +2 -0
  237. package/lib/typescript/core/RecorderAdapterNode.d.ts.map +1 -1
  238. package/lib/typescript/core/StereoPannerNode.d.ts +2 -2
  239. package/lib/typescript/core/StereoPannerNode.d.ts.map +1 -1
  240. package/lib/typescript/core/StreamerNode.d.ts +5 -0
  241. package/lib/typescript/core/StreamerNode.d.ts.map +1 -1
  242. package/lib/typescript/core/WaveShaperNode.d.ts +3 -0
  243. package/lib/typescript/core/WaveShaperNode.d.ts.map +1 -1
  244. package/lib/typescript/core/WorkletNode.d.ts +3 -0
  245. package/lib/typescript/core/WorkletNode.d.ts.map +1 -1
  246. package/lib/typescript/core/WorkletProcessingNode.d.ts +3 -0
  247. package/lib/typescript/core/WorkletProcessingNode.d.ts.map +1 -1
  248. package/lib/typescript/core/WorkletSourceNode.d.ts +3 -0
  249. package/lib/typescript/core/WorkletSourceNode.d.ts.map +1 -1
  250. package/lib/typescript/defaults.d.ts +16 -0
  251. package/lib/typescript/defaults.d.ts.map +1 -0
  252. package/lib/typescript/interfaces.d.ts +16 -15
  253. package/lib/typescript/interfaces.d.ts.map +1 -1
  254. package/lib/typescript/options-validators.d.ts +6 -0
  255. package/lib/typescript/options-validators.d.ts.map +1 -0
  256. package/lib/typescript/types.d.ts +80 -11
  257. package/lib/typescript/types.d.ts.map +1 -1
  258. package/lib/typescript/web-core/AnalyserNode.d.ts +2 -2
  259. package/lib/typescript/web-core/AnalyserNode.d.ts.map +1 -1
  260. package/lib/typescript/web-core/AudioBuffer.d.ts +3 -0
  261. package/lib/typescript/web-core/AudioBuffer.d.ts.map +1 -1
  262. package/lib/typescript/web-core/AudioBufferSourceNode.d.ts +24 -15
  263. package/lib/typescript/web-core/AudioBufferSourceNode.d.ts.map +1 -1
  264. package/lib/typescript/web-core/AudioContext.d.ts +5 -6
  265. package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
  266. package/lib/typescript/web-core/AudioNode.d.ts +2 -2
  267. package/lib/typescript/web-core/AudioNode.d.ts.map +1 -1
  268. package/lib/typescript/web-core/BaseAudioContext.d.ts +3 -3
  269. package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
  270. package/lib/typescript/web-core/BiquadFilterNode.d.ts +2 -2
  271. package/lib/typescript/web-core/BiquadFilterNode.d.ts.map +1 -1
  272. package/lib/typescript/web-core/ConstantSourceNode.d.ts +2 -1
  273. package/lib/typescript/web-core/ConstantSourceNode.d.ts.map +1 -1
  274. package/lib/typescript/web-core/ConvolverNode.d.ts +2 -1
  275. package/lib/typescript/web-core/ConvolverNode.d.ts.map +1 -1
  276. package/lib/typescript/web-core/DelayNode.d.ts +2 -1
  277. package/lib/typescript/web-core/DelayNode.d.ts.map +1 -1
  278. package/lib/typescript/web-core/GainNode.d.ts +2 -1
  279. package/lib/typescript/web-core/GainNode.d.ts.map +1 -1
  280. package/lib/typescript/web-core/IIRFilterNode.d.ts +3 -0
  281. package/lib/typescript/web-core/IIRFilterNode.d.ts.map +1 -1
  282. package/lib/typescript/web-core/OfflineAudioContext.d.ts +5 -6
  283. package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
  284. package/lib/typescript/web-core/OscillatorNode.d.ts +2 -2
  285. package/lib/typescript/web-core/OscillatorNode.d.ts.map +1 -1
  286. package/lib/typescript/web-core/PeriodicWave.d.ts +3 -1
  287. package/lib/typescript/web-core/PeriodicWave.d.ts.map +1 -1
  288. package/lib/typescript/web-core/StereoPannerNode.d.ts +2 -1
  289. package/lib/typescript/web-core/StereoPannerNode.d.ts.map +1 -1
  290. package/package.json +1 -1
  291. package/src/api.ts +3 -1
  292. package/src/api.web.ts +1 -2
  293. package/src/core/AnalyserNode.ts +16 -1
  294. package/src/core/AudioBuffer.ts +26 -6
  295. package/src/core/AudioBufferQueueSourceNode.ts +15 -0
  296. package/src/core/AudioBufferSourceNode.ts +12 -0
  297. package/src/core/BaseAudioContext.ts +48 -151
  298. package/src/core/BiquadFilterNode.ts +9 -2
  299. package/src/core/ConstantSourceNode.ts +9 -1
  300. package/src/core/ConvolverNode.ts +11 -3
  301. package/src/core/DelayNode.ts +5 -2
  302. package/src/core/GainNode.ts +10 -3
  303. package/src/core/IIRFilterNode.ts +12 -0
  304. package/src/core/OscillatorNode.ts +13 -2
  305. package/src/core/PeriodicWave.ts +36 -2
  306. package/src/core/RecorderAdapterNode.ts +5 -0
  307. package/src/core/StereoPannerNode.ts +9 -1
  308. package/src/core/StreamerNode.ts +29 -1
  309. package/src/core/WaveShaperNode.ts +17 -0
  310. package/src/core/WorkletNode.ts +30 -1
  311. package/src/core/WorkletProcessingNode.ts +39 -1
  312. package/src/core/WorkletSourceNode.ts +36 -1
  313. package/src/defaults.ts +100 -0
  314. package/src/interfaces.ts +37 -24
  315. package/src/options-validators.ts +66 -0
  316. package/src/types.ts +96 -12
  317. package/src/web-core/AnalyserNode.tsx +15 -6
  318. package/src/web-core/AudioBuffer.tsx +20 -6
  319. package/src/web-core/AudioBufferSourceNode.tsx +393 -148
  320. package/src/web-core/AudioContext.tsx +22 -72
  321. package/src/web-core/AudioNode.tsx +6 -2
  322. package/src/web-core/BaseAudioContext.tsx +3 -7
  323. package/src/web-core/BiquadFilterNode.tsx +6 -2
  324. package/src/web-core/ConstantSourceNode.tsx +3 -1
  325. package/src/web-core/ConvolverNode.tsx +8 -8
  326. package/src/web-core/DelayNode.tsx +5 -1
  327. package/src/web-core/GainNode.tsx +3 -1
  328. package/src/web-core/IIRFilterNode.tsx +15 -0
  329. package/src/web-core/OfflineAudioContext.tsx +19 -67
  330. package/src/web-core/OscillatorNode.tsx +3 -2
  331. package/src/web-core/PeriodicWave.tsx +11 -1
  332. package/src/web-core/StereoPannerNode.tsx +9 -1
@@ -22,7 +22,9 @@
22
22
  #include <audioapi/HostObjects/sources/WorkletSourceNodeHostObject.h>
23
23
  #include <audioapi/core/BaseAudioContext.h>
24
24
 
25
+ #include <audioapi/HostObjects/utils/NodeOptionsParser.h>
25
26
  #include <memory>
27
+ #include <utility>
26
28
  #include <vector>
27
29
 
28
30
  namespace audioapi {
@@ -165,14 +167,21 @@ JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createRecorderAdapter) {
165
167
  }
166
168
 
167
169
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createOscillator) {
168
- auto oscillator = context_->createOscillator();
170
+ const auto options = args[0].asObject(runtime);
171
+ const auto oscillatorOptions = audioapi::option_parser::parseOscillatorOptions(runtime, options);
172
+ auto oscillator = context_->createOscillator(oscillatorOptions);
169
173
  auto oscillatorHostObject = std::make_shared<OscillatorNodeHostObject>(oscillator);
170
174
  return jsi::Object::createFromHostObject(runtime, oscillatorHostObject);
171
175
  }
172
176
 
173
177
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createStreamer) {
174
178
  #if !RN_AUDIO_API_FFMPEG_DISABLED
175
- auto streamer = context_->createStreamer();
179
+ auto streamerOptions = StreamerOptions();
180
+ if (!args[0].isUndefined()) {
181
+ const auto options = args[0].asObject(runtime);
182
+ streamerOptions = audioapi::option_parser::parseStreamerOptions(runtime, options);
183
+ }
184
+ auto streamer = context_->createStreamer(streamerOptions);
176
185
  auto streamerHostObject = std::make_shared<StreamerNodeHostObject>(streamer);
177
186
  auto object = jsi::Object::createFromHostObject(runtime, streamerHostObject);
178
187
  object.setExternalMemoryPressure(runtime, StreamerNodeHostObject::getSizeInBytes());
@@ -183,20 +192,26 @@ JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createStreamer) {
183
192
  }
184
193
 
185
194
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createConstantSource) {
186
- auto constantSource = context_->createConstantSource();
195
+ const auto options = args[0].asObject(runtime);
196
+ const auto constantSourceOptions =
197
+ audioapi::option_parser::parseConstantSourceOptions(runtime, options);
198
+ auto constantSource = context_->createConstantSource(constantSourceOptions);
187
199
  auto constantSourceHostObject = std::make_shared<ConstantSourceNodeHostObject>(constantSource);
188
200
  return jsi::Object::createFromHostObject(runtime, constantSourceHostObject);
189
201
  }
190
202
 
191
203
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createGain) {
192
- auto gain = context_->createGain();
204
+ const auto options = args[0].asObject(runtime);
205
+ const auto gainOptions = audioapi::option_parser::parseGainOptions(runtime, options);
206
+ auto gain = context_->createGain(std::move(gainOptions));
193
207
  auto gainHostObject = std::make_shared<GainNodeHostObject>(gain);
194
208
  return jsi::Object::createFromHostObject(runtime, gainHostObject);
195
209
  }
196
210
 
197
211
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createDelay) {
198
- auto maxDelayTime = static_cast<float>(args[0].getNumber());
199
- auto delayNode = context_->createDelay(maxDelayTime);
212
+ const auto options = args[0].asObject(runtime);
213
+ const auto delayOptions = audioapi::option_parser::parseDelayOptions(runtime, options);
214
+ auto delayNode = context_->createDelay(delayOptions);
200
215
  auto delayNodeHostObject = std::make_shared<DelayNodeHostObject>(delayNode);
201
216
  auto jsiObject = jsi::Object::createFromHostObject(runtime, delayNodeHostObject);
202
217
  jsiObject.setExternalMemoryPressure(runtime, delayNodeHostObject->getSizeInBytes());
@@ -204,63 +219,52 @@ JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createDelay) {
204
219
  }
205
220
 
206
221
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createStereoPanner) {
207
- auto stereoPanner = context_->createStereoPanner();
222
+ const auto options = args[0].asObject(runtime);
223
+ const auto stereoPannerOptions = audioapi::option_parser::parseStereoPannerOptions(runtime, options);
224
+ auto stereoPanner = context_->createStereoPanner(stereoPannerOptions);
208
225
  auto stereoPannerHostObject = std::make_shared<StereoPannerNodeHostObject>(stereoPanner);
209
226
  return jsi::Object::createFromHostObject(runtime, stereoPannerHostObject);
210
227
  }
211
228
 
212
229
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createBiquadFilter) {
213
- auto biquadFilter = context_->createBiquadFilter();
230
+ const auto options = args[0].asObject(runtime);
231
+ const auto biquadFilterOptions = audioapi::option_parser::parseBiquadFilterOptions(runtime, options);
232
+ auto biquadFilter = context_->createBiquadFilter(biquadFilterOptions);
214
233
  auto biquadFilterHostObject = std::make_shared<BiquadFilterNodeHostObject>(biquadFilter);
215
234
  return jsi::Object::createFromHostObject(runtime, biquadFilterHostObject);
216
235
  }
217
236
 
218
237
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createIIRFilter) {
219
- auto feedforwardArray = args[0].asObject(runtime).asArray(runtime);
220
- auto feedbackArray = args[1].asObject(runtime).asArray(runtime);
221
-
222
- size_t feedforwardLength = feedforwardArray.length(runtime);
223
- size_t feedbackLength = feedbackArray.length(runtime);
224
-
225
- std::vector<float> feedforward;
226
- std::vector<float> feedback;
227
-
228
- feedforward.reserve(feedforwardLength);
229
- feedback.reserve(feedbackLength);
230
-
231
- for (size_t i = 0; i < feedforwardLength; ++i) {
232
- feedforward.push_back(feedforwardArray.getValueAtIndex(runtime, i).asNumber());
233
- }
234
-
235
- for (size_t i = 0; i < feedbackLength; ++i) {
236
- feedback.push_back(feedbackArray.getValueAtIndex(runtime, i).asNumber());
237
- }
238
-
239
- auto iirFilter = context_->createIIRFilter(feedforward, feedback);
238
+ const auto options = args[0].asObject(runtime);
239
+ const auto iirFilterOptions = audioapi::option_parser::parseIIRFilterOptions(runtime, options);
240
+ auto iirFilter = context_->createIIRFilter(iirFilterOptions);
240
241
  auto iirFilterHostObject = std::make_shared<IIRFilterNodeHostObject>(iirFilter);
241
242
  return jsi::Object::createFromHostObject(runtime, iirFilterHostObject);
242
243
  }
243
244
 
244
245
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createBufferSource) {
245
- auto pitchCorrection = args[0].asBool();
246
- auto bufferSource = context_->createBufferSource(pitchCorrection);
246
+ const auto options = args[0].asObject(runtime);
247
+ const auto audioBufferSourceOptions =
248
+ audioapi::option_parser::parseAudioBufferSourceOptions(runtime, options);
249
+ auto bufferSource = context_->createBufferSource(audioBufferSourceOptions);
247
250
  auto bufferSourceHostObject = std::make_shared<AudioBufferSourceNodeHostObject>(bufferSource);
248
251
  return jsi::Object::createFromHostObject(runtime, bufferSourceHostObject);
249
252
  }
250
253
 
251
254
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createBufferQueueSource) {
252
- auto pitchCorrection = args[0].asBool();
253
- auto bufferSource = context_->createBufferQueueSource(pitchCorrection);
255
+ const auto options = args[0].asObject(runtime);
256
+ const auto baseAudioBufferSourceOptions =
257
+ audioapi::option_parser::parseBaseAudioBufferSourceOptions(runtime, options);
258
+ auto bufferSource = context_->createBufferQueueSource(baseAudioBufferSourceOptions);
254
259
  auto bufferStreamSourceHostObject =
255
260
  std::make_shared<AudioBufferQueueSourceNodeHostObject>(bufferSource);
256
261
  return jsi::Object::createFromHostObject(runtime, bufferStreamSourceHostObject);
257
262
  }
258
263
 
259
264
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createBuffer) {
260
- auto numberOfChannels = static_cast<int>(args[0].getNumber());
261
- auto length = static_cast<size_t>(args[1].getNumber());
262
- auto sampleRate = static_cast<float>(args[2].getNumber());
263
- auto buffer = BaseAudioContext::createBuffer(numberOfChannels, length, sampleRate);
265
+ const auto options = args[0].asObject(runtime);
266
+ const auto audioBufferOptions = audioapi::option_parser::parseAudioBufferOptions(runtime, options);
267
+ auto buffer = BaseAudioContext::createBuffer(audioBufferOptions);
264
268
  auto bufferHostObject = std::make_shared<AudioBufferHostObject>(buffer);
265
269
 
266
270
  auto jsiObject = jsi::Object::createFromHostObject(runtime, bufferHostObject);
@@ -294,31 +298,30 @@ JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createPeriodicWave) {
294
298
  }
295
299
 
296
300
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createAnalyser) {
297
- auto analyser = context_->createAnalyser();
301
+ const auto options = args[0].asObject(runtime);
302
+ const auto analyserOptions = audioapi::option_parser::parseAnalyserOptions(runtime, options);
303
+ auto analyser = context_->createAnalyser(analyserOptions);
298
304
  auto analyserHostObject = std::make_shared<AnalyserNodeHostObject>(analyser);
299
305
  return jsi::Object::createFromHostObject(runtime, analyserHostObject);
300
306
  }
301
307
 
302
308
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createConvolver) {
303
- auto disableNormalization = args[1].getBool();
304
- std::shared_ptr<ConvolverNode> convolver;
305
- if (args[0].isUndefined()) {
306
- convolver = context_->createConvolver(nullptr, disableNormalization);
307
- } else {
308
- auto bufferHostObject = args[0].getObject(runtime).asHostObject<AudioBufferHostObject>(runtime);
309
- convolver = context_->createConvolver(bufferHostObject->audioBuffer_, disableNormalization);
310
- }
309
+ const auto options = args[0].asObject(runtime);
310
+ const auto convolverOptions = audioapi::option_parser::parseConvolverOptions(runtime, options);
311
+ auto convolver = context_->createConvolver(convolverOptions);
311
312
  auto convolverHostObject = std::make_shared<ConvolverNodeHostObject>(convolver);
312
313
  auto jsiObject = jsi::Object::createFromHostObject(runtime, convolverHostObject);
313
- if (!args[0].isUndefined()) {
314
- auto bufferHostObject = args[0].getObject(runtime).asHostObject<AudioBufferHostObject>(runtime);
314
+ if (convolverOptions.bus != nullptr) {
315
+ auto bufferHostObject = options.getProperty(runtime, "buffer").getObject(runtime).asHostObject<AudioBufferHostObject>(runtime);
315
316
  jsiObject.setExternalMemoryPressure(runtime, bufferHostObject->getSizeInBytes());
316
317
  }
317
318
  return jsiObject;
318
319
  }
319
320
 
320
321
  JSI_HOST_FUNCTION_IMPL(BaseAudioContextHostObject, createWaveShaper) {
321
- auto waveShaper = context_->createWaveShaper();
322
+ const auto options = args[0].asObject(runtime);
323
+ const auto waveShaperOptions = audioapi::option_parser::parseWaveShaperOptions(runtime, options);
324
+ auto waveShaper = context_->createWaveShaper(waveShaperOptions);
322
325
  auto waveShaperHostObject = std::make_shared<WaveShaperNodeHostObject>(waveShaper);
323
326
  return jsi::Object::createFromHostObject(runtime, waveShaperHostObject);
324
327
  }
@@ -10,6 +10,12 @@ namespace audioapi {
10
10
  StreamerNodeHostObject::StreamerNodeHostObject(const std::shared_ptr<StreamerNode> &node)
11
11
  : AudioScheduledSourceNodeHostObject(node) {
12
12
  addFunctions(JSI_EXPORT_FUNCTION(StreamerNodeHostObject, initialize));
13
+ addGetters(JSI_EXPORT_PROPERTY_GETTER(StreamerNodeHostObject, streamPath));
14
+ }
15
+
16
+ JSI_PROPERTY_GETTER_IMPL(StreamerNodeHostObject, streamPath) {
17
+ auto streamerNode = std::static_pointer_cast<StreamerNode>(node_);
18
+ return jsi::String::createFromUtf8(runtime, streamerNode->getStreamPath());
13
19
  }
14
20
 
15
21
  JSI_HOST_FUNCTION_IMPL(StreamerNodeHostObject, initialize) {
@@ -19,6 +19,7 @@ class StreamerNodeHostObject : public AudioScheduledSourceNodeHostObject {
19
19
  return SIZE;
20
20
  }
21
21
 
22
+ JSI_PROPERTY_GETTER_DECL(streamPath);
22
23
  JSI_HOST_FUNCTION_DECL(initialize);
23
24
 
24
25
  private:
@@ -0,0 +1,111 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+ #include <utility>
6
+ #include <vector>
7
+
8
+ #include <audioapi/core/effects/PeriodicWave.h>
9
+ #include <audioapi/core/sources/AudioBuffer.h>
10
+ #include <audioapi/core/types/BiquadFilterType.h>
11
+ #include <audioapi/core/types/ChannelCountMode.h>
12
+ #include <audioapi/core/types/ChannelInterpretation.h>
13
+ #include <audioapi/core/types/OscillatorType.h>
14
+ #include <audioapi/core/types/OverSampleType.h>
15
+ #include <audioapi/utils/AudioArray.h>
16
+
17
+ namespace audioapi {
18
+ struct AudioNodeOptions {
19
+ int channelCount = 2;
20
+ ChannelCountMode channelCountMode;
21
+ ChannelInterpretation channelInterpretation;
22
+ };
23
+
24
+ struct GainOptions : AudioNodeOptions {
25
+ float gain;
26
+ };
27
+
28
+ struct StereoPannerOptions : AudioNodeOptions {
29
+ float pan;
30
+ };
31
+
32
+ struct ConvolverOptions : AudioNodeOptions {
33
+ std::shared_ptr<AudioBuffer> bus;
34
+ bool disableNormalization;
35
+ };
36
+
37
+ struct ConstantSourceOptions {
38
+ float offset;
39
+ };
40
+
41
+ struct AnalyserOptions : AudioNodeOptions {
42
+ int fftSize;
43
+ float minDecibels;
44
+ float maxDecibels;
45
+ float smoothingTimeConstant;
46
+ };
47
+
48
+ struct BiquadFilterOptions : AudioNodeOptions {
49
+ BiquadFilterType type;
50
+ float frequency;
51
+ float detune;
52
+ float Q;
53
+ float gain;
54
+ };
55
+
56
+ struct OscillatorOptions {
57
+ std::shared_ptr<PeriodicWave> periodicWave;
58
+ float frequency;
59
+ float detune;
60
+ OscillatorType type;
61
+ };
62
+
63
+ struct BaseAudioBufferSourceOptions {
64
+ float detune;
65
+ bool pitchCorrection;
66
+ float playbackRate;
67
+ };
68
+
69
+ struct AudioBufferSourceOptions : BaseAudioBufferSourceOptions {
70
+ std::shared_ptr<AudioBuffer> buffer;
71
+ bool loop;
72
+ float loopStart;
73
+ float loopEnd;
74
+ };
75
+
76
+ struct StreamerOptions {
77
+ std::string streamPath;
78
+ };
79
+
80
+ struct AudioBufferOptions {
81
+ int numberOfChannels;
82
+ size_t length;
83
+ float sampleRate;
84
+ };
85
+
86
+ struct DelayOptions : AudioNodeOptions {
87
+ float maxDelayTime;
88
+ float delayTime;
89
+ };
90
+
91
+ struct IIRFilterOptions : AudioNodeOptions {
92
+ std::vector<float> feedforward;
93
+ std::vector<float> feedback;
94
+
95
+ IIRFilterOptions() = default;
96
+
97
+ explicit IIRFilterOptions(const AudioNodeOptions options) : AudioNodeOptions(options) {}
98
+
99
+ IIRFilterOptions(const std::vector<float> &ff, const std::vector<float> &fb)
100
+ : feedforward(ff), feedback(fb) {}
101
+
102
+ IIRFilterOptions(std::vector<float> &&ff, std::vector<float> &&fb)
103
+ : feedforward(std::move(ff)), feedback(std::move(fb)) {}
104
+ };
105
+
106
+ struct WaveShaperOptions : AudioNodeOptions {
107
+ std::shared_ptr<AudioArray> curve;
108
+ OverSampleType oversample;
109
+ };
110
+
111
+ } // namespace audioapi
@@ -0,0 +1,262 @@
1
+ #pragma once
2
+
3
+ #include <audioapi/jsi/RuntimeLifecycleMonitor.h>
4
+ #include <jsi/jsi.h>
5
+ #include <cstddef>
6
+ #include <memory>
7
+ #include <utility>
8
+ #include <vector>
9
+
10
+ #include <audioapi/HostObjects/effects/PeriodicWaveHostObject.h>
11
+ #include <audioapi/HostObjects/sources/AudioBufferHostObject.h>
12
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
13
+
14
+ namespace audioapi::option_parser {
15
+ AudioNodeOptions parseAudioNodeOptions(jsi::Runtime &runtime, const jsi::Object &optionsObject) {
16
+ AudioNodeOptions options;
17
+
18
+ options.channelCount =
19
+ static_cast<int>(optionsObject.getProperty(runtime, "channelCount").getNumber());
20
+
21
+ auto channelCountModeStr =
22
+ optionsObject.getProperty(runtime, "channelCountMode").asString(runtime).utf8(runtime);
23
+
24
+ if (channelCountModeStr == "max") {
25
+ options.channelCountMode = ChannelCountMode::MAX;
26
+ } else if (channelCountModeStr == "clamped-max") {
27
+ options.channelCountMode = ChannelCountMode::CLAMPED_MAX;
28
+ } else if (channelCountModeStr == "explicit") {
29
+ options.channelCountMode = ChannelCountMode::EXPLICIT;
30
+ }
31
+
32
+ auto channelInterpretationStr =
33
+ optionsObject.getProperty(runtime, "channelInterpretation").asString(runtime).utf8(runtime);
34
+
35
+ if (channelInterpretationStr == "speakers") {
36
+ options.channelInterpretation = ChannelInterpretation::SPEAKERS;
37
+ } else if (channelInterpretationStr == "discrete") {
38
+ options.channelInterpretation = ChannelInterpretation::DISCRETE;
39
+ }
40
+
41
+ return options;
42
+ }
43
+
44
+ GainOptions parseGainOptions(jsi::Runtime &runtime, const jsi::Object &optionsObject) {
45
+ GainOptions options(parseAudioNodeOptions(runtime, optionsObject));
46
+ options.gain = static_cast<float>(optionsObject.getProperty(runtime, "gain").getNumber());
47
+ return options;
48
+ }
49
+
50
+ StereoPannerOptions parseStereoPannerOptions(
51
+ jsi::Runtime &runtime,
52
+ const jsi::Object &optionsObject) {
53
+ StereoPannerOptions options(parseAudioNodeOptions(runtime, optionsObject));
54
+ options.pan = static_cast<float>(optionsObject.getProperty(runtime, "pan").getNumber());
55
+ return options;
56
+ }
57
+
58
+ ConvolverOptions parseConvolverOptions(jsi::Runtime &runtime, const jsi::Object &optionsObject) {
59
+ ConvolverOptions options(parseAudioNodeOptions(runtime, optionsObject));
60
+ options.disableNormalization =
61
+ optionsObject.getProperty(runtime, "disableNormalization").getBool();
62
+ if (optionsObject.hasProperty(runtime, "buffer")) {
63
+ auto bufferHostObject = optionsObject.getProperty(runtime, "buffer")
64
+ .getObject(runtime)
65
+ .asHostObject<AudioBufferHostObject>(runtime);
66
+ options.bus = bufferHostObject->audioBuffer_;
67
+ }
68
+ return options;
69
+ }
70
+
71
+ ConstantSourceOptions parseConstantSourceOptions(
72
+ jsi::Runtime &runtime,
73
+ const jsi::Object &optionsObject) {
74
+ ConstantSourceOptions options;
75
+ options.offset = static_cast<float>(optionsObject.getProperty(runtime, "offset").getNumber());
76
+ return options;
77
+ }
78
+
79
+ AnalyserOptions parseAnalyserOptions(jsi::Runtime &runtime, const jsi::Object &optionsObject) {
80
+ AnalyserOptions options(parseAudioNodeOptions(runtime, optionsObject));
81
+ options.fftSize = static_cast<int>(optionsObject.getProperty(runtime, "fftSize").getNumber());
82
+ options.minDecibels =
83
+ static_cast<float>(optionsObject.getProperty(runtime, "minDecibels").getNumber());
84
+ options.maxDecibels =
85
+ static_cast<float>(optionsObject.getProperty(runtime, "maxDecibels").getNumber());
86
+ options.smoothingTimeConstant =
87
+ static_cast<float>(optionsObject.getProperty(runtime, "smoothingTimeConstant").getNumber());
88
+ return options;
89
+ }
90
+
91
+ BiquadFilterOptions parseBiquadFilterOptions(
92
+ jsi::Runtime &runtime,
93
+ const jsi::Object &optionsObject) {
94
+ BiquadFilterOptions options(parseAudioNodeOptions(runtime, optionsObject));
95
+
96
+ auto typeStr = optionsObject.getProperty(runtime, "type").asString(runtime).utf8(runtime);
97
+
98
+ if (typeStr == "lowpass") {
99
+ options.type = BiquadFilterType::LOWPASS;
100
+ } else if (typeStr == "highpass") {
101
+ options.type = BiquadFilterType::HIGHPASS;
102
+ } else if (typeStr == "bandpass") {
103
+ options.type = BiquadFilterType::BANDPASS;
104
+ } else if (typeStr == "lowshelf") {
105
+ options.type = BiquadFilterType::LOWSHELF;
106
+ } else if (typeStr == "highshelf") {
107
+ options.type = BiquadFilterType::HIGHSHELF;
108
+ } else if (typeStr == "peaking") {
109
+ options.type = BiquadFilterType::PEAKING;
110
+ } else if (typeStr == "notch") {
111
+ options.type = BiquadFilterType::NOTCH;
112
+ } else if (typeStr == "allpass") {
113
+ options.type = BiquadFilterType::ALLPASS;
114
+ }
115
+
116
+ options.frequency =
117
+ static_cast<float>(optionsObject.getProperty(runtime, "frequency").getNumber());
118
+ options.detune = static_cast<float>(optionsObject.getProperty(runtime, "detune").getNumber());
119
+ options.Q = static_cast<float>(optionsObject.getProperty(runtime, "Q").getNumber());
120
+ options.gain = static_cast<float>(optionsObject.getProperty(runtime, "gain").getNumber());
121
+
122
+ return options;
123
+ }
124
+
125
+ OscillatorOptions parseOscillatorOptions(jsi::Runtime &runtime, const jsi::Object &optionsObject) {
126
+ OscillatorOptions options;
127
+
128
+ auto typeStr = optionsObject.getProperty(runtime, "type").asString(runtime).utf8(runtime);
129
+
130
+ if (typeStr == "sine") {
131
+ options.type = OscillatorType::SINE;
132
+ } else if (typeStr == "square") {
133
+ options.type = OscillatorType::SQUARE;
134
+ } else if (typeStr == "sawtooth") {
135
+ options.type = OscillatorType::SAWTOOTH;
136
+ } else if (typeStr == "triangle") {
137
+ options.type = OscillatorType::TRIANGLE;
138
+ } else if (typeStr == "custom") {
139
+ options.type = OscillatorType::CUSTOM;
140
+ }
141
+
142
+ options.frequency =
143
+ static_cast<float>(optionsObject.getProperty(runtime, "frequency").getNumber());
144
+ options.detune = static_cast<float>(optionsObject.getProperty(runtime, "detune").getNumber());
145
+
146
+ if (optionsObject.hasProperty(runtime, "periodicWave")) {
147
+ auto periodicWaveHostObject = optionsObject.getProperty(runtime, "periodicWave")
148
+ .getObject(runtime)
149
+ .asHostObject<PeriodicWaveHostObject>(runtime);
150
+ options.periodicWave = periodicWaveHostObject->periodicWave_;
151
+ }
152
+
153
+ return options;
154
+ }
155
+
156
+ BaseAudioBufferSourceOptions parseBaseAudioBufferSourceOptions(
157
+ jsi::Runtime &runtime,
158
+ const jsi::Object &optionsObject) {
159
+ BaseAudioBufferSourceOptions options;
160
+ options.detune = static_cast<float>(optionsObject.getProperty(runtime, "detune").getNumber());
161
+ options.playbackRate =
162
+ static_cast<float>(optionsObject.getProperty(runtime, "playbackRate").getNumber());
163
+ options.pitchCorrection =
164
+ static_cast<bool>(optionsObject.getProperty(runtime, "pitchCorrection").getBool());
165
+ return options;
166
+ }
167
+
168
+ AudioBufferSourceOptions parseAudioBufferSourceOptions(
169
+ jsi::Runtime &runtime,
170
+ const jsi::Object &optionsObject) {
171
+ AudioBufferSourceOptions options(parseBaseAudioBufferSourceOptions(runtime, optionsObject));
172
+ if (optionsObject.hasProperty(runtime, "buffer")) {
173
+ auto bufferHostObject = optionsObject.getProperty(runtime, "buffer")
174
+ .getObject(runtime)
175
+ .asHostObject<AudioBufferHostObject>(runtime);
176
+ options.buffer = bufferHostObject->audioBuffer_;
177
+ }
178
+ options.loop = static_cast<bool>(optionsObject.getProperty(runtime, "loop").getBool());
179
+ options.loopStart =
180
+ static_cast<float>(optionsObject.getProperty(runtime, "loopStart").getNumber());
181
+ options.loopEnd = static_cast<float>(optionsObject.getProperty(runtime, "loopEnd").getNumber());
182
+ return options;
183
+ }
184
+
185
+ StreamerOptions parseStreamerOptions(jsi::Runtime &runtime, const jsi::Object &optionsObject) {
186
+ auto options = StreamerOptions();
187
+ if (optionsObject.hasProperty(runtime, "streamPath")) {
188
+ options.streamPath =
189
+ optionsObject.getProperty(runtime, "streamPath").asString(runtime).utf8(runtime);
190
+ }
191
+ return options;
192
+ }
193
+
194
+ AudioBufferOptions parseAudioBufferOptions(
195
+ jsi::Runtime &runtime,
196
+ const jsi::Object &optionsObject) {
197
+ AudioBufferOptions options;
198
+ options.numberOfChannels =
199
+ static_cast<int>(optionsObject.getProperty(runtime, "numberOfChannels").getNumber());
200
+ options.length = static_cast<size_t>(optionsObject.getProperty(runtime, "length").getNumber());
201
+ options.sampleRate =
202
+ static_cast<float>(optionsObject.getProperty(runtime, "sampleRate").getNumber());
203
+ return options;
204
+ }
205
+
206
+ DelayOptions parseDelayOptions(jsi::Runtime &runtime, const jsi::Object &optionsObject) {
207
+ DelayOptions options(parseAudioNodeOptions(runtime, optionsObject));
208
+ options.maxDelayTime =
209
+ static_cast<float>(optionsObject.getProperty(runtime, "maxDelayTime").getNumber());
210
+ options.delayTime =
211
+ static_cast<float>(optionsObject.getProperty(runtime, "delayTime").getNumber());
212
+ return options;
213
+ }
214
+
215
+ IIRFilterOptions parseIIRFilterOptions(jsi::Runtime &runtime, const jsi::Object &optionsObject) {
216
+ IIRFilterOptions options(parseAudioNodeOptions(runtime, optionsObject));
217
+
218
+ auto feedforwardArray =
219
+ optionsObject.getProperty(runtime, "feedforward").asObject(runtime).asArray(runtime);
220
+ size_t feedforwardLength = feedforwardArray.size(runtime);
221
+ options.feedforward.reserve(feedforwardLength);
222
+ for (size_t i = 0; i < feedforwardLength; ++i) {
223
+ options.feedforward.push_back(
224
+ static_cast<float>(feedforwardArray.getValueAtIndex(runtime, i).getNumber()));
225
+ }
226
+
227
+ auto feedbackArray =
228
+ optionsObject.getProperty(runtime, "feedback").asObject(runtime).asArray(runtime);
229
+ size_t feedbackLength = feedbackArray.size(runtime);
230
+ options.feedback.reserve(feedbackLength);
231
+ for (size_t i = 0; i < feedbackLength; ++i) {
232
+ options.feedback.push_back(
233
+ static_cast<float>(feedbackArray.getValueAtIndex(runtime, i).getNumber()));
234
+ }
235
+
236
+ return options;
237
+ }
238
+
239
+ WaveShaperOptions parseWaveShaperOptions(jsi::Runtime &runtime, const jsi::Object &optionsObject) {
240
+ WaveShaperOptions options(parseAudioNodeOptions(runtime, optionsObject));
241
+
242
+ auto oversampleStr =
243
+ optionsObject.getProperty(runtime, "oversample").asString(runtime).utf8(runtime);
244
+
245
+ if (oversampleStr == "none") {
246
+ options.oversample = OverSampleType::OVERSAMPLE_NONE;
247
+ } else if (oversampleStr == "2x") {
248
+ options.oversample = OverSampleType::OVERSAMPLE_2X;
249
+ } else if (oversampleStr == "4x") {
250
+ options.oversample = OverSampleType::OVERSAMPLE_4X;
251
+ }
252
+
253
+ if (optionsObject.hasProperty(runtime, "buffer")) {
254
+ auto arrayBuffer = optionsObject.getPropertyAsObject(runtime, "buffer").getArrayBuffer(runtime);
255
+
256
+ options.curve = std::make_shared<AudioArray>(
257
+ reinterpret_cast<float *>(arrayBuffer.data(runtime)),
258
+ static_cast<size_t>(arrayBuffer.size(runtime) / sizeof(float)));
259
+ }
260
+ return options;
261
+ }
262
+ } // namespace audioapi::option_parser
@@ -1,3 +1,4 @@
1
+ #include <audioapi/HostObjects/utils/NodeOptions.h>
1
2
  #include <audioapi/core/AudioNode.h>
2
3
  #include <audioapi/core/AudioParam.h>
3
4
  #include <audioapi/core/BaseAudioContext.h>
@@ -10,13 +11,19 @@
10
11
 
11
12
  namespace audioapi {
12
13
 
13
- AudioNode::AudioNode(std::shared_ptr<BaseAudioContext> context)
14
+ AudioNode::AudioNode(std::shared_ptr<BaseAudioContext> context) : context_(context) {
15
+ audioBus_ =
16
+ std::make_shared<AudioBus>(RENDER_QUANTUM_SIZE, channelCount_, context->getSampleRate());
17
+ }
18
+
19
+ AudioNode::AudioNode(std::shared_ptr<BaseAudioContext> context, const AudioNodeOptions &options)
14
20
  : context_(context),
15
- audioBus_(
16
- std::make_shared<AudioBus>(
17
- RENDER_QUANTUM_SIZE,
18
- channelCount_,
19
- context->getSampleRate())) {}
21
+ channelCount_(options.channelCount),
22
+ channelCountMode_(options.channelCountMode),
23
+ channelInterpretation_(options.channelInterpretation) {
24
+ audioBus_ =
25
+ std::make_shared<AudioBus>(RENDER_QUANTUM_SIZE, channelCount_, context->getSampleRate());
26
+ }
20
27
 
21
28
  AudioNode::~AudioNode() {
22
29
  if (isInitialized_) {
@@ -16,10 +16,12 @@ namespace audioapi {
16
16
  class AudioBus;
17
17
  class BaseAudioContext;
18
18
  class AudioParam;
19
+ class AudioNodeOptions;
19
20
 
20
21
  class AudioNode : public std::enable_shared_from_this<AudioNode> {
21
22
  public:
22
23
  explicit AudioNode(std::shared_ptr<BaseAudioContext> context);
24
+ explicit AudioNode(std::shared_ptr<BaseAudioContext> context, const AudioNodeOptions &options);
23
25
  virtual ~AudioNode();
24
26
 
25
27
  int getNumberOfInputs() const;