@babylonjs/core 7.52.1 → 7.52.3

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 (247) hide show
  1. package/AudioV2/abstractAudio/abstractAudioBus.d.ts +11 -0
  2. package/AudioV2/abstractAudio/abstractAudioBus.js +10 -0
  3. package/AudioV2/abstractAudio/abstractAudioBus.js.map +1 -1
  4. package/AudioV2/abstractAudio/abstractSound.d.ts +11 -5
  5. package/AudioV2/abstractAudio/abstractSound.js +11 -5
  6. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  7. package/AudioV2/abstractAudio/audioBus.d.ts +5 -6
  8. package/AudioV2/abstractAudio/audioBus.js +1 -5
  9. package/AudioV2/abstractAudio/audioBus.js.map +1 -1
  10. package/AudioV2/abstractAudio/audioEngineV2.d.ts +1 -2
  11. package/AudioV2/abstractAudio/audioEngineV2.js +1 -5
  12. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  13. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +43 -0
  14. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +71 -0
  15. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -0
  16. package/AudioV2/abstractAudio/mainAudioBus.d.ts +2 -2
  17. package/AudioV2/abstractAudio/mainAudioBus.js.map +1 -1
  18. package/AudioV2/abstractAudio/staticSound.d.ts +6 -6
  19. package/AudioV2/abstractAudio/staticSound.js +5 -5
  20. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  21. package/AudioV2/abstractAudio/streamingSound.d.ts +2 -2
  22. package/AudioV2/abstractAudio/streamingSound.js +3 -3
  23. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  24. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.d.ts +30 -6
  25. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +44 -21
  26. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
  27. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.d.ts +24 -0
  28. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js +30 -0
  29. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js.map +1 -0
  30. package/AudioV2/abstractAudio/subNodes/audioSubNode.d.ts +1 -0
  31. package/AudioV2/abstractAudio/subNodes/audioSubNode.js +1 -0
  32. package/AudioV2/abstractAudio/subNodes/audioSubNode.js.map +1 -1
  33. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +15 -0
  34. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +38 -3
  35. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
  36. package/AudioV2/abstractAudio/subNodes/stereoAudioSubNode.js.map +1 -1
  37. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.d.ts +86 -0
  38. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js +29 -0
  39. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js.map +1 -0
  40. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +29 -8
  41. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +1 -0
  42. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
  43. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +28 -1
  44. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js +5 -1
  45. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
  46. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.d.ts +35 -0
  47. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js +96 -0
  48. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js.map +1 -0
  49. package/AudioV2/abstractAudio/subProperties/index.d.ts +1 -0
  50. package/AudioV2/abstractAudio/subProperties/index.js +1 -0
  51. package/AudioV2/abstractAudio/subProperties/index.js.map +1 -1
  52. package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +16 -1
  53. package/AudioV2/abstractAudio/subProperties/spatialAudio.js +48 -14
  54. package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
  55. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +21 -0
  56. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +39 -4
  57. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
  58. package/AudioV2/index.d.ts +1 -0
  59. package/AudioV2/index.js +1 -0
  60. package/AudioV2/index.js.map +1 -1
  61. package/AudioV2/spatialAudioAttachmentType.d.ts +5 -0
  62. package/AudioV2/spatialAudioAttachmentType.js +7 -0
  63. package/AudioV2/spatialAudioAttachmentType.js.map +1 -0
  64. package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.d.ts +13 -0
  65. package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js +38 -0
  66. package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js.map +1 -0
  67. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +13 -14
  68. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +39 -39
  69. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
  70. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.d.ts +37 -0
  71. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js +85 -0
  72. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js.map +1 -0
  73. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.d.ts +5 -3
  74. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js +25 -2
  75. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js.map +1 -1
  76. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.d.ts +2 -1
  77. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +32 -17
  78. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
  79. package/AudioV2/webAudio/subProperties/spatialWebAudio.d.ts +6 -2
  80. package/AudioV2/webAudio/subProperties/spatialWebAudio.js +13 -15
  81. package/AudioV2/webAudio/subProperties/spatialWebAudio.js.map +1 -1
  82. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.d.ts +1 -1
  83. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +41 -56
  84. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
  85. package/AudioV2/webAudio/webAudioBus.d.ts +3 -0
  86. package/AudioV2/webAudio/webAudioBus.js +23 -2
  87. package/AudioV2/webAudio/webAudioBus.js.map +1 -1
  88. package/AudioV2/webAudio/webAudioEngine.d.ts +3 -1
  89. package/AudioV2/webAudio/webAudioEngine.js +11 -3
  90. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  91. package/AudioV2/webAudio/webAudioStaticSound.d.ts +3 -0
  92. package/AudioV2/webAudio/webAudioStaticSound.js +23 -2
  93. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  94. package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -0
  95. package/AudioV2/webAudio/webAudioStreamingSound.js +23 -2
  96. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  97. package/Engines/WebGPU/webgpuTextureManager.d.ts +0 -1
  98. package/Engines/WebGPU/webgpuTextureManager.js +2 -57
  99. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  100. package/Engines/abstractEngine.d.ts +6 -0
  101. package/Engines/abstractEngine.js +3 -3
  102. package/Engines/abstractEngine.js.map +1 -1
  103. package/Engines/engine.common.js +4 -0
  104. package/Engines/engine.common.js.map +1 -1
  105. package/Engines/nativeEngine.d.ts +1 -0
  106. package/Engines/nativeEngine.js +3 -0
  107. package/Engines/nativeEngine.js.map +1 -1
  108. package/Engines/nullEngine.d.ts +1 -0
  109. package/Engines/nullEngine.js +1 -0
  110. package/Engines/nullEngine.js.map +1 -1
  111. package/Engines/thinEngine.d.ts +1 -0
  112. package/Engines/thinEngine.js +7 -4
  113. package/Engines/thinEngine.js.map +1 -1
  114. package/Engines/webgpuEngine.d.ts +2 -1
  115. package/Engines/webgpuEngine.js +12 -9
  116. package/Engines/webgpuEngine.js.map +1 -1
  117. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.d.ts +48 -0
  118. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js +54 -0
  119. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js.map +1 -0
  120. package/FlowGraph/Blocks/Data/index.d.ts +1 -0
  121. package/FlowGraph/Blocks/Data/index.js +1 -0
  122. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  123. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +1 -0
  124. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +19 -13
  125. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  126. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +3 -5
  127. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  128. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js +1 -1
  129. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js.map +1 -1
  130. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js +2 -4
  131. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js.map +1 -1
  132. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +1 -1
  133. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
  134. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +1 -2
  135. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  136. package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
  137. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
  138. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +2 -1
  139. package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
  140. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
  141. package/FlowGraph/CustomTypes/flowGraphInteger.d.ts +1 -0
  142. package/FlowGraph/CustomTypes/flowGraphInteger.js +3 -0
  143. package/FlowGraph/CustomTypes/flowGraphInteger.js.map +1 -1
  144. package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +2 -0
  145. package/FlowGraph/CustomTypes/flowGraphMatrix.js +6 -0
  146. package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
  147. package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -0
  148. package/FlowGraph/flowGraphExecutionBlock.js +4 -0
  149. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  150. package/FlowGraph/utils.d.ts +2 -1
  151. package/FlowGraph/utils.js +7 -2
  152. package/FlowGraph/utils.js.map +1 -1
  153. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +2 -2
  154. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
  155. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +2 -2
  156. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -1
  157. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.d.ts +126 -0
  158. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +497 -0
  159. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -0
  160. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
  161. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +30 -4
  162. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
  163. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  164. package/FrameGraph/Node/Blocks/index.js +1 -0
  165. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  166. package/FrameGraph/Node/nodeRenderGraph.js +1 -1
  167. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  168. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +2 -3
  169. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +3 -4
  170. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  171. package/FrameGraph/Tasks/PostProcesses/blurTask.js +2 -2
  172. package/FrameGraph/Tasks/PostProcesses/blurTask.js.map +1 -1
  173. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +2 -3
  174. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +4 -5
  175. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
  176. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +6 -0
  177. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +14 -0
  178. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  179. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.d.ts +11 -0
  180. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js +18 -0
  181. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js.map +1 -0
  182. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.d.ts +76 -0
  183. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +170 -0
  184. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -0
  185. package/FrameGraph/Tasks/PostProcesses/ssrTask.d.ts +16 -0
  186. package/FrameGraph/Tasks/PostProcesses/ssrTask.js +45 -0
  187. package/FrameGraph/Tasks/PostProcesses/ssrTask.js.map +1 -0
  188. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +10 -0
  189. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +29 -0
  190. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  191. package/FrameGraph/frameGraph.d.ts +7 -3
  192. package/FrameGraph/frameGraph.js +10 -4
  193. package/FrameGraph/frameGraph.js.map +1 -1
  194. package/FrameGraph/frameGraphTextureManager.d.ts +2 -1
  195. package/FrameGraph/frameGraphTextureManager.js +4 -3
  196. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  197. package/FrameGraph/index.d.ts +1 -0
  198. package/FrameGraph/index.js +1 -0
  199. package/FrameGraph/index.js.map +1 -1
  200. package/Materials/PBR/pbrBaseMaterial.js +1 -1
  201. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  202. package/Materials/effectRenderer.js +1 -1
  203. package/Materials/effectRenderer.js.map +1 -1
  204. package/Materials/material.js +5 -3
  205. package/Materials/material.js.map +1 -1
  206. package/Materials/materialHelper.geometryrendering.d.ts +7 -5
  207. package/Materials/materialHelper.geometryrendering.js +8 -3
  208. package/Materials/materialHelper.geometryrendering.js.map +1 -1
  209. package/Materials/standardMaterial.js +1 -1
  210. package/Materials/standardMaterial.js.map +1 -1
  211. package/Meshes/geometry.js +18 -7
  212. package/Meshes/geometry.js.map +1 -1
  213. package/Meshes/mesh.vertexData.d.ts +1 -1
  214. package/Meshes/mesh.vertexData.js +2 -1
  215. package/Meshes/mesh.vertexData.js.map +1 -1
  216. package/Particles/particleSystemComponent.d.ts +2 -1
  217. package/Particles/particleSystemComponent.js +2 -2
  218. package/Particles/particleSystemComponent.js.map +1 -1
  219. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +23 -30
  220. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +226 -411
  221. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  222. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.d.ts +222 -0
  223. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js +373 -0
  224. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js.map +1 -0
  225. package/PostProcesses/thinDepthOfFieldEffect.d.ts +4 -4
  226. package/PostProcesses/thinDepthOfFieldEffect.js.map +1 -1
  227. package/PostProcesses/thinSSRBlurCombinerPostProcess.d.ts +41 -0
  228. package/PostProcesses/thinSSRBlurCombinerPostProcess.js +185 -0
  229. package/PostProcesses/thinSSRBlurCombinerPostProcess.js.map +1 -0
  230. package/PostProcesses/thinSSRBlurPostProcess.d.ts +18 -0
  231. package/PostProcesses/thinSSRBlurPostProcess.js +47 -0
  232. package/PostProcesses/thinSSRBlurPostProcess.js.map +1 -0
  233. package/PostProcesses/thinSSRPostProcess.d.ts +94 -0
  234. package/PostProcesses/thinSSRPostProcess.js +416 -0
  235. package/PostProcesses/thinSSRPostProcess.js.map +1 -0
  236. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +2 -0
  237. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -0
  238. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  239. package/Rendering/iblCdfGenerator.js +1 -1
  240. package/Rendering/iblCdfGenerator.js.map +1 -1
  241. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
  242. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
  243. package/ShadersWGSL/geometry.fragment.js +1 -1
  244. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  245. package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
  246. package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
  247. package/package.json +1 -1
@@ -1,6 +1,12 @@
1
1
  import { AbstractNamedAudioNode } from "./abstractAudioNode";
2
2
  import type { AudioEngineV2 } from "./audioEngineV2";
3
3
  import type { _AbstractAudioSubGraph } from "./subNodes/abstractAudioSubGraph";
4
+ import type { IVolumeAudioOptions } from "./subNodes/volumeAudioSubNode";
5
+ import type { IAudioAnalyzerOptions } from "./subProperties/abstractAudioAnalyzer";
6
+ import { _AudioAnalyzer } from "./subProperties/audioAnalyzer";
7
+ /** @internal */
8
+ export interface IAbstractAudioBusOptions extends IAudioAnalyzerOptions, IVolumeAudioOptions {
9
+ }
4
10
  /**
5
11
  * Abstract class representing an audio bus with volume control.
6
12
  *
@@ -8,8 +14,13 @@ import type { _AbstractAudioSubGraph } from "./subNodes/abstractAudioSubGraph";
8
14
  * sounds together and apply effects to them.
9
15
  */
10
16
  export declare abstract class AbstractAudioBus extends AbstractNamedAudioNode {
17
+ private _analyzer;
11
18
  protected abstract _subGraph: _AbstractAudioSubGraph;
12
19
  protected constructor(name: string, engine: AudioEngineV2);
20
+ /**
21
+ * The analyzer features of the bus.
22
+ */
23
+ get analyzer(): _AudioAnalyzer;
13
24
  /**
14
25
  * The output volume of the bus.
15
26
  */
@@ -1,5 +1,6 @@
1
1
  import { AbstractNamedAudioNode } from "./abstractAudioNode.js";
2
2
  import { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from "./subNodes/volumeAudioSubNode.js";
3
+ import { _AudioAnalyzer } from "./subProperties/audioAnalyzer.js";
3
4
  /**
4
5
  * Abstract class representing an audio bus with volume control.
5
6
  *
@@ -9,6 +10,13 @@ import { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from "./subNodes/volu
9
10
  export class AbstractAudioBus extends AbstractNamedAudioNode {
10
11
  constructor(name, engine) {
11
12
  super(name, engine, 3 /* AudioNodeType.HAS_INPUTS_AND_OUTPUTS */);
13
+ this._analyzer = null;
14
+ }
15
+ /**
16
+ * The analyzer features of the bus.
17
+ */
18
+ get analyzer() {
19
+ return this._analyzer ?? (this._analyzer = new _AudioAnalyzer(this._subGraph));
12
20
  }
13
21
  /**
14
22
  * The output volume of the bus.
@@ -29,6 +37,8 @@ export class AbstractAudioBus extends AbstractNamedAudioNode {
29
37
  */
30
38
  dispose() {
31
39
  super.dispose();
40
+ this._analyzer?.dispose();
41
+ this._analyzer = null;
32
42
  this._subGraph.dispose();
33
43
  }
34
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"abstractAudioBus.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/abstractAudioBus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAiB,MAAM,qBAAqB,CAAC;AAG5E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEhG;;;;;GAKG;AACH,MAAM,OAAgB,gBAAiB,SAAQ,sBAAsB;IAGjE,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,+CAAuC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,uBAAuB,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,2EAA2E;QAC3E,MAAM,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED;;OAEG;IACa,OAAO;QACnB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import { AbstractNamedAudioNode, AudioNodeType } from \"./abstractAudioNode\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { _AbstractAudioSubGraph } from \"./subNodes/abstractAudioSubGraph\";\nimport { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from \"./subNodes/volumeAudioSubNode\";\n\n/**\n * Abstract class representing an audio bus with volume control.\n *\n * An audio bus is a node in the audio graph that can have multiple inputs and outputs. It is typically used to group\n * sounds together and apply effects to them.\n */\nexport abstract class AbstractAudioBus extends AbstractNamedAudioNode {\n protected abstract _subGraph: _AbstractAudioSubGraph;\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine, AudioNodeType.HAS_INPUTS_AND_OUTPUTS);\n }\n\n /**\n * The output volume of the bus.\n */\n public get volume(): number {\n return _GetVolumeAudioProperty(this._subGraph, \"volume\");\n }\n\n public set volume(value: number) {\n // The volume subnode is created on initialization and should always exist.\n const node = _GetVolumeAudioSubNode(this._subGraph);\n if (!node) {\n throw new Error(\"No volume subnode\");\n }\n\n node.volume = value;\n }\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n this._subGraph.dispose();\n }\n}\n"]}
1
+ {"version":3,"file":"abstractAudioBus.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/abstractAudioBus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAiB,MAAM,qBAAqB,CAAC;AAI5E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAK/D;;;;;GAKG;AACH,MAAM,OAAgB,gBAAiB,SAAQ,sBAAsB;IAKjE,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,+CAAuC,CAAC;QALtD,cAAS,GAA6B,IAAI,CAAC;IAMnD,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,uBAAuB,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,2EAA2E;QAC3E,MAAM,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED;;OAEG;IACa,OAAO;QACnB,KAAK,CAAC,OAAO,EAAE,CAAC;QAEhB,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport { AbstractNamedAudioNode, AudioNodeType } from \"./abstractAudioNode\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { _AbstractAudioSubGraph } from \"./subNodes/abstractAudioSubGraph\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\nimport { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from \"./subNodes/volumeAudioSubNode\";\nimport type { IAudioAnalyzerOptions } from \"./subProperties/abstractAudioAnalyzer\";\nimport { _AudioAnalyzer } from \"./subProperties/audioAnalyzer\";\n\n/** @internal */\nexport interface IAbstractAudioBusOptions extends IAudioAnalyzerOptions, IVolumeAudioOptions {}\n\n/**\n * Abstract class representing an audio bus with volume control.\n *\n * An audio bus is a node in the audio graph that can have multiple inputs and outputs. It is typically used to group\n * sounds together and apply effects to them.\n */\nexport abstract class AbstractAudioBus extends AbstractNamedAudioNode {\n private _analyzer: Nullable<_AudioAnalyzer> = null;\n\n protected abstract _subGraph: _AbstractAudioSubGraph;\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine, AudioNodeType.HAS_INPUTS_AND_OUTPUTS);\n }\n\n /**\n * The analyzer features of the bus.\n */\n public get analyzer(): _AudioAnalyzer {\n return this._analyzer ?? (this._analyzer = new _AudioAnalyzer(this._subGraph));\n }\n\n /**\n * The output volume of the bus.\n */\n public get volume(): number {\n return _GetVolumeAudioProperty(this._subGraph, \"volume\");\n }\n\n public set volume(value: number) {\n // The volume subnode is created on initialization and should always exist.\n const node = _GetVolumeAudioSubNode(this._subGraph);\n if (!node) {\n throw new Error(\"No volume subnode\");\n }\n\n node.volume = value;\n }\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n\n this._analyzer?.dispose();\n this._analyzer = null;\n\n this._subGraph.dispose();\n }\n}\n"]}
@@ -7,8 +7,10 @@ import type { PrimaryAudioBus } from "./audioBus";
7
7
  import type { AudioEngineV2 } from "./audioEngineV2";
8
8
  import type { _AbstractAudioSubGraph } from "./subNodes/abstractAudioSubGraph";
9
9
  import type { IVolumeAudioOptions } from "./subNodes/volumeAudioSubNode";
10
+ import type { IAudioAnalyzerOptions } from "./subProperties/abstractAudioAnalyzer";
10
11
  import type { AbstractSpatialAudio, ISpatialAudioOptions } from "./subProperties/abstractSpatialAudio";
11
12
  import type { AbstractStereoAudio, IStereoAudioOptions } from "./subProperties/abstractStereoAudio";
13
+ import { _AudioAnalyzer } from "./subProperties/audioAnalyzer";
12
14
  /** @internal */
13
15
  export interface IAbstractSoundOptionsBase {
14
16
  /**
@@ -34,7 +36,7 @@ export interface IAbstractSoundPlayOptionsBase {
34
36
  /**
35
37
  * Options for creating a sound.
36
38
  */
37
- export interface IAbstractSoundOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptions, ISpatialAudioOptions, IStereoAudioOptions {
39
+ export interface IAbstractSoundOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptions, IAudioAnalyzerOptions, ISpatialAudioOptions, IStereoAudioOptions {
38
40
  /**
39
41
  * The output bus for the sound. Defaults to `null`.
40
42
  * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.
@@ -57,19 +59,23 @@ export interface IAbstractSoundStoredOptions extends IAbstractSoundOptionsBase,
57
59
  * Abstract class representing a sound in the audio engine.
58
60
  */
59
61
  export declare abstract class AbstractSound extends AbstractNamedAudioNode {
62
+ private _analyzer;
60
63
  private _newestInstance;
61
64
  private _outBus;
62
65
  private _privateInstances;
63
66
  private _state;
64
67
  protected _instances: ReadonlySet<_AbstractSoundInstance>;
65
68
  protected abstract readonly _options: IAbstractSoundStoredOptions;
66
- protected _spatialAutoUpdate: boolean;
67
69
  protected abstract _subGraph: _AbstractAudioSubGraph;
68
70
  /**
69
71
  * Observable for when the sound stops playing.
70
72
  */
71
73
  readonly onEndedObservable: Observable<AbstractSound>;
72
- protected constructor(name: string, engine: AudioEngineV2, options: Partial<IAbstractSoundOptions>);
74
+ protected constructor(name: string, engine: AudioEngineV2);
75
+ /**
76
+ * The analyzer features of the sound.
77
+ */
78
+ get analyzer(): _AudioAnalyzer;
73
79
  /**
74
80
  * Whether the sound should start playing automatically. Defaults to `false`.
75
81
  */
@@ -97,7 +103,7 @@ export declare abstract class AbstractSound extends AbstractNamedAudioNode {
97
103
  get outBus(): Nullable<PrimaryAudioBus>;
98
104
  set outBus(outBus: Nullable<PrimaryAudioBus>);
99
105
  /**
100
- * The spatial properties of the sound.
106
+ * The spatial features of the sound.
101
107
  */
102
108
  abstract spatial: AbstractSpatialAudio;
103
109
  /**
@@ -110,7 +116,7 @@ export declare abstract class AbstractSound extends AbstractNamedAudioNode {
110
116
  */
111
117
  get state(): SoundState;
112
118
  /**
113
- * The stereo properties of the sound.
119
+ * The stereo features of the sound.
114
120
  */
115
121
  abstract stereo: AbstractStereoAudio;
116
122
  /**
@@ -1,18 +1,19 @@
1
1
  import { Observable } from "../../Misc/observable.js";
2
2
  import { AbstractNamedAudioNode } from "./abstractAudioNode.js";
3
3
  import { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from "./subNodes/volumeAudioSubNode.js";
4
+ import { _AudioAnalyzer } from "./subProperties/audioAnalyzer.js";
4
5
  /**
5
6
  * Abstract class representing a sound in the audio engine.
6
7
  */
7
8
  export class AbstractSound extends AbstractNamedAudioNode {
8
- constructor(name, engine, options) {
9
+ constructor(name, engine) {
9
10
  super(name, engine, 3 /* AudioNodeType.HAS_INPUTS_AND_OUTPUTS */); // Inputs are for instances.
11
+ this._analyzer = null;
10
12
  this._newestInstance = null;
11
13
  this._outBus = null;
12
14
  this._privateInstances = new Set();
13
15
  this._state = 1 /* SoundState.Stopped */;
14
16
  this._instances = this._privateInstances;
15
- this._spatialAutoUpdate = true;
16
17
  /**
17
18
  * Observable for when the sound stops playing.
18
19
  */
@@ -30,9 +31,12 @@ export class AbstractSound extends AbstractNamedAudioNode {
30
31
  this._onOutBusDisposed = () => {
31
32
  this.outBus = null;
32
33
  };
33
- if (typeof options.spatialAutoUpdate === "boolean") {
34
- this._spatialAutoUpdate = options.spatialAutoUpdate;
35
- }
34
+ }
35
+ /**
36
+ * The analyzer features of the sound.
37
+ */
38
+ get analyzer() {
39
+ return this._analyzer ?? (this._analyzer = new _AudioAnalyzer(this._subGraph));
36
40
  }
37
41
  /**
38
42
  * Whether the sound should start playing automatically. Defaults to `false`.
@@ -133,6 +137,8 @@ export class AbstractSound extends AbstractNamedAudioNode {
133
137
  dispose() {
134
138
  super.dispose();
135
139
  this.stop();
140
+ this._analyzer?.dispose();
141
+ this._analyzer = null;
136
142
  this._newestInstance = null;
137
143
  this._outBus = null;
138
144
  this._privateInstances.clear();
@@ -1 +1 @@
1
- {"version":3,"file":"abstractSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/abstractSound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,sBAAsB,EAAiB,MAAM,qBAAqB,CAAC;AAM5E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAmDhG;;GAEG;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CAAC;IAES,SAAS,CAAC,KAAiB;QACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAIS,oBAAoB;QAC1B,IAAI,IAAI,CAAC,YAAY,GAAG,QAAQ,EAAE,CAAC;YAC/B,MAAM,uBAAuB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,+BAAuB,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;YACnJ,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,uBAAuB,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/C,MAAM,QAAQ,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;gBACjC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpB,CAAC;QACL,CAAC;IACL,CAAC;IAEO,kBAAkB;QACtB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACpC,KAAK,IAAI,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC;YACtC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;CAkBJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport type { Nullable } from \"../../types\";\nimport { SoundState } from \"../soundState\";\nimport { AbstractNamedAudioNode, AudioNodeType } from \"./abstractAudioNode\";\nimport type { _AbstractSoundInstance } from \"./abstractSoundInstance\";\nimport type { PrimaryAudioBus } from \"./audioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { _AbstractAudioSubGraph } from \"./subNodes/abstractAudioSubGraph\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\nimport { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from \"./subNodes/volumeAudioSubNode\";\nimport type { AbstractSpatialAudio, ISpatialAudioOptions } from \"./subProperties/abstractSpatialAudio\";\nimport type { AbstractStereoAudio, IStereoAudioOptions } from \"./subProperties/abstractStereoAudio\";\n\n/** @internal */\nexport interface IAbstractSoundOptionsBase {\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n autoplay: boolean;\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n maxInstances: number;\n}\n\n/** @internal */\nexport interface IAbstractSoundPlayOptionsBase {\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n loop: boolean;\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n startOffset: number;\n}\n\n/**\n * Options for creating a sound.\n */\nexport interface IAbstractSoundOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptions, ISpatialAudioOptions, IStereoAudioOptions {\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n outBus: Nullable<PrimaryAudioBus>;\n}\n\n/**\n * Options for playing a sound.\n */\nexport interface IAbstractSoundPlayOptions extends IAbstractSoundPlayOptionsBase, IVolumeAudioOptions {}\n\n/**\n * Options stored in a sound.\n * @internal\n */\nexport interface IAbstractSoundStoredOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptionsBase {}\n\n/**\n * Abstract class representing a sound in the audio engine.\n */\nexport abstract class AbstractSound extends AbstractNamedAudioNode {\n private _newestInstance: Nullable<_AbstractSoundInstance> = null;\n private _outBus: Nullable<PrimaryAudioBus> = null;\n private _privateInstances = new Set<_AbstractSoundInstance>();\n private _state: SoundState = SoundState.Stopped;\n\n protected _instances: ReadonlySet<_AbstractSoundInstance> = this._privateInstances;\n protected abstract readonly _options: IAbstractSoundStoredOptions;\n protected _spatialAutoUpdate: boolean = true;\n protected abstract _subGraph: _AbstractAudioSubGraph;\n\n /**\n * Observable for when the sound stops playing.\n */\n public readonly onEndedObservable = new Observable<AbstractSound>();\n\n protected constructor(name: string, engine: AudioEngineV2, options: Partial<IAbstractSoundOptions>) {\n super(name, engine, AudioNodeType.HAS_INPUTS_AND_OUTPUTS); // Inputs are for instances.\n\n if (typeof options.spatialAutoUpdate === \"boolean\") {\n this._spatialAutoUpdate = options.spatialAutoUpdate;\n }\n }\n\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n public get autoplay(): boolean {\n return this._options.autoplay;\n }\n\n /**\n * The current playback time of the sound, in seconds.\n */\n public get currentTime(): number {\n const instance = this._getNewestInstance();\n return instance ? instance.currentTime : 0;\n }\n\n public set currentTime(value: number) {\n this.startOffset = value;\n\n const instance = this._getNewestInstance();\n if (instance) {\n instance.currentTime = value;\n }\n }\n\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n public get loop(): boolean {\n return this._options.loop;\n }\n\n public set loop(value: boolean) {\n this._options.loop = value;\n }\n\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n public get maxInstances(): number {\n return this._options.maxInstances;\n }\n\n public set maxInstances(value: number) {\n this._options.maxInstances = value;\n }\n\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n public get outBus(): Nullable<PrimaryAudioBus> {\n return this._outBus;\n }\n\n public set outBus(outBus: Nullable<PrimaryAudioBus>) {\n if (this._outBus === outBus) {\n return;\n }\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n if (!this._disconnect(this._outBus)) {\n throw new Error(\"Disconnect failed\");\n }\n }\n\n this._outBus = outBus;\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n if (!this._connect(this._outBus)) {\n throw new Error(\"Connect failed\");\n }\n }\n }\n\n /**\n * The spatial properties of the sound.\n */\n public abstract spatial: AbstractSpatialAudio;\n\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n public get startOffset(): number {\n return this._options.startOffset;\n }\n\n public set startOffset(value: number) {\n this._options.startOffset = value;\n }\n\n /**\n * The state of the sound.\n */\n public get state(): SoundState {\n return this._state;\n }\n\n /**\n * The stereo properties of the sound.\n */\n public abstract stereo: AbstractStereoAudio;\n\n /**\n * The output volume of the sound.\n */\n public get volume(): number {\n return _GetVolumeAudioProperty(this._subGraph, \"volume\");\n }\n\n public set volume(value: number) {\n // The volume subnode is created on initialization and should always exist.\n const node = _GetVolumeAudioSubNode(this._subGraph);\n if (!node) {\n throw new Error(\"No volume subnode\");\n }\n\n node.volume = value;\n }\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n\n this.stop();\n\n this._newestInstance = null;\n this._outBus = null;\n\n this._privateInstances.clear();\n this.onEndedObservable.clear();\n }\n\n /**\n * Plays the sound.\n * - Triggers `onEndedObservable` if played for the full duration and the `loop` option is not set.\n * @param options The options to use when playing the sound. Options set here override the sound's options.\n */\n public abstract play(options?: Partial<IAbstractSoundPlayOptions>): void;\n\n /**\n * Pauses the sound.\n */\n public pause(): void {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.pause();\n }\n\n this._state = SoundState.Paused;\n }\n\n /**\n * Resumes the sound.\n */\n public resume(): void {\n if (this._state !== SoundState.Paused) {\n return;\n }\n\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.resume();\n }\n\n this._state = SoundState.Started;\n }\n\n /**\n * Stops the sound.\n * - Triggers `onEndedObservable` if the sound is playing.\n */\n public abstract stop(): void;\n\n protected _beforePlay(instance: _AbstractSoundInstance): void {\n if (this.state === SoundState.Paused && this._instances.size > 0) {\n this.resume();\n return;\n }\n\n instance.onEndedObservable.addOnce(this._onInstanceEnded);\n this._privateInstances.add(instance);\n this._newestInstance = instance;\n }\n\n protected _afterPlay(instance: _AbstractSoundInstance): void {\n this._state = instance.state;\n }\n\n protected _setState(state: SoundState): void {\n this._state = state;\n }\n\n protected abstract _createInstance(): _AbstractSoundInstance;\n\n protected _stopExcessInstances(): void {\n if (this.maxInstances < Infinity) {\n const numberOfInstancesToStop = Array.from(this._instances).filter((instance) => instance.state === SoundState.Started).length - this.maxInstances;\n const it = this._instances.values();\n\n for (let i = 0; i < numberOfInstancesToStop; i++) {\n const instance = it.next().value;\n instance.stop();\n }\n }\n }\n\n private _getNewestInstance(): Nullable<_AbstractSoundInstance> {\n if (this._instances.size === 0) {\n return null;\n }\n\n if (!this._newestInstance) {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n this._newestInstance = next.value;\n }\n }\n\n return this._newestInstance;\n }\n\n private _onInstanceEnded: (instance: _AbstractSoundInstance) => void = (instance) => {\n if (this._newestInstance === instance) {\n this._newestInstance = null;\n }\n\n this._privateInstances.delete(instance);\n\n if (this._instances.size === 0) {\n this._state = SoundState.Stopped;\n this.onEndedObservable.notifyObservers(this);\n }\n };\n\n private _onOutBusDisposed = () => {\n this.outBus = null;\n };\n}\n"]}
1
+ {"version":3,"file":"abstractSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/abstractSound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,sBAAsB,EAAiB,MAAM,qBAAqB,CAAC;AAM5E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,+BAA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Ae,GAAG,IAAI,CAAC,KAAK,CAAC;YACtC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;CAkBJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport type { Nullable } from \"../../types\";\nimport { SoundState } from \"../soundState\";\nimport { AbstractNamedAudioNode, AudioNodeType } from \"./abstractAudioNode\";\nimport type { _AbstractSoundInstance } from \"./abstractSoundInstance\";\nimport type { PrimaryAudioBus } from \"./audioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { _AbstractAudioSubGraph } from \"./subNodes/abstractAudioSubGraph\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\nimport { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from \"./subNodes/volumeAudioSubNode\";\nimport type { IAudioAnalyzerOptions } from \"./subProperties/abstractAudioAnalyzer\";\nimport type { AbstractSpatialAudio, ISpatialAudioOptions } from \"./subProperties/abstractSpatialAudio\";\nimport type { AbstractStereoAudio, IStereoAudioOptions } from \"./subProperties/abstractStereoAudio\";\nimport { _AudioAnalyzer } from \"./subProperties/audioAnalyzer\";\n\n/** @internal */\nexport interface IAbstractSoundOptionsBase {\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n autoplay: boolean;\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n maxInstances: number;\n}\n\n/** @internal */\nexport interface IAbstractSoundPlayOptionsBase {\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n loop: boolean;\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n startOffset: number;\n}\n\n/**\n * Options for creating a sound.\n */\nexport interface IAbstractSoundOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptions, IAudioAnalyzerOptions, ISpatialAudioOptions, IStereoAudioOptions {\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n outBus: Nullable<PrimaryAudioBus>;\n}\n\n/**\n * Options for playing a sound.\n */\nexport interface IAbstractSoundPlayOptions extends IAbstractSoundPlayOptionsBase, IVolumeAudioOptions {}\n\n/**\n * Options stored in a sound.\n * @internal\n */\nexport interface IAbstractSoundStoredOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptionsBase {}\n\n/**\n * Abstract class representing a sound in the audio engine.\n */\nexport abstract class AbstractSound extends AbstractNamedAudioNode {\n private _analyzer: Nullable<_AudioAnalyzer> = null;\n private _newestInstance: Nullable<_AbstractSoundInstance> = null;\n private _outBus: Nullable<PrimaryAudioBus> = null;\n private _privateInstances = new Set<_AbstractSoundInstance>();\n private _state: SoundState = SoundState.Stopped;\n\n protected _instances: ReadonlySet<_AbstractSoundInstance> = this._privateInstances;\n protected abstract readonly _options: IAbstractSoundStoredOptions;\n protected abstract _subGraph: _AbstractAudioSubGraph;\n\n /**\n * Observable for when the sound stops playing.\n */\n public readonly onEndedObservable = new Observable<AbstractSound>();\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine, AudioNodeType.HAS_INPUTS_AND_OUTPUTS); // Inputs are for instances.\n }\n\n /**\n * The analyzer features of the sound.\n */\n public get analyzer(): _AudioAnalyzer {\n return this._analyzer ?? (this._analyzer = new _AudioAnalyzer(this._subGraph));\n }\n\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n public get autoplay(): boolean {\n return this._options.autoplay;\n }\n\n /**\n * The current playback time of the sound, in seconds.\n */\n public get currentTime(): number {\n const instance = this._getNewestInstance();\n return instance ? instance.currentTime : 0;\n }\n\n public set currentTime(value: number) {\n this.startOffset = value;\n\n const instance = this._getNewestInstance();\n if (instance) {\n instance.currentTime = value;\n }\n }\n\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n public get loop(): boolean {\n return this._options.loop;\n }\n\n public set loop(value: boolean) {\n this._options.loop = value;\n }\n\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n public get maxInstances(): number {\n return this._options.maxInstances;\n }\n\n public set maxInstances(value: number) {\n this._options.maxInstances = value;\n }\n\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n public get outBus(): Nullable<PrimaryAudioBus> {\n return this._outBus;\n }\n\n public set outBus(outBus: Nullable<PrimaryAudioBus>) {\n if (this._outBus === outBus) {\n return;\n }\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n if (!this._disconnect(this._outBus)) {\n throw new Error(\"Disconnect failed\");\n }\n }\n\n this._outBus = outBus;\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n if (!this._connect(this._outBus)) {\n throw new Error(\"Connect failed\");\n }\n }\n }\n\n /**\n * The spatial features of the sound.\n */\n public abstract spatial: AbstractSpatialAudio;\n\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n public get startOffset(): number {\n return this._options.startOffset;\n }\n\n public set startOffset(value: number) {\n this._options.startOffset = value;\n }\n\n /**\n * The state of the sound.\n */\n public get state(): SoundState {\n return this._state;\n }\n\n /**\n * The stereo features of the sound.\n */\n public abstract stereo: AbstractStereoAudio;\n\n /**\n * The output volume of the sound.\n */\n public get volume(): number {\n return _GetVolumeAudioProperty(this._subGraph, \"volume\");\n }\n\n public set volume(value: number) {\n // The volume subnode is created on initialization and should always exist.\n const node = _GetVolumeAudioSubNode(this._subGraph);\n if (!node) {\n throw new Error(\"No volume subnode\");\n }\n\n node.volume = value;\n }\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n\n this.stop();\n\n this._analyzer?.dispose();\n this._analyzer = null;\n\n this._newestInstance = null;\n this._outBus = null;\n\n this._privateInstances.clear();\n this.onEndedObservable.clear();\n }\n\n /**\n * Plays the sound.\n * - Triggers `onEndedObservable` if played for the full duration and the `loop` option is not set.\n * @param options The options to use when playing the sound. Options set here override the sound's options.\n */\n public abstract play(options?: Partial<IAbstractSoundPlayOptions>): void;\n\n /**\n * Pauses the sound.\n */\n public pause(): void {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.pause();\n }\n\n this._state = SoundState.Paused;\n }\n\n /**\n * Resumes the sound.\n */\n public resume(): void {\n if (this._state !== SoundState.Paused) {\n return;\n }\n\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.resume();\n }\n\n this._state = SoundState.Started;\n }\n\n /**\n * Stops the sound.\n * - Triggers `onEndedObservable` if the sound is playing.\n */\n public abstract stop(): void;\n\n protected _beforePlay(instance: _AbstractSoundInstance): void {\n if (this.state === SoundState.Paused && this._instances.size > 0) {\n this.resume();\n return;\n }\n\n instance.onEndedObservable.addOnce(this._onInstanceEnded);\n this._privateInstances.add(instance);\n this._newestInstance = instance;\n }\n\n protected _afterPlay(instance: _AbstractSoundInstance): void {\n this._state = instance.state;\n }\n\n protected _setState(state: SoundState): void {\n this._state = state;\n }\n\n protected abstract _createInstance(): _AbstractSoundInstance;\n\n protected _stopExcessInstances(): void {\n if (this.maxInstances < Infinity) {\n const numberOfInstancesToStop = Array.from(this._instances).filter((instance) => instance.state === SoundState.Started).length - this.maxInstances;\n const it = this._instances.values();\n\n for (let i = 0; i < numberOfInstancesToStop; i++) {\n const instance = it.next().value;\n instance.stop();\n }\n }\n }\n\n private _getNewestInstance(): Nullable<_AbstractSoundInstance> {\n if (this._instances.size === 0) {\n return null;\n }\n\n if (!this._newestInstance) {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n this._newestInstance = next.value;\n }\n }\n\n return this._newestInstance;\n }\n\n private _onInstanceEnded: (instance: _AbstractSoundInstance) => void = (instance) => {\n if (this._newestInstance === instance) {\n this._newestInstance = null;\n }\n\n this._privateInstances.delete(instance);\n\n if (this._instances.size === 0) {\n this._state = SoundState.Stopped;\n this.onEndedObservable.notifyObservers(this);\n }\n };\n\n private _onOutBusDisposed = () => {\n this.outBus = null;\n };\n}\n"]}
@@ -1,15 +1,15 @@
1
1
  import type { Nullable } from "../../types";
2
+ import type { IAbstractAudioBusOptions } from "./abstractAudioBus";
2
3
  import { AbstractAudioBus } from "./abstractAudioBus";
3
4
  import type { AudioEngineV2 } from "./audioEngineV2";
4
5
  import type { MainAudioBus } from "./mainAudioBus";
5
- import type { IVolumeAudioOptions } from "./subNodes/volumeAudioSubNode";
6
6
  import type { AbstractSpatialAudio, ISpatialAudioOptions } from "./subProperties/abstractSpatialAudio";
7
7
  import type { AbstractStereoAudio, IStereoAudioOptions } from "./subProperties/abstractStereoAudio";
8
8
  export type PrimaryAudioBus = MainAudioBus | AudioBus;
9
9
  /**
10
10
  * Options for creating an audio bus.
11
11
  */
12
- export interface IAudioBusOptions extends ISpatialAudioOptions, IStereoAudioOptions, IVolumeAudioOptions {
12
+ export interface IAudioBusOptions extends IAbstractAudioBusOptions, ISpatialAudioOptions, IStereoAudioOptions {
13
13
  /**
14
14
  * The output bus of the audio bus. Defaults to the audio engine's default main bus.
15
15
  * @see {@link AudioEngineV2.defaultMainBus}
@@ -25,19 +25,18 @@ export interface IAudioBusOptions extends ISpatialAudioOptions, IStereoAudioOpti
25
25
  */
26
26
  export declare abstract class AudioBus extends AbstractAudioBus {
27
27
  private _outBus;
28
- protected _spatialAutoUpdate: boolean;
29
- protected constructor(name: string, engine: AudioEngineV2, options: Partial<IAudioBusOptions>);
28
+ protected constructor(name: string, engine: AudioEngineV2);
30
29
  /**
31
30
  * The output bus of the audio bus. Defaults to the audio engine's default main bus.
32
31
  */
33
32
  get outBus(): Nullable<PrimaryAudioBus>;
34
33
  set outBus(outBus: Nullable<PrimaryAudioBus>);
35
34
  /**
36
- * The spatial audio properties of the audio bus.
35
+ * The spatial features of the audio bus.
37
36
  */
38
37
  abstract readonly spatial: AbstractSpatialAudio;
39
38
  /**
40
- * The stereo audio properties of the audio bus.
39
+ * The stereo features of the audio bus.
41
40
  */
42
41
  abstract readonly stereo: AbstractStereoAudio;
43
42
  /**
@@ -7,16 +7,12 @@ import { AbstractAudioBus } from "./abstractAudioBus.js";
7
7
  * Audio buses are created by the {@link CreateAudioBusAsync} function.
8
8
  */
9
9
  export class AudioBus extends AbstractAudioBus {
10
- constructor(name, engine, options) {
10
+ constructor(name, engine) {
11
11
  super(name, engine);
12
12
  this._outBus = null;
13
- this._spatialAutoUpdate = true;
14
13
  this._onOutBusDisposed = () => {
15
14
  this.outBus = this.engine.defaultMainBus;
16
15
  };
17
- if (typeof options.spatialAutoUpdate === "boolean") {
18
- this._spatialAutoUpdate = options.spatialAutoUpdate;
19
- }
20
16
  }
21
17
  /**
22
18
  * The output bus of the audio bus. Defaults to the audio engine's default main bus.
@@ -1 +1 @@
1
- {"version":3,"file":"audioBus.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/audioBus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAqBtD;;;;;;GAMG;AACH,MAAM,OAAgB,QAAS,SAAQ,gBAAgB;IAKnD,YAAsB,IAAY,EAAE,MAAqB,EAAE,OAAkC;QACzF,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QALhB,YAAO,GAA8B,IAAI,CAAC;QAExC,uBAAkB,GAAY,IAAI,CAAC;QA2DrC,sBAAiB,GAAG,GAAG,EAAE;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAC7C,CAAC,CAAC;QAxDE,IAAI,OAAO,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACjD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACxD,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAiC;QAC/C,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;YAC1B,OAAO;QACX,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAExE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACzC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAE7D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACtC,CAAC;QACL,CAAC;IACL,CAAC;IAYD;;OAEG;IACa,OAAO;QACnB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;CAKJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport { AbstractAudioBus } from \"./abstractAudioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { MainAudioBus } from \"./mainAudioBus\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\nimport type { AbstractSpatialAudio, ISpatialAudioOptions } from \"./subProperties/abstractSpatialAudio\";\nimport type { AbstractStereoAudio, IStereoAudioOptions } from \"./subProperties/abstractStereoAudio\";\n\n// NB: Secondary audio buses will be added later.\nexport type PrimaryAudioBus = MainAudioBus | AudioBus;\n\n/**\n * Options for creating an audio bus.\n */\nexport interface IAudioBusOptions extends ISpatialAudioOptions, IStereoAudioOptions, IVolumeAudioOptions {\n /**\n * The output bus of the audio bus. Defaults to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n outBus: PrimaryAudioBus;\n}\n\n/**\n * Abstract class for an audio bus that has spatial audio and stereo output capabilities.\n *\n * Instances of this class can be connected to other audio buses.\n *\n * Audio buses are created by the {@link CreateAudioBusAsync} function.\n */\nexport abstract class AudioBus extends AbstractAudioBus {\n private _outBus: Nullable<PrimaryAudioBus> = null;\n\n protected _spatialAutoUpdate: boolean = true;\n\n protected constructor(name: string, engine: AudioEngineV2, options: Partial<IAudioBusOptions>) {\n super(name, engine);\n\n if (typeof options.spatialAutoUpdate === \"boolean\") {\n this._spatialAutoUpdate = options.spatialAutoUpdate;\n }\n }\n\n /**\n * The output bus of the audio bus. Defaults to the audio engine's default main bus.\n */\n public get outBus(): Nullable<PrimaryAudioBus> {\n return this._outBus;\n }\n\n public set outBus(outBus: Nullable<PrimaryAudioBus>) {\n if (this._outBus === outBus) {\n return;\n }\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n\n if (!this._disconnect(this._outBus)) {\n throw new Error(\"Disconnect failed\");\n }\n }\n\n this._outBus = outBus;\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n\n if (!this._connect(this._outBus)) {\n throw new Error(\"Connect failed\");\n }\n }\n }\n\n /**\n * The spatial audio properties of the audio bus.\n */\n public abstract readonly spatial: AbstractSpatialAudio;\n\n /**\n * The stereo audio properties of the audio bus.\n */\n public abstract readonly stereo: AbstractStereoAudio;\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n this._outBus = null;\n }\n\n private _onOutBusDisposed = () => {\n this.outBus = this.engine.defaultMainBus;\n };\n}\n"]}
1
+ {"version":3,"file":"audioBus.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/audioBus.ts"],"names":[],"mappings":"A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IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;CAKJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { IAbstractAudioBusOptions } from \"./abstractAudioBus\";\nimport { AbstractAudioBus } from \"./abstractAudioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { MainAudioBus } from \"./mainAudioBus\";\nimport type { AbstractSpatialAudio, ISpatialAudioOptions } from \"./subProperties/abstractSpatialAudio\";\nimport type { AbstractStereoAudio, IStereoAudioOptions } from \"./subProperties/abstractStereoAudio\";\n\n// NB: Secondary audio buses will be added later.\nexport type PrimaryAudioBus = MainAudioBus | AudioBus;\n\n/**\n * Options for creating an audio bus.\n */\nexport interface IAudioBusOptions extends IAbstractAudioBusOptions, ISpatialAudioOptions, IStereoAudioOptions {\n /**\n * The output bus of the audio bus. Defaults to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n outBus: PrimaryAudioBus;\n}\n\n/**\n * Abstract class for an audio bus that has spatial audio and stereo output capabilities.\n *\n * Instances of this class can be connected to other audio buses.\n *\n * Audio buses are created by the {@link CreateAudioBusAsync} function.\n */\nexport abstract class AudioBus extends AbstractAudioBus {\n private _outBus: Nullable<PrimaryAudioBus> = null;\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine);\n }\n\n /**\n * The output bus of the audio bus. Defaults to the audio engine's default main bus.\n */\n public get outBus(): Nullable<PrimaryAudioBus> {\n return this._outBus;\n }\n\n public set outBus(outBus: Nullable<PrimaryAudioBus>) {\n if (this._outBus === outBus) {\n return;\n }\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n\n if (!this._disconnect(this._outBus)) {\n throw new Error(\"Disconnect failed\");\n }\n }\n\n this._outBus = outBus;\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n\n if (!this._connect(this._outBus)) {\n throw new Error(\"Connect failed\");\n }\n }\n }\n\n /**\n * The spatial features of the audio bus.\n */\n public abstract readonly spatial: AbstractSpatialAudio;\n\n /**\n * The stereo features of the audio bus.\n */\n public abstract readonly stereo: AbstractStereoAudio;\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n this._outBus = null;\n }\n\n private _onOutBusDisposed = () => {\n this.outBus = this.engine.defaultMainBus;\n };\n}\n"]}
@@ -36,8 +36,7 @@ export declare abstract class AudioEngineV2 {
36
36
  /** Owned top-level sound and bus nodes. */
37
37
  private readonly _nodes;
38
38
  private _defaultMainBus;
39
- protected _listenerAutoUpdate: boolean;
40
- protected constructor(options: Partial<IAudioEngineV2Options>);
39
+ protected constructor();
41
40
  /**
42
41
  * The elapsed time since the audio engine was started, in seconds.
43
42
  */
@@ -15,17 +15,13 @@ export function LastCreatedAudioEngine() {
15
15
  * A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.
16
16
  */
17
17
  export class AudioEngineV2 {
18
- constructor(options) {
18
+ constructor() {
19
19
  /** Not owned, but all items should be in `_nodes` container, too, which is owned. */
20
20
  this._mainBuses = new Set();
21
21
  /** Owned top-level sound and bus nodes. */
22
22
  this._nodes = new Set();
23
23
  this._defaultMainBus = null;
24
- this._listenerAutoUpdate = true;
25
24
  Instances.push(this);
26
- if (typeof options.listenerAutoUpdate === "boolean") {
27
- this._listenerAutoUpdate = options.listenerAutoUpdate;
28
- }
29
25
  }
30
26
  /**
31
27
  * The default main bus that will be used for audio buses and sounds if their `outBus` option is not set.
@@ -1 +1 @@
1
- {"version":3,"file":"audioEngineV2.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/audioEngineV2.ts"],"names":[],"mappings":"AASA,MAAM,SAAS,GAAoB,EAAE,CAAC;AAEtC;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IAClC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,SAAS,CAAC,S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CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAY,EAAE,UAAyC,EAAE,EAAE,SAAkC,IAAI;IACrI,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC5B,IAAY,EACZ,MAAyE,EACzE,UAAwC,EAAE,EAC1C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CACxC,MAAyE,EACzE,UAA8C,EAAE,EAChD,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACrC,IAAY,EACZ,MAA4C,EAC5C,UAA2C,EAAE,EAC7C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { AbstractAudioNode, AbstractNamedAudioNode } from \"./abstractAudioNode\";\nimport type { AudioBus, IAudioBusOptions } from \"./audioBus\";\nimport type { IMainAudioBusOptions, MainAudioBus } from \"./mainAudioBus\";\nimport type { IStaticSoundOptions, StaticSound } from \"./staticSound\";\nimport type { IStaticSoundBufferOptions, StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport type { IStreamingSoundOptions, StreamingSound } from \"./streamingSound\";\nimport type { AbstractSpatialAudioListener, ISpatialAudioListenerOptions } from \"./subProperties/abstractSpatialAudioListener\";\n\nconst Instances: AudioEngineV2[] = [];\n\n/**\n * Gets the most recently created v2 audio engine.\n * @returns The most recently created v2 audio engine.\n */\nexport function LastCreatedAudioEngine(): Nullable<AudioEngineV2> {\n if (Instances.length === 0) {\n return null;\n }\n\n return Instances[Instances.length - 1];\n}\n\n/**\n * Options for creating a v2 audio engine.\n */\nexport interface IAudioEngineV2Options extends ISpatialAudioListenerOptions {\n /**\n * The initial output volume of the audio engine. Defaults to `1`.\n */\n volume: number;\n}\n\n/**\n * The state of a v2 audio engine.\n * @see {@link AudioEngineV2.state}\n */\nexport type AudioEngineV2State = \"closed\" | \"interrupted\" | \"running\" | \"suspended\";\n\n/**\n * Abstract base class for v2 audio engines.\n *\n * A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.\n */\nexport abstract class AudioEngineV2 {\n /** Not owned, but all items should be in `_nodes` container, too, which is owned. */\n private readonly _mainBuses = new Set<MainAudioBus>();\n\n /** Owned top-level sound and bus nodes. */\n private readonly _nodes = new Set<AbstractNamedAudioNode>();\n\n private _defaultMainBus: Nullable<MainAudioBus> = null;\n\n protected _listenerAutoUpdate: boolean = true;\n\n protected constructor(options: Partial<IAudioEngineV2Options>) {\n Instances.push(this);\n\n if (typeof options.listenerAutoUpdate === \"boolean\") {\n this._listenerAutoUpdate = options.listenerAutoUpdate;\n }\n }\n\n /**\n * The elapsed time since the audio engine was started, in seconds.\n */\n public abstract readonly currentTime: number;\n\n /**\n * The default main bus that will be used for audio buses and sounds if their `outBus` option is not set.\n * @see {@link IAudioBusOptions.outBus}\n * @see {@link IAbstractSoundOptions.outBus}\n */\n public get defaultMainBus(): Nullable<MainAudioBus> {\n if (this._mainBuses.size === 0) {\n return null;\n }\n\n if (!this._defaultMainBus) {\n this._defaultMainBus = Array.from(this._mainBuses)[0];\n }\n\n return this._defaultMainBus;\n }\n\n /**\n * The spatial audio listener properties for the audio engine.\n * - Each audio engine has exactly one listener.\n */\n public abstract readonly listener: AbstractSpatialAudioListener;\n\n /**\n * The main output node.\n * - This is the last node in the audio graph before the audio is sent to the speakers.\n */\n public abstract readonly mainOut: AbstractAudioNode;\n\n /**\n * The current state of the audio engine.\n *\n * Possible values are:\n * - `\"closed\"`: The audio engine has been closed.\n * - `\"interrupted\"`: The audio engine has been interrupted and is not running.\n * - `\"running\"`: The audio engine is running normally.\n * - `\"suspended\"`: The audio engine is suspended and is not running.\n */\n public abstract readonly state: AudioEngineV2State;\n\n /**\n * The output volume of the audio engine.\n */\n public abstract volume: number;\n /**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created audio bus.\n */\n public abstract createBusAsync(name: string, options?: Partial<IAudioBusOptions>): Promise<AudioBus>;\n\n /**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @returns A promise that resolves with the created main audio bus.\n */\n public abstract createMainBusAsync(name: string, options?: Partial<IMainAudioBusOptions>): Promise<MainAudioBus>;\n /**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @returns A promise that resolves to the created static sound.\n */\n public abstract createSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundOptions>\n ): Promise<StaticSound>;\n\n /**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound buffer.\n */\n public abstract createSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundBufferOptions>\n ): Promise<StaticSoundBuffer>;\n\n /**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @returns A promise that resolves to the created streaming sound.\n */\n public abstract createStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options?: Partial<IStreamingSoundOptions>): Promise<StreamingSound>;\n\n /**\n * Releases associated resources.\n */\n public dispose(): void {\n if (Instances.includes(this)) {\n Instances.splice(Instances.indexOf(this), 1);\n }\n\n const nodeIt = this._nodes.values();\n for (let next = nodeIt.next(); !next.done; next = nodeIt.next()) {\n next.value.dispose();\n }\n\n this._mainBuses.clear();\n this._nodes.clear();\n\n this._defaultMainBus = null;\n }\n\n /**\n * Checks if the specified format is valid.\n * @param format The format to check as an audio file extension like \"mp3\" or \"wav\".\n * @returns `true` if the format is valid; otherwise `false`.\n */\n public abstract isFormatValid(format: string): boolean;\n\n /**\n * Pauses the audio engine if it is running.\n * @returns A promise that resolves when the audio engine is paused.\n */\n public abstract pause(): Promise<void>;\n\n /**\n * Resumes the audio engine if it is not running.\n * @returns A promise that resolves when the audio engine is running.\n */\n public abstract resume(): Promise<void>;\n\n /**\n * Unlocks the audio engine if it is locked.\n * - Note that the returned promise may already be resolved if the audio engine is already unlocked.\n * @returns A promise that is resolved when the audio engine is unlocked.\n */\n public unlock(): Promise<void> {\n return this.resume();\n }\n\n protected _addMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.add(mainBus);\n\n this._addNode(mainBus);\n }\n\n protected _removeMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.delete(mainBus);\n this._defaultMainBus = null;\n\n this._removeNode(mainBus);\n }\n\n protected _addNode(node: AbstractNamedAudioNode): void {\n this._nodes.add(node);\n }\n\n protected _removeNode(node: AbstractNamedAudioNode): void {\n this._nodes.delete(node);\n }\n}\n\n/**\n * @internal\n * @param engine - The given audio engine. If `null` then the last created audio engine is used.\n * @returns the given audio engine or the last created audio engine.\n * @throws An error if the resulting engine is `null`.\n */\nexport function _GetAudioEngine(engine: Nullable<AudioEngineV2>): AudioEngineV2 {\n if (!engine) {\n engine = LastCreatedAudioEngine();\n }\n\n if (engine) {\n return engine;\n }\n\n throw new Error(\"No audio engine.\");\n}\n\n/**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created audio bus.\n */\nexport function CreateAudioBusAsync(name: string, options: Partial<IAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createBusAsync(name, options);\n}\n\n/**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created main audio bus.\n */\nexport function CreateMainAudioBusAsync(name: string, options: Partial<IMainAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<MainAudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createMainBusAsync(name, options);\n}\n\n/**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound.\n */\nexport function CreateSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSound> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundAsync(name, source, options);\n}\n\n/**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound buffer.\n */\nexport async function CreateSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundBufferOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSoundBuffer> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundBufferAsync(source, options);\n}\n\n/**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created streaming sound.\n */\nexport function CreateStreamingSoundAsync(\n name: string,\n source: HTMLMediaElement | string | string[],\n options: Partial<IStreamingSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StreamingSound> {\n engine = _GetAudioEngine(engine);\n return engine.createStreamingSoundAsync(name, source, options);\n}\n"]}
1
+ {"version":3,"file":"audioEngineV2.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/audioEngineV2.ts"],"names":[],"mappings":"AASA,MAAM,SAAS,GAAoB,EAAE,CAAC;AAEtC;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IAClC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC3C,CAAC;AAkBD;;;;GAIG;AACH,MAAM,OAAgB,aAAa;IAS/B;QARA,qFAAqF;QACpE,eAAU,GAAG,IAAI,GAAG,EAAgB,CAAC;QAEtD,2CAA2C;QAC1B,WAAM,GAAG,IAAI,GAAG,EAA0B,CAAC;QAEpD,oBAAe,GAA2B,IAAI,CAAC;QAGnD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAOD;;;;OAIG;IACH,IAAW,cAAc;QACrB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAA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,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACrC,IAAY,EACZ,MAA4C,EAC5C,UAA2C,EAAE,EAC7C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { AbstractAudioNode, AbstractNamedAudioNode } from \"./abstractAudioNode\";\nimport type { AudioBus, IAudioBusOptions } from \"./audioBus\";\nimport type { IMainAudioBusOptions, MainAudioBus } from \"./mainAudioBus\";\nimport type { IStaticSoundOptions, StaticSound } from \"./staticSound\";\nimport type { IStaticSoundBufferOptions, StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport type { IStreamingSoundOptions, StreamingSound } from \"./streamingSound\";\nimport type { AbstractSpatialAudioListener, ISpatialAudioListenerOptions } from \"./subProperties/abstractSpatialAudioListener\";\n\nconst Instances: AudioEngineV2[] = [];\n\n/**\n * Gets the most recently created v2 audio engine.\n * @returns The most recently created v2 audio engine.\n */\nexport function LastCreatedAudioEngine(): Nullable<AudioEngineV2> {\n if (Instances.length === 0) {\n return null;\n }\n\n return Instances[Instances.length - 1];\n}\n\n/**\n * Options for creating a v2 audio engine.\n */\nexport interface IAudioEngineV2Options extends ISpatialAudioListenerOptions {\n /**\n * The initial output volume of the audio engine. Defaults to `1`.\n */\n volume: number;\n}\n\n/**\n * The state of a v2 audio engine.\n * @see {@link AudioEngineV2.state}\n */\nexport type AudioEngineV2State = \"closed\" | \"interrupted\" | \"running\" | \"suspended\";\n\n/**\n * Abstract base class for v2 audio engines.\n *\n * A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.\n */\nexport abstract class AudioEngineV2 {\n /** Not owned, but all items should be in `_nodes` container, too, which is owned. */\n private readonly _mainBuses = new Set<MainAudioBus>();\n\n /** Owned top-level sound and bus nodes. */\n private readonly _nodes = new Set<AbstractNamedAudioNode>();\n\n private _defaultMainBus: Nullable<MainAudioBus> = null;\n\n protected constructor() {\n Instances.push(this);\n }\n\n /**\n * The elapsed time since the audio engine was started, in seconds.\n */\n public abstract readonly currentTime: number;\n\n /**\n * The default main bus that will be used for audio buses and sounds if their `outBus` option is not set.\n * @see {@link IAudioBusOptions.outBus}\n * @see {@link IAbstractSoundOptions.outBus}\n */\n public get defaultMainBus(): Nullable<MainAudioBus> {\n if (this._mainBuses.size === 0) {\n return null;\n }\n\n if (!this._defaultMainBus) {\n this._defaultMainBus = Array.from(this._mainBuses)[0];\n }\n\n return this._defaultMainBus;\n }\n\n /**\n * The spatial audio listener properties for the audio engine.\n * - Each audio engine has exactly one listener.\n */\n public abstract readonly listener: AbstractSpatialAudioListener;\n\n /**\n * The main output node.\n * - This is the last node in the audio graph before the audio is sent to the speakers.\n */\n public abstract readonly mainOut: AbstractAudioNode;\n\n /**\n * The current state of the audio engine.\n *\n * Possible values are:\n * - `\"closed\"`: The audio engine has been closed.\n * - `\"interrupted\"`: The audio engine has been interrupted and is not running.\n * - `\"running\"`: The audio engine is running normally.\n * - `\"suspended\"`: The audio engine is suspended and is not running.\n */\n public abstract readonly state: AudioEngineV2State;\n\n /**\n * The output volume of the audio engine.\n */\n public abstract volume: number;\n\n /**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created audio bus.\n */\n public abstract createBusAsync(name: string, options?: Partial<IAudioBusOptions>): Promise<AudioBus>;\n\n /**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @returns A promise that resolves with the created main audio bus.\n */\n public abstract createMainBusAsync(name: string, options?: Partial<IMainAudioBusOptions>): Promise<MainAudioBus>;\n /**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @returns A promise that resolves to the created static sound.\n */\n public abstract createSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundOptions>\n ): Promise<StaticSound>;\n\n /**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound buffer.\n */\n public abstract createSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundBufferOptions>\n ): Promise<StaticSoundBuffer>;\n\n /**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @returns A promise that resolves to the created streaming sound.\n */\n public abstract createStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options?: Partial<IStreamingSoundOptions>): Promise<StreamingSound>;\n\n /**\n * Releases associated resources.\n */\n public dispose(): void {\n if (Instances.includes(this)) {\n Instances.splice(Instances.indexOf(this), 1);\n }\n\n const nodeIt = this._nodes.values();\n for (let next = nodeIt.next(); !next.done; next = nodeIt.next()) {\n next.value.dispose();\n }\n\n this._mainBuses.clear();\n this._nodes.clear();\n\n this._defaultMainBus = null;\n }\n\n /**\n * Checks if the specified format is valid.\n * @param format The format to check as an audio file extension like \"mp3\" or \"wav\".\n * @returns `true` if the format is valid; otherwise `false`.\n */\n public abstract isFormatValid(format: string): boolean;\n\n /**\n * Pauses the audio engine if it is running.\n * @returns A promise that resolves when the audio engine is paused.\n */\n public abstract pause(): Promise<void>;\n\n /**\n * Resumes the audio engine if it is not running.\n * @returns A promise that resolves when the audio engine is running.\n */\n public abstract resume(): Promise<void>;\n\n /**\n * Unlocks the audio engine if it is locked.\n * - Note that the returned promise may already be resolved if the audio engine is already unlocked.\n * @returns A promise that is resolved when the audio engine is unlocked.\n */\n public unlock(): Promise<void> {\n return this.resume();\n }\n\n protected _addMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.add(mainBus);\n\n this._addNode(mainBus);\n }\n\n protected _removeMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.delete(mainBus);\n this._defaultMainBus = null;\n\n this._removeNode(mainBus);\n }\n\n protected _addNode(node: AbstractNamedAudioNode): void {\n this._nodes.add(node);\n }\n\n protected _removeNode(node: AbstractNamedAudioNode): void {\n this._nodes.delete(node);\n }\n}\n\n/**\n * @internal\n * @param engine - The given audio engine. If `null` then the last created audio engine is used.\n * @returns the given audio engine or the last created audio engine.\n * @throws An error if the resulting engine is `null`.\n */\nexport function _GetAudioEngine(engine: Nullable<AudioEngineV2>): AudioEngineV2 {\n if (!engine) {\n engine = LastCreatedAudioEngine();\n }\n\n if (engine) {\n return engine;\n }\n\n throw new Error(\"No audio engine.\");\n}\n\n/**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created audio bus.\n */\nexport function CreateAudioBusAsync(name: string, options: Partial<IAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createBusAsync(name, options);\n}\n\n/**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created main audio bus.\n */\nexport function CreateMainAudioBusAsync(name: string, options: Partial<IMainAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<MainAudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createMainBusAsync(name, options);\n}\n\n/**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound.\n */\nexport function CreateSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSound> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundAsync(name, source, options);\n}\n\n/**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound buffer.\n */\nexport async function CreateSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundBufferOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSoundBuffer> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundBufferAsync(source, options);\n}\n\n/**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created streaming sound.\n */\nexport function CreateStreamingSoundAsync(\n name: string,\n source: HTMLMediaElement | string | string[],\n options: Partial<IStreamingSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StreamingSound> {\n engine = _GetAudioEngine(engine);\n return engine.createStreamingSoundAsync(name, source, options);\n}\n"]}
@@ -0,0 +1,43 @@
1
+ import type { Node } from "../../../node";
2
+ import { SpatialAudioAttachmentType } from "../../spatialAudioAttachmentType";
3
+ import type { _SpatialAudioSubNode } from "../subNodes/spatialAudioSubNode";
4
+ import type { _SpatialAudioListener } from "../subProperties/spatialAudioListener";
5
+ /**
6
+ * Provides a common interface for attaching an audio listener or source to a specific entity, ensuring only one entity
7
+ * is attached at a time.
8
+ * @internal
9
+ */
10
+ export declare class _SpatialAudioAttacherComponent {
11
+ /** @internal */
12
+ private _attachmentType;
13
+ private readonly _position;
14
+ private readonly _rotationQuaternion;
15
+ private _sceneNode;
16
+ private readonly _spatialAudioNode;
17
+ private _useBoundingBox;
18
+ /** @internal */
19
+ constructor(spatialAudioNode: _SpatialAudioSubNode | _SpatialAudioListener);
20
+ /**
21
+ * Returns `true` if the audio listener or source is attached to an entity; otherwise returns `false`.
22
+ */
23
+ get isAttached(): boolean;
24
+ /**
25
+ * Attaches a scene object.
26
+ * @param sceneNode The scene node to attach to.
27
+ * @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.
28
+ * @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.
29
+ */
30
+ attach(sceneNode: Node, useBoundingBox: boolean, attachmentType: SpatialAudioAttachmentType): void;
31
+ /**
32
+ * Detaches the attached entity.
33
+ */
34
+ detach(): void;
35
+ /**
36
+ * Releases associated resources.
37
+ */
38
+ dispose: () => void;
39
+ /**
40
+ * Updates the audio listener or source.
41
+ */
42
+ update(): void;
43
+ }
@@ -0,0 +1,71 @@
1
+ import { Quaternion, Vector3 } from "../../../Maths/math.vector.js";
2
+ /**
3
+ * Provides a common interface for attaching an audio listener or source to a specific entity, ensuring only one entity
4
+ * is attached at a time.
5
+ * @internal
6
+ */
7
+ export class _SpatialAudioAttacherComponent {
8
+ /** @internal */
9
+ constructor(spatialAudioNode) {
10
+ /** @internal */
11
+ this._attachmentType = 3 /* SpatialAudioAttachmentType.PositionAndRotation */;
12
+ this._position = new Vector3();
13
+ this._rotationQuaternion = new Quaternion();
14
+ this._sceneNode = null;
15
+ this._useBoundingBox = false;
16
+ /**
17
+ * Releases associated resources.
18
+ */
19
+ this.dispose = () => {
20
+ this.detach();
21
+ };
22
+ this._spatialAudioNode = spatialAudioNode;
23
+ }
24
+ /**
25
+ * Returns `true` if the audio listener or source is attached to an entity; otherwise returns `false`.
26
+ */
27
+ get isAttached() {
28
+ return this._sceneNode !== null;
29
+ }
30
+ /**
31
+ * Attaches a scene object.
32
+ * @param sceneNode The scene node to attach to.
33
+ * @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.
34
+ * @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.
35
+ */
36
+ attach(sceneNode, useBoundingBox, attachmentType) {
37
+ this.detach();
38
+ this._attachmentType = attachmentType;
39
+ this._sceneNode = sceneNode;
40
+ this._sceneNode.onDisposeObservable.add(this.dispose);
41
+ this._useBoundingBox = useBoundingBox;
42
+ }
43
+ /**
44
+ * Detaches the attached entity.
45
+ */
46
+ detach() {
47
+ this._sceneNode?.onDisposeObservable.removeCallback(this.dispose);
48
+ this._sceneNode = null;
49
+ }
50
+ /**
51
+ * Updates the audio listener or source.
52
+ */
53
+ update() {
54
+ if (this._attachmentType & 1 /* SpatialAudioAttachmentType.Position */) {
55
+ if (this._useBoundingBox && this._sceneNode.getBoundingInfo) {
56
+ this._position.copyFrom(this._sceneNode.getBoundingInfo().boundingBox.centerWorld);
57
+ }
58
+ else {
59
+ this._position.copyFrom(this._sceneNode.position);
60
+ }
61
+ this._spatialAudioNode.position.copyFrom(this._position);
62
+ this._spatialAudioNode.updatePosition();
63
+ }
64
+ if (this._attachmentType & 2 /* SpatialAudioAttachmentType.Rotation */) {
65
+ this._sceneNode?.getWorldMatrix().decompose(undefined, this._rotationQuaternion, undefined);
66
+ this._spatialAudioNode.rotationQuaternion.copyFrom(this._rotationQuaternion);
67
+ this._spatialAudioNode.updateRotation();
68
+ }
69
+ }
70
+ }
71
+ //# sourceMappingURL=spatialAudioAttacherComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spatialAudioAttacherComponent.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAQjE;;;;GAIG;AACH,MAAM,OAAO,8BAA8B;IASvC,gBAAgB;IAChB,YAAmB,gBAA8D;QATjF,gBAAgB;QACR,oBAAe,0DAA8E;QACpF,cAAS,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,wBAAmB,GAAG,IAAI,UAAU,EAAE,CAAC;QAChD,eAAU,GAAmB,IAAI,CAAC;QAElC,oBAAe,GAAY,KAAK,CAAC;QAuCzC;;WAEG;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C,iBAAiB,CAAC,cAAc,EAAE,CAAC;QAC5C,CAAC;QAED,IAAI,IAAI,CAAC,eAAe,8CAAsC,EAAE,CAAC;YAC7D,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;YAE5F,IAAI,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YAC7E,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,CAAC;QAC5C,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Quaternion, Vector3 } from \"../../../Maths/math.vector\";\nimport type { AbstractMesh } from \"../../../Meshes/abstractMesh\";\nimport type { Node } from \"../../../node\";\nimport type { Nullable } from \"../../../types\";\nimport { SpatialAudioAttachmentType } from \"../../spatialAudioAttachmentType\";\nimport type { _SpatialAudioSubNode } from \"../subNodes/spatialAudioSubNode\";\nimport type { _SpatialAudioListener } from \"../subProperties/spatialAudioListener\";\n\n/**\n * Provides a common interface for attaching an audio listener or source to a specific entity, ensuring only one entity\n * is attached at a time.\n * @internal\n */\nexport class _SpatialAudioAttacherComponent {\n /** @internal */\n private _attachmentType: SpatialAudioAttachmentType = SpatialAudioAttachmentType.PositionAndRotation;\n private readonly _position = new Vector3();\n private readonly _rotationQuaternion = new Quaternion();\n private _sceneNode: Nullable<Node> = null;\n private readonly _spatialAudioNode: _SpatialAudioSubNode | _SpatialAudioListener;\n private _useBoundingBox: boolean = false;\n\n /** @internal */\n public constructor(spatialAudioNode: _SpatialAudioSubNode | _SpatialAudioListener) {\n this._spatialAudioNode = spatialAudioNode;\n }\n\n /**\n * Returns `true` if the audio listener or source is attached to an entity; otherwise returns `false`.\n */\n public get isAttached(): boolean {\n return this._sceneNode !== null;\n }\n\n /**\n * Attaches a scene object.\n * @param sceneNode The scene node to attach to.\n * @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.\n * @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.\n */\n public attach(sceneNode: Node, useBoundingBox: boolean, attachmentType: SpatialAudioAttachmentType): void {\n this.detach();\n\n this._attachmentType = attachmentType;\n\n this._sceneNode = sceneNode;\n this._sceneNode.onDisposeObservable.add(this.dispose);\n\n this._useBoundingBox = useBoundingBox;\n }\n\n /**\n * Detaches the attached entity.\n */\n public detach() {\n this._sceneNode?.onDisposeObservable.removeCallback(this.dispose);\n this._sceneNode = null;\n }\n\n /**\n * Releases associated resources.\n */\n public dispose = () => {\n this.detach();\n };\n\n /**\n * Updates the audio listener or source.\n */\n public update() {\n if (this._attachmentType & SpatialAudioAttachmentType.Position) {\n if (this._useBoundingBox && (this._sceneNode as AbstractMesh).getBoundingInfo) {\n this._position.copyFrom((this._sceneNode as AbstractMesh).getBoundingInfo().boundingBox.centerWorld);\n } else {\n this._position.copyFrom((this._sceneNode as any).position);\n }\n\n this._spatialAudioNode.position.copyFrom(this._position);\n this._spatialAudioNode.updatePosition();\n }\n\n if (this._attachmentType & SpatialAudioAttachmentType.Rotation) {\n this._sceneNode?.getWorldMatrix().decompose(undefined, this._rotationQuaternion, undefined);\n\n this._spatialAudioNode.rotationQuaternion.copyFrom(this._rotationQuaternion);\n this._spatialAudioNode.updateRotation();\n }\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import { AbstractAudioBus } from "./abstractAudioBus";
2
2
  import type { AudioEngineV2 } from "./audioEngineV2";
3
- import type { IVolumeAudioOptions } from "./subNodes/volumeAudioSubNode";
3
+ import type { IAbstractAudioBusOptions } from "./abstractAudioBus";
4
4
  /**
5
5
  * Options for creating a main audio bus.
6
6
  */
7
- export interface IMainAudioBusOptions extends IVolumeAudioOptions {
7
+ export interface IMainAudioBusOptions extends IAbstractAudioBusOptions {
8
8
  }
9
9
  /**
10
10
  * Abstract class representing a main audio bus.
@@ -1 +1 @@
1
- {"version":3,"file":"mainAudioBus.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/mainAudioBus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD;;;;;;;;;;GAUG;AACH,MAAM,OAAgB,YAAa,SAAQ,gBAAgB;IACvD,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import { AbstractAudioBus } from \"./abstractAudioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\n\n/**\n * Options for creating a main audio bus.\n */\nexport interface IMainAudioBusOptions extends IVolumeAudioOptions {}\n\n/**\n * Abstract class representing a main audio bus.\n *\n * Main audio buses are the last bus in the audio graph.\n *\n * Unlike {@link AudioBus} instances, `MainAudioBus` instances have no spatial audio and stereo output capabilities,\n * and they cannot be connected downstream to another audio bus. They only connect downstream to the audio engine's\n * main output.\n *\n * Main audio buses are created by the {@link CreateMainAudioBusAsync} function.\n */\nexport abstract class MainAudioBus extends AbstractAudioBus {\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine);\n }\n}\n"]}
1
+ {"version":3,"file":"mainAudioBus.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/mainAudioBus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD;;;;;;;;;;GAUG;AACH,MAAM,OAAgB,YAAa,SAAQ,gBAAgB;IACvD,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import { AbstractAudioBus } from \"./abstractAudioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { IAbstractAudioBusOptions } from \"./abstractAudioBus\";\n\n/**\n * Options for creating a main audio bus.\n */\nexport interface IMainAudioBusOptions extends IAbstractAudioBusOptions {}\n\n/**\n * Abstract class representing a main audio bus.\n *\n * Main audio buses are the last bus in the audio graph.\n *\n * Unlike {@link AudioBus} instances, `MainAudioBus` instances have no spatial audio and stereo output capabilities,\n * and they cannot be connected downstream to another audio bus. They only connect downstream to the audio engine's\n * main output.\n *\n * Main audio buses are created by the {@link CreateMainAudioBusAsync} function.\n */\nexport abstract class MainAudioBus extends AbstractAudioBus {\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine);\n }\n}\n"]}