@babylonjs/core 7.52.2 → 7.53.0

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 (211) 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 +10 -3
  5. package/AudioV2/abstractAudio/abstractSound.js +10 -0
  6. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  7. package/AudioV2/abstractAudio/audioBus.d.ts +4 -4
  8. package/AudioV2/abstractAudio/audioBus.js.map +1 -1
  9. package/AudioV2/abstractAudio/mainAudioBus.d.ts +2 -2
  10. package/AudioV2/abstractAudio/mainAudioBus.js.map +1 -1
  11. package/AudioV2/abstractAudio/staticSound.d.ts +5 -5
  12. package/AudioV2/abstractAudio/staticSound.js +3 -3
  13. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  14. package/AudioV2/abstractAudio/streamingSound.d.ts +1 -1
  15. package/AudioV2/abstractAudio/streamingSound.js +1 -1
  16. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  17. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.d.ts +30 -9
  18. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +52 -26
  19. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
  20. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.d.ts +24 -0
  21. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js +30 -0
  22. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js.map +1 -0
  23. package/AudioV2/abstractAudio/subNodes/audioSubNode.d.ts +1 -0
  24. package/AudioV2/abstractAudio/subNodes/audioSubNode.js +1 -0
  25. package/AudioV2/abstractAudio/subNodes/audioSubNode.js.map +1 -1
  26. package/AudioV2/abstractAudio/subNodes/stereoAudioSubNode.js.map +1 -1
  27. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.d.ts +86 -0
  28. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js +29 -0
  29. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js.map +1 -0
  30. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.d.ts +35 -0
  31. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js +96 -0
  32. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js.map +1 -0
  33. package/AudioV2/abstractAudio/subProperties/index.d.ts +1 -0
  34. package/AudioV2/abstractAudio/subProperties/index.js +1 -0
  35. package/AudioV2/abstractAudio/subProperties/index.js.map +1 -1
  36. package/AudioV2/abstractAudio/subProperties/spatialAudio.js +10 -5
  37. package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
  38. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.d.ts +37 -0
  39. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js +85 -0
  40. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js.map +1 -0
  41. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.d.ts +5 -3
  42. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js +25 -2
  43. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js.map +1 -1
  44. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.d.ts +2 -1
  45. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +33 -18
  46. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
  47. package/Engines/WebGPU/webgpuTextureManager.d.ts +0 -1
  48. package/Engines/WebGPU/webgpuTextureManager.js +2 -57
  49. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  50. package/Engines/abstractEngine.d.ts +6 -0
  51. package/Engines/abstractEngine.js +3 -3
  52. package/Engines/abstractEngine.js.map +1 -1
  53. package/Engines/engine.common.js +4 -0
  54. package/Engines/engine.common.js.map +1 -1
  55. package/Engines/nativeEngine.d.ts +1 -0
  56. package/Engines/nativeEngine.js +3 -0
  57. package/Engines/nativeEngine.js.map +1 -1
  58. package/Engines/nullEngine.d.ts +1 -0
  59. package/Engines/nullEngine.js +1 -0
  60. package/Engines/nullEngine.js.map +1 -1
  61. package/Engines/thinEngine.d.ts +1 -0
  62. package/Engines/thinEngine.js +7 -4
  63. package/Engines/thinEngine.js.map +1 -1
  64. package/Engines/webgpuEngine.d.ts +2 -1
  65. package/Engines/webgpuEngine.js +12 -9
  66. package/Engines/webgpuEngine.js.map +1 -1
  67. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.d.ts +3 -12
  68. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +16 -36
  69. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -1
  70. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +5 -1
  71. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +17 -4
  72. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
  73. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.d.ts +48 -0
  74. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js +54 -0
  75. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js.map +1 -0
  76. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +3 -11
  77. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +5 -14
  78. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
  79. package/FlowGraph/Blocks/Data/index.d.ts +1 -0
  80. package/FlowGraph/Blocks/Data/index.js +1 -0
  81. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  82. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +1 -0
  83. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +19 -13
  84. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  85. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +3 -5
  86. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  87. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js +1 -1
  88. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js.map +1 -1
  89. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js +2 -4
  90. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js.map +1 -1
  91. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +1 -1
  92. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
  93. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +1 -2
  94. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  95. package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
  96. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
  97. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +2 -1
  98. package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
  99. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
  100. package/FlowGraph/CustomTypes/flowGraphInteger.d.ts +1 -0
  101. package/FlowGraph/CustomTypes/flowGraphInteger.js +3 -0
  102. package/FlowGraph/CustomTypes/flowGraphInteger.js.map +1 -1
  103. package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +2 -0
  104. package/FlowGraph/CustomTypes/flowGraphMatrix.js +6 -0
  105. package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
  106. package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -0
  107. package/FlowGraph/flowGraphExecutionBlock.js +4 -0
  108. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  109. package/FlowGraph/utils.d.ts +2 -1
  110. package/FlowGraph/utils.js +7 -2
  111. package/FlowGraph/utils.js.map +1 -1
  112. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +2 -2
  113. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
  114. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +2 -2
  115. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -1
  116. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.d.ts +126 -0
  117. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +497 -0
  118. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -0
  119. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
  120. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +30 -4
  121. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
  122. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  123. package/FrameGraph/Node/Blocks/index.js +1 -0
  124. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  125. package/FrameGraph/Node/nodeRenderGraph.js +1 -1
  126. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  127. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +2 -3
  128. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +3 -4
  129. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  130. package/FrameGraph/Tasks/PostProcesses/blurTask.js +2 -2
  131. package/FrameGraph/Tasks/PostProcesses/blurTask.js.map +1 -1
  132. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +2 -3
  133. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +4 -5
  134. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
  135. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +6 -0
  136. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +14 -0
  137. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  138. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.d.ts +11 -0
  139. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js +18 -0
  140. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js.map +1 -0
  141. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.d.ts +76 -0
  142. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +170 -0
  143. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -0
  144. package/FrameGraph/Tasks/PostProcesses/ssrTask.d.ts +16 -0
  145. package/FrameGraph/Tasks/PostProcesses/ssrTask.js +45 -0
  146. package/FrameGraph/Tasks/PostProcesses/ssrTask.js.map +1 -0
  147. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +10 -0
  148. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +29 -0
  149. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  150. package/FrameGraph/frameGraph.d.ts +7 -3
  151. package/FrameGraph/frameGraph.js +10 -4
  152. package/FrameGraph/frameGraph.js.map +1 -1
  153. package/FrameGraph/frameGraphTextureManager.d.ts +2 -1
  154. package/FrameGraph/frameGraphTextureManager.js +4 -3
  155. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  156. package/FrameGraph/index.d.ts +1 -0
  157. package/FrameGraph/index.js +1 -0
  158. package/FrameGraph/index.js.map +1 -1
  159. package/Materials/Node/nodeMaterial.js +3 -0
  160. package/Materials/Node/nodeMaterial.js.map +1 -1
  161. package/Materials/PBR/pbrBaseMaterial.js +1 -1
  162. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  163. package/Materials/effectRenderer.js +1 -1
  164. package/Materials/effectRenderer.js.map +1 -1
  165. package/Materials/material.js +5 -3
  166. package/Materials/material.js.map +1 -1
  167. package/Materials/materialHelper.geometryrendering.d.ts +7 -5
  168. package/Materials/materialHelper.geometryrendering.js +8 -3
  169. package/Materials/materialHelper.geometryrendering.js.map +1 -1
  170. package/Materials/standardMaterial.js +1 -1
  171. package/Materials/standardMaterial.js.map +1 -1
  172. package/Meshes/Builders/shapeBuilder.d.ts +2 -0
  173. package/Meshes/Builders/shapeBuilder.js +7 -4
  174. package/Meshes/Builders/shapeBuilder.js.map +1 -1
  175. package/Meshes/geometry.js +4 -0
  176. package/Meshes/geometry.js.map +1 -1
  177. package/Particles/particleSystemComponent.d.ts +2 -1
  178. package/Particles/particleSystemComponent.js +2 -2
  179. package/Particles/particleSystemComponent.js.map +1 -1
  180. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +23 -30
  181. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +226 -411
  182. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  183. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.d.ts +222 -0
  184. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js +373 -0
  185. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js.map +1 -0
  186. package/PostProcesses/postProcess.d.ts +5 -0
  187. package/PostProcesses/postProcess.js +10 -2
  188. package/PostProcesses/postProcess.js.map +1 -1
  189. package/PostProcesses/thinDepthOfFieldEffect.d.ts +4 -4
  190. package/PostProcesses/thinDepthOfFieldEffect.js.map +1 -1
  191. package/PostProcesses/thinSSRBlurCombinerPostProcess.d.ts +41 -0
  192. package/PostProcesses/thinSSRBlurCombinerPostProcess.js +185 -0
  193. package/PostProcesses/thinSSRBlurCombinerPostProcess.js.map +1 -0
  194. package/PostProcesses/thinSSRBlurPostProcess.d.ts +18 -0
  195. package/PostProcesses/thinSSRBlurPostProcess.js +47 -0
  196. package/PostProcesses/thinSSRBlurPostProcess.js.map +1 -0
  197. package/PostProcesses/thinSSRPostProcess.d.ts +94 -0
  198. package/PostProcesses/thinSSRPostProcess.js +416 -0
  199. package/PostProcesses/thinSSRPostProcess.js.map +1 -0
  200. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +2 -0
  201. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -0
  202. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  203. package/Rendering/iblCdfGenerator.js +1 -1
  204. package/Rendering/iblCdfGenerator.js.map +1 -1
  205. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
  206. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
  207. package/ShadersWGSL/geometry.fragment.js +1 -1
  208. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  209. package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
  210. package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
  211. 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,6 +59,7 @@ 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;
@@ -69,6 +72,10 @@ export declare abstract class AbstractSound extends AbstractNamedAudioNode {
69
72
  */
70
73
  readonly onEndedObservable: Observable<AbstractSound>;
71
74
  protected constructor(name: string, engine: AudioEngineV2);
75
+ /**
76
+ * The analyzer features of the sound.
77
+ */
78
+ get analyzer(): _AudioAnalyzer;
72
79
  /**
73
80
  * Whether the sound should start playing automatically. Defaults to `false`.
74
81
  */
@@ -96,7 +103,7 @@ export declare abstract class AbstractSound extends AbstractNamedAudioNode {
96
103
  get outBus(): Nullable<PrimaryAudioBus>;
97
104
  set outBus(outBus: Nullable<PrimaryAudioBus>);
98
105
  /**
99
- * The spatial properties of the sound.
106
+ * The spatial features of the sound.
100
107
  */
101
108
  abstract spatial: AbstractSpatialAudio;
102
109
  /**
@@ -109,7 +116,7 @@ export declare abstract class AbstractSound extends AbstractNamedAudioNode {
109
116
  */
110
117
  get state(): SoundState;
111
118
  /**
112
- * The stereo properties of the sound.
119
+ * The stereo features of the sound.
113
120
  */
114
121
  abstract stereo: AbstractStereoAudio;
115
122
  /**
@@ -1,12 +1,14 @@
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
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();
@@ -30,6 +32,12 @@ export class AbstractSound extends AbstractNamedAudioNode {
30
32
  this.outBus = null;
31
33
  };
32
34
  }
35
+ /**
36
+ * The analyzer features of the sound.
37
+ */
38
+ get analyzer() {
39
+ return this._analyzer ?? (this._analyzer = new _AudioAnalyzer(this._subGraph));
40
+ }
33
41
  /**
34
42
  * Whether the sound should start playing automatically. Defaults to `false`.
35
43
  */
@@ -129,6 +137,8 @@ export class AbstractSound extends AbstractNamedAudioNode {
129
137
  dispose() {
130
138
  super.dispose();
131
139
  this.stop();
140
+ this._analyzer?.dispose();
141
+ this._analyzer = null;
132
142
  this._newestInstance = null;
133
143
  this._outBus = null;
134
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;AACH,MAAM,OAAgB,aAAc,SAAQ,sBAAsB;IAe9D,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,+CAAuC,CAAC,CAAC,4BAA4B;QAfnF,oBAAe,GAAqC,IAAI,CAAC;QACzD,YAAO,GAA8B,IAAI,CAAC;QAC1C,sBAAiB,GAAG,IAAI,GAAG,EAA0B,CAAC;QACtD,WAAM,8BAAkC;QAEtC,eAAU,GAAwC,IAAI,CAAC,iBAAiB,CAAC;QAInF;;WAEG;QACa,sBAAiB,GAAG,IAAI,UAAU,EAAiB,CAAC;QAwO5D,qBAAgB,GAA+C,CAAC,QAAQ,EAAE,EAAE;YAChF,IAAI,IAAI,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;gBACpC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;YAChC,CAAC;YAED,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAExC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBAC7B,IAAI,CAAC,MAAM,6BAAqB,CAAC;gBACjC,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YACjD,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AI,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 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 * 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,EA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K,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 { 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}
@@ -32,11 +32,11 @@ export declare abstract class AudioBus extends AbstractAudioBus {
32
32
  get outBus(): Nullable<PrimaryAudioBus>;
33
33
  set outBus(outBus: Nullable<PrimaryAudioBus>);
34
34
  /**
35
- * The spatial audio properties of the audio bus.
35
+ * The spatial features of the audio bus.
36
36
  */
37
37
  abstract readonly spatial: AbstractSpatialAudio;
38
38
  /**
39
- * The stereo audio properties of the audio bus.
39
+ * The stereo features of the audio bus.
40
40
  */
41
41
  abstract readonly stereo: AbstractStereoAudio;
42
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file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AC;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 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 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":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAoBtD;;;;;;GAMG;AACH,MAAM,OAAgB,QAAS,SAAQ,gBAAgB;IAGnD,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAHhB,YAAO,GAA8B,IAAI,CAAC;QAuD1C,sBAAiB,GAAG,GAAG,EAAE;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAC7C,CAAC,CAAC;IArDF,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 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"]}
@@ -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"]}
@@ -37,7 +37,7 @@ export interface IStaticSoundOptionsBase {
37
37
  /** @internal */
38
38
  export interface IStaticSoundPlayOptionsBase {
39
39
  /**
40
- * The time to wait before playing the sound, in seconds.
40
+ * The time to wait before playing the sound, in seconds. Defaults to `0`.
41
41
  */
42
42
  waitTime: number;
43
43
  }
@@ -56,7 +56,7 @@ export interface IStaticSoundPlayOptions extends IAbstractSoundPlayOptions, ISta
56
56
  */
57
57
  export interface IStaticSoundStopOptions {
58
58
  /**
59
- * The time to wait before stopping the sound, in seconds.
59
+ * The time to wait before stopping the sound, in seconds. Defaults to `0`.
60
60
  */
61
61
  waitTime: number;
62
62
  }
@@ -89,7 +89,7 @@ export declare abstract class StaticSound extends AbstractSound {
89
89
  abstract readonly buffer: StaticSoundBuffer;
90
90
  protected constructor(name: string, engine: AudioEngineV2);
91
91
  /**
92
- * The amount of time to play the sound for, in seconds.
92
+ * The amount of time to play the sound for, in seconds. Defaults to `0`.
93
93
  * - If less than or equal to `0`, the sound plays for its full duration.
94
94
  */
95
95
  get duration(): number;
@@ -107,13 +107,13 @@ export declare abstract class StaticSound extends AbstractSound {
107
107
  get loopEnd(): number;
108
108
  set loopEnd(value: number);
109
109
  /**
110
- * The pitch of the sound, in cents.
110
+ * The pitch of the sound, in cents. Defaults to `0`.
111
111
  * - Gets combined with {@link playbackRate} to determine the final pitch.
112
112
  */
113
113
  get pitch(): number;
114
114
  set pitch(value: number);
115
115
  /**
116
- * The playback rate of the sound.
116
+ * The playback rate of the sound. Defaults to `1`.
117
117
  * - Gets combined with {@link pitch} to determine the final playback rate.
118
118
  */
119
119
  get playbackRate(): number;
@@ -16,7 +16,7 @@ export class StaticSound extends AbstractSound {
16
16
  super(name, engine);
17
17
  }
18
18
  /**
19
- * The amount of time to play the sound for, in seconds.
19
+ * The amount of time to play the sound for, in seconds. Defaults to `0`.
20
20
  * - If less than or equal to `0`, the sound plays for its full duration.
21
21
  */
22
22
  get duration() {
@@ -46,7 +46,7 @@ export class StaticSound extends AbstractSound {
46
46
  this._options.loopEnd = value;
47
47
  }
48
48
  /**
49
- * The pitch of the sound, in cents.
49
+ * The pitch of the sound, in cents. Defaults to `0`.
50
50
  * - Gets combined with {@link playbackRate} to determine the final pitch.
51
51
  */
52
52
  get pitch() {
@@ -56,7 +56,7 @@ export class StaticSound extends AbstractSound {
56
56
  this._options.pitch = value;
57
57
  }
58
58
  /**
59
- * The playback rate of the sound.
59
+ * The playback rate of the sound. Defaults to `1`.
60
60
  * - Gets combined with {@link pitch} to determine the final playback rate.
61
61
  */
62
62
  get playbackRate() {
@@ -1 +1 @@
1
- {"version":3,"file":"staticSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/staticSound.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAuEhD;;;;;;;;;;;GAWG;AACH,MAAM,OAAgB,WAAY,SAAQ,aAAa;IAWnD,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED,IAAW,QAAQ,CAAC,KAAa;QAC7B,IAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,KAAK,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;IACnC,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,KAAK,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,IAAW,OAAO;QACd,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AW,EAAC;QACzC,OAAO,CAAC,MAAM,KAAd,OAAO,CAAC,MAAM,GAAK,CAAC,EAAC;QACrB,OAAO,CAAC,QAAQ,KAAhB,OAAO,CAAC,QAAQ,GAAK,CAAC,EAAC;QAEvB,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACxC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC3B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAE1B,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,UAA4C,EAAE;QACtD,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC3C,IAAI,CAAC,SAAS,6BAAqB,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,SAAS,4BAAoB,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACnB,OAAO;QACX,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { SoundState } from \"../soundState\";\nimport type { IAbstractSoundOptions, IAbstractSoundPlayOptions, IAbstractSoundStoredOptions } from \"./abstractSound\";\nimport { AbstractSound } from \"./abstractSound\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { IStaticSoundBufferOptions, StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport type { _StaticSoundInstance } from \"./staticSoundInstance\";\n\n/** @internal */\nexport interface IStaticSoundOptionsBase {\n /**\n * The amount of time to play the sound for, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the sound plays for its full duration.\n */\n duration: number;\n /**\n * The end of the loop range in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop plays for the sound's full duration.\n * - Has no effect if {@link loop} is `false`.\n */\n loopEnd: number;\n /**\n * The start of the loop range in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop starts at the beginning of the sound.\n * - Has no effect if {@link loop} is `false`.\n *\n */\n loopStart: number;\n /**\n * The pitch of the sound, in cents. Defaults to `0`.\n * - Can be combined with {@link playbackRate}.\n */\n pitch: number;\n /**\n * The playback rate of the sound. Defaults to `1`.\n * - Can be combined with {@link pitch}.\n */\n playbackRate: number;\n}\n\n/** @internal */\nexport interface IStaticSoundPlayOptionsBase {\n /**\n * The time to wait before playing the sound, in seconds.\n */\n waitTime: number;\n}\n\n/**\n * Options for creating a static sound.\n */\nexport interface IStaticSoundOptions extends IAbstractSoundOptions, IStaticSoundBufferOptions, IStaticSoundStoredOptions {}\n\n/**\n * Options for playing a static sound.\n */\nexport interface IStaticSoundPlayOptions extends IAbstractSoundPlayOptions, IStaticSoundOptionsBase, IStaticSoundPlayOptionsBase {}\n\n/**\n * Options for stopping a static sound.\n */\nexport interface IStaticSoundStopOptions {\n /**\n * The time to wait before stopping the sound, in seconds.\n */\n waitTime: number;\n}\n\n/**\n * Options stored in a static sound.\n * @internal\n */\nexport interface IStaticSoundStoredOptions extends IAbstractSoundStoredOptions, IStaticSoundOptionsBase {}\n\n/**\n * Abstract class representing a static sound.\n *\n * A static sound has a sound buffer that is loaded into memory all at once. This allows it to have more capabilities\n * than a streaming sound, such as loop points and playback rate changes, but it also means that the sound must be\n * fully downloaded and decoded before it can be played, which may take a long time for sounds with long durations.\n *\n * To prevent downloading and decoding a sound multiple times, a sound's buffer can be shared with other sounds.\n * See {@link CreateSoundBufferAsync}, {@link StaticSoundBuffer} and {@link StaticSound.buffer} for more information.\n *\n * Static sounds are created by the {@link CreateSoundAsync} function.\n */\nexport abstract class StaticSound extends AbstractSound {\n protected override _instances: Set<_StaticSoundInstance>;\n protected abstract override readonly _options: IStaticSoundStoredOptions;\n\n /**\n * The sound buffer that the sound uses.\n *\n * This buffer can be shared with other static sounds.\n */\n public abstract readonly buffer: StaticSoundBuffer;\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine);\n }\n\n /**\n * The amount of time to play the sound for, in seconds.\n * - If less than or equal to `0`, the sound plays for its full duration.\n */\n public get duration(): number {\n return this._options.duration;\n }\n\n public set duration(value: number) {\n this._options.duration = value;\n }\n\n /**\n * The start of the loop range, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop starts at the beginning of the sound.\n */\n public get loopStart(): number {\n return this._options.loopStart;\n }\n\n public set loopStart(value: number) {\n this._options.loopStart = value;\n }\n\n /**\n * The end of the loop range, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop plays for the sound's full duration.\n */\n public get loopEnd(): number {\n return this._options.loopEnd;\n }\n\n public set loopEnd(value: number) {\n this._options.loopEnd = value;\n }\n\n /**\n * The pitch of the sound, in cents.\n * - Gets combined with {@link playbackRate} to determine the final pitch.\n */\n public get pitch(): number {\n return this._options.pitch;\n }\n\n public set pitch(value: number) {\n this._options.pitch = value;\n }\n\n /**\n * The playback rate of the sound.\n * - Gets combined with {@link pitch} to determine the final playback rate.\n */\n public get playbackRate(): number {\n return this._options.playbackRate;\n }\n\n public set playbackRate(value: number) {\n this._options.playbackRate = value;\n }\n\n protected abstract override _createInstance(): _StaticSoundInstance;\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 play(options: Partial<IStaticSoundPlayOptions> = {}): void {\n if (this.state === SoundState.Paused) {\n this.resume();\n return;\n }\n\n options.duration ??= this.duration;\n options.loop ??= this.loop;\n options.loopStart ??= this.loopStart;\n options.loopEnd ??= this.loopEnd;\n options.pitch ??= this.pitch;\n options.playbackRate ??= this.playbackRate;\n options.startOffset ??= this.startOffset;\n options.volume ??= 1;\n options.waitTime ??= 0;\n\n const instance = this._createInstance();\n this._beforePlay(instance);\n instance.play(options);\n this._afterPlay(instance);\n\n this._stopExcessInstances();\n }\n\n /**\n * Stops the sound.\n * - Triggers `onEndedObservable` if the sound is playing.\n * @param options - The options to use when stopping the sound.\n */\n public stop(options: Partial<IStaticSoundStopOptions> = {}): void {\n if (options.waitTime && 0 < options.waitTime) {\n this._setState(SoundState.Stopping);\n } else {\n this._setState(SoundState.Stopped);\n }\n\n if (!this._instances) {\n return;\n }\n\n for (const instance of Array.from(this._instances)) {\n instance.stop(options);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"staticSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/staticSound.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAuEhD;;;;;;;;;;;GAWG;AACH,MAAM,OAAgB,WAAY,SAAQ,aAAa;IAWnD,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED,IAAW,QAAQ,CAAC,KAAa;QAC7B,IAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,KAAK,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;IACnC,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,KAAK,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,IAAW,OAAO,CAAC,KAAa;QAC5B,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,KAAK,CAA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,EAAC;QAEvB,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACxC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC3B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAE1B,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,UAA4C,EAAE;QACtD,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC3C,IAAI,CAAC,SAAS,6BAAqB,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,SAAS,4BAAoB,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACnB,OAAO;QACX,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { SoundState } from \"../soundState\";\nimport type { IAbstractSoundOptions, IAbstractSoundPlayOptions, IAbstractSoundStoredOptions } from \"./abstractSound\";\nimport { AbstractSound } from \"./abstractSound\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { IStaticSoundBufferOptions, StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport type { _StaticSoundInstance } from \"./staticSoundInstance\";\n\n/** @internal */\nexport interface IStaticSoundOptionsBase {\n /**\n * The amount of time to play the sound for, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the sound plays for its full duration.\n */\n duration: number;\n /**\n * The end of the loop range in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop plays for the sound's full duration.\n * - Has no effect if {@link loop} is `false`.\n */\n loopEnd: number;\n /**\n * The start of the loop range in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop starts at the beginning of the sound.\n * - Has no effect if {@link loop} is `false`.\n *\n */\n loopStart: number;\n /**\n * The pitch of the sound, in cents. Defaults to `0`.\n * - Can be combined with {@link playbackRate}.\n */\n pitch: number;\n /**\n * The playback rate of the sound. Defaults to `1`.\n * - Can be combined with {@link pitch}.\n */\n playbackRate: number;\n}\n\n/** @internal */\nexport interface IStaticSoundPlayOptionsBase {\n /**\n * The time to wait before playing the sound, in seconds. Defaults to `0`.\n */\n waitTime: number;\n}\n\n/**\n * Options for creating a static sound.\n */\nexport interface IStaticSoundOptions extends IAbstractSoundOptions, IStaticSoundBufferOptions, IStaticSoundStoredOptions {}\n\n/**\n * Options for playing a static sound.\n */\nexport interface IStaticSoundPlayOptions extends IAbstractSoundPlayOptions, IStaticSoundOptionsBase, IStaticSoundPlayOptionsBase {}\n\n/**\n * Options for stopping a static sound.\n */\nexport interface IStaticSoundStopOptions {\n /**\n * The time to wait before stopping the sound, in seconds. Defaults to `0`.\n */\n waitTime: number;\n}\n\n/**\n * Options stored in a static sound.\n * @internal\n */\nexport interface IStaticSoundStoredOptions extends IAbstractSoundStoredOptions, IStaticSoundOptionsBase {}\n\n/**\n * Abstract class representing a static sound.\n *\n * A static sound has a sound buffer that is loaded into memory all at once. This allows it to have more capabilities\n * than a streaming sound, such as loop points and playback rate changes, but it also means that the sound must be\n * fully downloaded and decoded before it can be played, which may take a long time for sounds with long durations.\n *\n * To prevent downloading and decoding a sound multiple times, a sound's buffer can be shared with other sounds.\n * See {@link CreateSoundBufferAsync}, {@link StaticSoundBuffer} and {@link StaticSound.buffer} for more information.\n *\n * Static sounds are created by the {@link CreateSoundAsync} function.\n */\nexport abstract class StaticSound extends AbstractSound {\n protected override _instances: Set<_StaticSoundInstance>;\n protected abstract override readonly _options: IStaticSoundStoredOptions;\n\n /**\n * The sound buffer that the sound uses.\n *\n * This buffer can be shared with other static sounds.\n */\n public abstract readonly buffer: StaticSoundBuffer;\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine);\n }\n\n /**\n * The amount of time to play the sound for, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the sound plays for its full duration.\n */\n public get duration(): number {\n return this._options.duration;\n }\n\n public set duration(value: number) {\n this._options.duration = value;\n }\n\n /**\n * The start of the loop range, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop starts at the beginning of the sound.\n */\n public get loopStart(): number {\n return this._options.loopStart;\n }\n\n public set loopStart(value: number) {\n this._options.loopStart = value;\n }\n\n /**\n * The end of the loop range, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop plays for the sound's full duration.\n */\n public get loopEnd(): number {\n return this._options.loopEnd;\n }\n\n public set loopEnd(value: number) {\n this._options.loopEnd = value;\n }\n\n /**\n * The pitch of the sound, in cents. Defaults to `0`.\n * - Gets combined with {@link playbackRate} to determine the final pitch.\n */\n public get pitch(): number {\n return this._options.pitch;\n }\n\n public set pitch(value: number) {\n this._options.pitch = value;\n }\n\n /**\n * The playback rate of the sound. Defaults to `1`.\n * - Gets combined with {@link pitch} to determine the final playback rate.\n */\n public get playbackRate(): number {\n return this._options.playbackRate;\n }\n\n public set playbackRate(value: number) {\n this._options.playbackRate = value;\n }\n\n protected abstract override _createInstance(): _StaticSoundInstance;\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 play(options: Partial<IStaticSoundPlayOptions> = {}): void {\n if (this.state === SoundState.Paused) {\n this.resume();\n return;\n }\n\n options.duration ??= this.duration;\n options.loop ??= this.loop;\n options.loopStart ??= this.loopStart;\n options.loopEnd ??= this.loopEnd;\n options.pitch ??= this.pitch;\n options.playbackRate ??= this.playbackRate;\n options.startOffset ??= this.startOffset;\n options.volume ??= 1;\n options.waitTime ??= 0;\n\n const instance = this._createInstance();\n this._beforePlay(instance);\n instance.play(options);\n this._afterPlay(instance);\n\n this._stopExcessInstances();\n }\n\n /**\n * Stops the sound.\n * - Triggers `onEndedObservable` if the sound is playing.\n * @param options - The options to use when stopping the sound.\n */\n public stop(options: Partial<IStaticSoundStopOptions> = {}): void {\n if (options.waitTime && 0 < options.waitTime) {\n this._setState(SoundState.Stopping);\n } else {\n this._setState(SoundState.Stopped);\n }\n\n if (!this._instances) {\n return;\n }\n\n for (const instance of Array.from(this._instances)) {\n instance.stop(options);\n }\n }\n}\n"]}
@@ -43,7 +43,7 @@ export declare abstract class StreamingSound extends AbstractSound {
43
43
  protected abstract readonly _options: IStreamingSoundStoredOptions;
44
44
  protected constructor(name: string, engine: AudioEngineV2);
45
45
  /**
46
- * The number of instances to preload.
46
+ * The number of instances to preload. Defaults to `1`.
47
47
  */
48
48
  get preloadCount(): number;
49
49
  /**
@@ -18,7 +18,7 @@ export class StreamingSound extends AbstractSound {
18
18
  this._preloadedInstances = new Array();
19
19
  }
20
20
  /**
21
- * The number of instances to preload.
21
+ * The number of instances to preload. Defaults to `1`.
22
22
  */
23
23
  get preloadCount() {
24
24
  return this._options.preloadCount ?? 1;
@@ -1 +1 @@
1
- {"version":3,"file":"streamingSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/streamingSound.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA4BhD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAgB,cAAe,SAAQ,aAAa;IAKtD,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QALhB,wBAAmB,GAAG,IAAI,KAAK,EAA2B,CAAC;IAMnE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,IAAW,qBAAqB;QAC5B,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM,CA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CACJ","sourcesContent":["import { SoundState } from \"../soundState\";\nimport type { IAbstractSoundOptions, IAbstractSoundPlayOptions, IAbstractSoundStoredOptions } from \"./abstractSound\";\nimport { AbstractSound } from \"./abstractSound\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { _StreamingSoundInstance } from \"./streamingSoundInstance\";\n\n/** @internal */\nexport interface IStreamingSoundOptionsBase {\n /**\n * The number of instances to preload. Defaults to 1.\n * */\n preloadCount: number;\n}\n\n/**\n * Options for creating a streaming sound.\n */\nexport interface IStreamingSoundOptions extends IAbstractSoundOptions, IStreamingSoundOptionsBase {}\n\n/**\n * Options for playing a streaming sound.\n */\nexport interface IStreamingSoundPlayOptions extends IAbstractSoundPlayOptions {}\n\n/**\n * Options stored in a streaming sound.\n * @internal\n */\nexport interface IStreamingSoundStoredOptions extends IAbstractSoundStoredOptions, IStreamingSoundOptionsBase {}\n\n/**\n * Abstract class representing a streaming sound.\n *\n * A streaming sound has a sound buffer that is loaded into memory in chunks as it is played. This allows it to be played\n * more quickly than a static sound, but it also means that it cannot have loop points or playback rate changes.\n *\n * Due to the way streaming sounds are typically implemented, there can be a significant delay when attempting to play\n * a streaming sound for the first time. To prevent this delay, it is recommended to preload instances of the sound\n * using the {@link IStreamingSoundStoredOptions.preloadCount} options, or the {@link preloadInstance} and\n * {@link preloadInstances} methods before calling the `play` method.\n *\n * Streaming sounds are created by the {@link CreateStreamingSoundAsync} function.\n */\nexport abstract class StreamingSound extends AbstractSound {\n private _preloadedInstances = new Array<_StreamingSoundInstance>();\n\n protected abstract override readonly _options: IStreamingSoundStoredOptions;\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine);\n }\n\n /**\n * The number of instances to preload.\n */\n public get preloadCount(): number {\n return this._options.preloadCount ?? 1;\n }\n\n /**\n * Returns the number of instances that have been preloaded.\n */\n public get preloadCompletedCount(): number {\n return this._preloadedInstances.length;\n }\n\n /**\n * Preloads an instance of the sound.\n * @returns A promise that resolves when the instance is preloaded.\n */\n public preloadInstance(): Promise<void> {\n const instance = this._createInstance();\n\n this._addPreloadedInstance(instance);\n\n return instance.preloadedPromise;\n }\n\n /**\n * Preloads the given number of instances of the sound.\n * @param count - The number of instances to preload.\n * @returns A promise that resolves when all instances are preloaded.\n */\n public async preloadInstances(count: number): Promise<void> {\n for (let i = 0; i < count; i++) {\n this.preloadInstance();\n }\n\n await Promise.all(this._preloadedInstances.map((instance) => instance.preloadedPromise));\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 play(options: Partial<IStreamingSoundPlayOptions> = {}): void {\n if (this.state === SoundState.Paused) {\n this.resume();\n return;\n }\n\n let instance: _StreamingSoundInstance;\n\n if (this.preloadCompletedCount > 0) {\n instance = this._preloadedInstances[0];\n instance.startOffset = this.startOffset;\n this._removePreloadedInstance(instance);\n } else {\n instance = this._createInstance();\n }\n\n const onInstanceStateChanged = () => {\n if (instance.state === SoundState.Started) {\n this._stopExcessInstances();\n instance.onStateChangedObservable.removeCallback(onInstanceStateChanged);\n }\n };\n instance.onStateChangedObservable.add(onInstanceStateChanged);\n\n options.startOffset ??= this.startOffset;\n options.loop ??= this.loop;\n options.volume ??= 1;\n\n this._beforePlay(instance);\n instance.play(options);\n this._afterPlay(instance);\n }\n\n /**\n * Stops the sound.\n */\n public stop(): void {\n this._setState(SoundState.Stopped);\n\n if (!this._instances) {\n return;\n }\n\n for (const instance of Array.from(this._instances)) {\n instance.stop();\n }\n }\n\n protected abstract override _createInstance(): _StreamingSoundInstance;\n\n private _addPreloadedInstance(instance: _StreamingSoundInstance): void {\n if (!this._preloadedInstances.includes(instance)) {\n this._preloadedInstances.push(instance);\n }\n }\n\n private _removePreloadedInstance(instance: _StreamingSoundInstance): void {\n const index = this._preloadedInstances.indexOf(instance);\n if (index !== -1) {\n this._preloadedInstances.splice(index, 1);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"streaming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ACjD,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpB,CAAC;IACL,CAAC;IAIO,qBAAqB,CAAC,QAAiC;QAC3D,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;IACL,CAAC;IAEO,wBAAwB,CAAC,QAAiC;QAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { SoundState } from \"../soundState\";\nimport type { IAbstractSoundOptions, IAbstractSoundPlayOptions, IAbstractSoundStoredOptions } from \"./abstractSound\";\nimport { AbstractSound } from \"./abstractSound\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { _StreamingSoundInstance } from \"./streamingSoundInstance\";\n\n/** @internal */\nexport interface IStreamingSoundOptionsBase {\n /**\n * The number of instances to preload. Defaults to 1.\n * */\n preloadCount: number;\n}\n\n/**\n * Options for creating a streaming sound.\n */\nexport interface IStreamingSoundOptions extends IAbstractSoundOptions, IStreamingSoundOptionsBase {}\n\n/**\n * Options for playing a streaming sound.\n */\nexport interface IStreamingSoundPlayOptions extends IAbstractSoundPlayOptions {}\n\n/**\n * Options stored in a streaming sound.\n * @internal\n */\nexport interface IStreamingSoundStoredOptions extends IAbstractSoundStoredOptions, IStreamingSoundOptionsBase {}\n\n/**\n * Abstract class representing a streaming sound.\n *\n * A streaming sound has a sound buffer that is loaded into memory in chunks as it is played. This allows it to be played\n * more quickly than a static sound, but it also means that it cannot have loop points or playback rate changes.\n *\n * Due to the way streaming sounds are typically implemented, there can be a significant delay when attempting to play\n * a streaming sound for the first time. To prevent this delay, it is recommended to preload instances of the sound\n * using the {@link IStreamingSoundStoredOptions.preloadCount} options, or the {@link preloadInstance} and\n * {@link preloadInstances} methods before calling the `play` method.\n *\n * Streaming sounds are created by the {@link CreateStreamingSoundAsync} function.\n */\nexport abstract class StreamingSound extends AbstractSound {\n private _preloadedInstances = new Array<_StreamingSoundInstance>();\n\n protected abstract override readonly _options: IStreamingSoundStoredOptions;\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine);\n }\n\n /**\n * The number of instances to preload. Defaults to `1`.\n */\n public get preloadCount(): number {\n return this._options.preloadCount ?? 1;\n }\n\n /**\n * Returns the number of instances that have been preloaded.\n */\n public get preloadCompletedCount(): number {\n return this._preloadedInstances.length;\n }\n\n /**\n * Preloads an instance of the sound.\n * @returns A promise that resolves when the instance is preloaded.\n */\n public preloadInstance(): Promise<void> {\n const instance = this._createInstance();\n\n this._addPreloadedInstance(instance);\n\n return instance.preloadedPromise;\n }\n\n /**\n * Preloads the given number of instances of the sound.\n * @param count - The number of instances to preload.\n * @returns A promise that resolves when all instances are preloaded.\n */\n public async preloadInstances(count: number): Promise<void> {\n for (let i = 0; i < count; i++) {\n this.preloadInstance();\n }\n\n await Promise.all(this._preloadedInstances.map((instance) => instance.preloadedPromise));\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 play(options: Partial<IStreamingSoundPlayOptions> = {}): void {\n if (this.state === SoundState.Paused) {\n this.resume();\n return;\n }\n\n let instance: _StreamingSoundInstance;\n\n if (this.preloadCompletedCount > 0) {\n instance = this._preloadedInstances[0];\n instance.startOffset = this.startOffset;\n this._removePreloadedInstance(instance);\n } else {\n instance = this._createInstance();\n }\n\n const onInstanceStateChanged = () => {\n if (instance.state === SoundState.Started) {\n this._stopExcessInstances();\n instance.onStateChangedObservable.removeCallback(onInstanceStateChanged);\n }\n };\n instance.onStateChangedObservable.add(onInstanceStateChanged);\n\n options.startOffset ??= this.startOffset;\n options.loop ??= this.loop;\n options.volume ??= 1;\n\n this._beforePlay(instance);\n instance.play(options);\n this._afterPlay(instance);\n }\n\n /**\n * Stops the sound.\n */\n public stop(): void {\n this._setState(SoundState.Stopped);\n\n if (!this._instances) {\n return;\n }\n\n for (const instance of Array.from(this._instances)) {\n instance.stop();\n }\n }\n\n protected abstract override _createInstance(): _StreamingSoundInstance;\n\n private _addPreloadedInstance(instance: _StreamingSoundInstance): void {\n if (!this._preloadedInstances.includes(instance)) {\n this._preloadedInstances.push(instance);\n }\n }\n\n private _removePreloadedInstance(instance: _StreamingSoundInstance): void {\n const index = this._preloadedInstances.indexOf(instance);\n if (index !== -1) {\n this._preloadedInstances.splice(index, 1);\n }\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Nullable } from "../../../types";
2
- import type { AbstractNamedAudioNode } from "../abstractAudioNode";
3
2
  import type { _AbstractAudioSubNode } from "./abstractAudioSubNode";
3
+ import type { AudioSubNode } from "./audioSubNode";
4
4
  /**
5
5
  * Adds common sub graph functionality to an audio node.
6
6
  *
@@ -18,36 +18,57 @@ import type { _AbstractAudioSubNode } from "./abstractAudioSubNode";
18
18
  */
19
19
  export declare abstract class _AbstractAudioSubGraph {
20
20
  private _createSubNodePromises;
21
+ private _isDisposed;
21
22
  private _subNodes;
22
23
  /**
23
24
  * Executes the given callback with the named sub node, creating the sub node if needed.
24
25
  *
25
- * Note that `callback` is executed synchronously if the sub node already exists, otherwise the sub node is created
26
- * asynchronously before `callback` is executed.
27
- *
28
26
  * @param name The name of the sub node
29
27
  * @param callback The function to call with the named sub node
28
+ *
29
+ * @internal
30
30
  */
31
- callOnSubNode<T extends _AbstractAudioSubNode>(name: string, callback: (node: T) => void): void;
31
+ callOnSubNode<T extends _AbstractAudioSubNode>(name: AudioSubNode, callback: (node: T) => void): void;
32
+ /**
33
+ * Creates the named subnode and adds it to the sub graph.
34
+ *
35
+ * @param name The name of the sub node.
36
+ * @returns A promise that resolves to the created sub node.
37
+ *
38
+ * @internal
39
+ */
40
+ createAndAddSubNode(name: AudioSubNode): Promise<_AbstractAudioSubNode>;
32
41
  /**
33
42
  * Releases associated resources.
43
+ *
44
+ * @internal
34
45
  */
35
46
  dispose(): void;
36
47
  /**
37
48
  * Gets a previously created sub node.
49
+ *
38
50
  * @param name - The name of the sub node
39
51
  * @returns The named sub node, or `null` if it has not been created, yet
52
+ *
40
53
  * @internal
41
54
  * */
42
- getSubNode<T extends AbstractNamedAudioNode>(name: string): Nullable<T>;
43
- protected abstract _createSubNode(name: string): Nullable<Promise<_AbstractAudioSubNode>>;
55
+ getSubNode<T extends _AbstractAudioSubNode>(name: string): Nullable<T>;
56
+ /**
57
+ * Removes a sub node from the sub graph.
58
+ *
59
+ * @param subNode - The sub node to remove
60
+ * @returns A promise that resolves when the sub node is removed
61
+ *
62
+ * @internal
63
+ */
64
+ removeSubNode(subNode: _AbstractAudioSubNode): Promise<void>;
65
+ protected abstract _createSubNode(name: string): Promise<_AbstractAudioSubNode>;
44
66
  /**
45
67
  * Called when sub-nodes are added or removed.
46
68
  * - Override this to connect and reconnect sub-nodes as needed.
47
69
  */
48
- protected _onSubNodesChanged(): void;
70
+ protected abstract _onSubNodesChanged(): void;
49
71
  protected _createSubNodePromisesResolved(): Promise<_AbstractAudioSubNode[]>;
50
72
  private _addSubNode;
51
- protected _createAndAddSubNode(name: string): Promise<_AbstractAudioSubNode>;
52
73
  private _onSubNodeDisposed;
53
74
  }