@onerjs/core 8.30.5 → 8.30.7
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.
- package/Actions/action.d.ts +5 -0
- package/Actions/action.js.map +1 -1
- package/Actions/actionManager.js +6 -2
- package/Actions/actionManager.js.map +1 -1
- package/Animations/runtimeAnimation.d.ts +0 -2
- package/Animations/runtimeAnimation.js +3 -5
- package/Animations/runtimeAnimation.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.js +1 -0
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +2 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +18 -8
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +8 -3
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/Collisions/gpuPicker.js +0 -1
- package/Collisions/gpuPicker.js.map +1 -1
- package/Debug/debugLayer.d.ts +1 -1
- package/Debug/debugLayer.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +3 -1
- package/Decorators/nodeDecorator.js +2 -0
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +4 -0
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +12 -13
- package/Engines/nativeEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +44 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +152 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +4 -4
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +20 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +83 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +7 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +8 -2
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +4 -4
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +3 -4
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -4
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -3
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +2 -3
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +1 -2
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +3 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +11 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +11 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +10 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +8 -1
- package/FrameGraph/frameGraphContext.js +9 -0
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +5 -2
- package/FrameGraph/frameGraphRenderContext.js +32 -7
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +8 -0
- package/FrameGraph/frameGraphTask.js +12 -0
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.js +2 -1
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +4 -1
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.js +11 -1
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
- package/Materials/floatingOriginMatrixOverrides.js +14 -2
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/shaderMaterial.js +1 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +31 -5
- package/Maths/math.vector.functions.js +41 -4
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/Node/Blocks/randomBlock.js +11 -11
- package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +18 -1
- package/Misc/copyTextureToTexture.js +31 -2
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +18 -2
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleRandomBlock.js +10 -10
- package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +33 -1
- package/Particles/Node/Blocks/systemBlock.js +83 -3
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
- package/Particles/Node/nodeParticleBuildState.js +7 -22
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +224 -58
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.js +1 -1
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -0
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +27 -4
- package/Physics/v2/Plugins/havokPlugin.js +72 -8
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +12 -2
- package/Physics/v2/physicsEngine.js +15 -1
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +3 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Shaders/copyTextureToTexture.fragment.js +2 -2
- package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
- package/Shaders/picking.fragment.js +1 -1
- package/Shaders/picking.fragment.js.map +1 -1
- package/Shaders/picking.vertex.js +1 -1
- package/Shaders/picking.vertex.js.map +1 -1
- package/ShadersWGSL/copyTextureToTexture.fragment.js +3 -3
- package/ShadersWGSL/copyTextureToTexture.fragment.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.js +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/picking.fragment.js +1 -1
- package/ShadersWGSL/picking.fragment.js.map +1 -1
- package/ShadersWGSL/picking.vertex.js +1 -1
- package/ShadersWGSL/picking.vertex.js.map +1 -1
- package/Sprites/spriteRenderer.js +10 -8
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRLightEstimation.d.ts +8 -0
- package/XR/features/WebXRLightEstimation.js +6 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/webXRSessionManager.js +4 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/assetContainer.d.ts +1 -1
- package/assetContainer.js +1 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +5 -2
- package/scene.js +9 -14
- package/scene.js.map +1 -1
|
@@ -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;AAKnD,OAAO,EAAE,mBAAmB,EAA4B,MAAM,uBAAuB,CAAC;AA4CtF;;GAEG;AACH,MAAM,OAAgB,aAAc,SAAQ,mBAAmB;IAa3D,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,+CAAuC,CAAC,CAAC,4BAA4B;QAbnF,oBAAe,GAAqC,IAAI,CAAC;QACzD,sBAAiB,GAAG,IAAI,GAAG,EAA0B,CAAC;QACtD,WAAM,8BAAkC;QAEtC,eAAU,GAAwC,IAAI,CAAC,iBAAiB,CAAC;QAGnF;;WAEG;QACa,sBAAiB,GAAG,IAAI,UAAU,EAAiB,C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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;CAcJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport type { Nullable } from \"../../types\";\nimport { SoundState } from \"../soundState\";\nimport { AudioNodeType } from \"./abstractAudioNode\";\nimport type { _AbstractSoundInstance } from \"./abstractSoundInstance\";\nimport { AbstractSoundSource, type ISoundSourceOptions } from \"./abstractSoundSource\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\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, ISoundSourceOptions {}\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 AbstractSoundSource {\n private _newestInstance: Nullable<_AbstractSoundInstance> = 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\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 number of active instances of the sound that are currently playing.\n */\n public get activeInstancesCount(): number {\n return this._instances.size;\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 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 * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n\n this.stop();\n\n this._newestInstance = 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 _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 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 _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"]}
|
|
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;AAKnD,OAAO,EAAE,mBAAmB,EAA4B,MAAM,uBAAuB,CAAC;AA4CtF;;GAEG;AACH,MAAM,OAAgB,aAAc,SAAQ,mBAAmB;IAa3D,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,+CAAuC,CAAC,CAAC,4BAA4B;QAbnF,oBAAe,GAAqC,IAAI,CAAC;QACzD,sBAAiB,GAAG,IAAI,GAAG,EAA0B,CAAC;QACtD,WAAM,8BAAkC;QAEtC,eAAU,GAAwC,IAAI,CAAC,iBAAiB,CAAC;QAGnF;;WAEG;QACa,sBAAiB,GAAG,IAAI,UAAU,EAAiB,CAAC;QAoL5D,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;g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nJ,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;CAgBJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport type { Nullable } from \"../../types\";\nimport { SoundState } from \"../soundState\";\nimport { AudioNodeType } from \"./abstractAudioNode\";\nimport type { _AbstractSoundInstance } from \"./abstractSoundInstance\";\nimport { AbstractSoundSource, type ISoundSourceOptions } from \"./abstractSoundSource\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\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, ISoundSourceOptions {}\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 AbstractSoundSource {\n private _newestInstance: Nullable<_AbstractSoundInstance> = 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\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 number of active instances of the sound that are currently playing.\n */\n public get activeInstancesCount(): number {\n return this._instances.size;\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 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 * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n\n this.stop();\n\n this._newestInstance = 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 _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 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 _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 instance.dispose();\n };\n}\n"]}
|
|
@@ -41,6 +41,7 @@ export declare abstract class AudioEngineV2 {
|
|
|
41
41
|
/** Not owned, but all items should be in `_nodes` container, too, which is owned. */
|
|
42
42
|
private readonly _mainBuses;
|
|
43
43
|
private readonly _sounds;
|
|
44
|
+
private _soundsArray;
|
|
44
45
|
/** Owned top-level sound and bus nodes. */
|
|
45
46
|
private readonly _nodes;
|
|
46
47
|
private _defaultMainBus;
|
|
@@ -185,6 +186,7 @@ export declare abstract class AudioEngineV2 {
|
|
|
185
186
|
protected _removeNode(node: AbstractNamedAudioNode): void;
|
|
186
187
|
protected _addSound(sound: AbstractSound): void;
|
|
187
188
|
protected _removeSound(sound: AbstractSound): void;
|
|
189
|
+
private _disposeSoundsArray;
|
|
188
190
|
}
|
|
189
191
|
/**
|
|
190
192
|
* @internal
|
|
@@ -18,7 +18,8 @@ export class AudioEngineV2 {
|
|
|
18
18
|
constructor(options) {
|
|
19
19
|
/** Not owned, but all items should be in `_nodes` container, too, which is owned. */
|
|
20
20
|
this._mainBuses = new Set();
|
|
21
|
-
this._sounds = new
|
|
21
|
+
this._sounds = new Set();
|
|
22
|
+
this._soundsArray = null;
|
|
22
23
|
/** Owned top-level sound and bus nodes. */
|
|
23
24
|
this._nodes = new Set();
|
|
24
25
|
this._defaultMainBus = null;
|
|
@@ -59,7 +60,10 @@ export class AudioEngineV2 {
|
|
|
59
60
|
* The list of static and streaming sounds created by the audio engine.
|
|
60
61
|
*/
|
|
61
62
|
get sounds() {
|
|
62
|
-
|
|
63
|
+
if (!this._soundsArray) {
|
|
64
|
+
this._soundsArray = Array.from(this._sounds);
|
|
65
|
+
}
|
|
66
|
+
return this._soundsArray;
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
65
69
|
* Releases associated resources.
|
|
@@ -74,7 +78,8 @@ export class AudioEngineV2 {
|
|
|
74
78
|
}
|
|
75
79
|
this._mainBuses.clear();
|
|
76
80
|
this._nodes.clear();
|
|
77
|
-
this._sounds.
|
|
81
|
+
this._sounds.clear();
|
|
82
|
+
this._disposeSoundsArray();
|
|
78
83
|
this._defaultMainBus = null;
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
@@ -102,16 +107,21 @@ export class AudioEngineV2 {
|
|
|
102
107
|
this._nodes.delete(node);
|
|
103
108
|
}
|
|
104
109
|
_addSound(sound) {
|
|
105
|
-
this.
|
|
110
|
+
this._disposeSoundsArray();
|
|
111
|
+
this._sounds.add(sound);
|
|
106
112
|
this._addNode(sound);
|
|
107
113
|
}
|
|
108
114
|
_removeSound(sound) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this._sounds.splice(index, 1);
|
|
112
|
-
}
|
|
115
|
+
this._disposeSoundsArray();
|
|
116
|
+
this._sounds.delete(sound);
|
|
113
117
|
this._removeNode(sound);
|
|
114
118
|
}
|
|
119
|
+
_disposeSoundsArray() {
|
|
120
|
+
if (this._soundsArray) {
|
|
121
|
+
this._soundsArray.length = 0;
|
|
122
|
+
this._soundsArray = null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
115
125
|
}
|
|
116
126
|
/**
|
|
117
127
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioEngineV2.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/audioEngineV2.ts"],"names":[],"mappings":"AAYA,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;AAsBD;;;;GAIG;AACH,MAAM,OAAgB,aAAa;IAY/B,YAAsB,OAAuC;QAX7D,qFAAqF;QACpE,eAAU,GAAG,IAAI,GAAG,EAAgB,CAAC;QACrC,YAAO,G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ClE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,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,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,MAAM,UAAU,sBAAsB,CAClC,IAAY,EACZ,MAAiB,EACjB,UAAwC,EAAE,EAC1C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,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 { IAudioParameterRampOptions } from \"../audioParameter\";\nimport type { AbstractAudioNode, AbstractNamedAudioNode } from \"./abstractAudioNode\";\nimport type { AbstractSound } from \"./abstractSound\";\nimport type { AbstractSoundSource, ISoundSourceOptions } from \"./abstractSoundSource\";\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 smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n */\n parameterRampDuration: number;\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 private readonly _sounds = new Array<AbstractSound>();\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 private _parameterRampDuration: number = 0.01;\n\n protected constructor(options: Partial<IAudioEngineV2Options>) {\n Instances.push(this);\n\n if (typeof options.parameterRampDuration === \"number\") {\n this.parameterRampDuration = options.parameterRampDuration;\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 /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n *\n * Due to limitations in some browsers, it is not recommended to set this value to longer than `0.01` seconds.\n *\n * Setting this value to longer than `0.01` seconds may result in errors being throw when setting audio parameters.\n */\n public get parameterRampDuration(): number {\n return this._parameterRampDuration;\n }\n\n public set parameterRampDuration(value: number) {\n this._parameterRampDuration = Math.max(0, value);\n }\n\n /**\n * The list of static and streaming sounds created by the audio engine.\n */\n public get sounds(): ReadonlyArray<AbstractSound> {\n return this._sounds;\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 * @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 /**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createMicrophoneSoundSourceAsync(name: string, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\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 * @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 * @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 sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createSoundSourceAsync(name: string, source: AudioNode, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\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 this._sounds.length = 0;\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 pauseAsync(): 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 resumeAsync(): Promise<void>;\n\n /**\n * Sets the audio output volume with optional ramping.\n * If the duration is 0 then the volume is set immediately, otherwise it is ramped to the new value over the given duration using the given shape.\n * If a ramp is already in progress then the volume is not set and an error is thrown.\n * @param value The value to set the volume to.\n * @param options The options to use for ramping the volume change.\n */\n public abstract setVolume(value: number, options?: Partial<IAudioParameterRampOptions>): 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 // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\n public unlockAsync(): Promise<void> {\n return this.resumeAsync();\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 protected _addSound(sound: AbstractSound): void {\n this._sounds.push(sound);\n this._addNode(sound);\n }\n\n protected _removeSound(sound: AbstractSound): void {\n const index = this._sounds.indexOf(sound);\n if (index !== -1) {\n this._sounds.splice(index, 1);\n }\n this._removeNode(sound);\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 */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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 */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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 microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMicrophoneSoundSourceAsync(name: string, options: Partial<ISoundSourceOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createMicrophoneSoundSourceAsync(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 */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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 await engine.createSoundBufferAsync(source, options);\n}\n\n/**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundSourceAsync(\n name: string,\n source: AudioNode,\n options: Partial<ISoundSourceOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundSourceAsync(name, 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 */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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":"AAYA,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;AAsBD;;;;GAIG;AACH,MAAM,OAAgB,aAAa;IAa/B,YAAsB,OAAuC;QAZ7D,qFAAqF;QACpE,eAAU,GAAG,IAAI,GAAG,EAAgB,CAAC;QACrC,YAAO,GAAG,IAAI,GAAG,EAAiB,CAAC;QAC5C,iBAAY,GAAmC,IAAI,CAAC;QAE5D,2CAA2C;QAC1B,WAAM,GAAG,IAAI,GAAG,EAA0B,CAAC;QAEpD,oBAAe,GAA2B,IAAI,CAAC;QAE/C,2BAAsB,GAAW,IAAI,CAAC;QAG1C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErB,IAAI,OAAO,OAAO,CAAC,qBAAqB,KAAK,QAAQ,EAAE,CAAC;YACpD,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;QAC/D,CAAC;IACL,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,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO,IAAI,CAAC,e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C,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,MAAM,UAAU,sBAAsB,CAClC,IAAY,EACZ,MAAiB,EACjB,UAAwC,EAAE,EAC1C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,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 { IAudioParameterRampOptions } from \"../audioParameter\";\nimport type { AbstractAudioNode, AbstractNamedAudioNode } from \"./abstractAudioNode\";\nimport type { AbstractSound } from \"./abstractSound\";\nimport type { AbstractSoundSource, ISoundSourceOptions } from \"./abstractSoundSource\";\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 smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n */\n parameterRampDuration: number;\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 private readonly _sounds = new Set<AbstractSound>();\n private _soundsArray: Nullable<Array<AbstractSound>> = null;\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 private _parameterRampDuration: number = 0.01;\n\n protected constructor(options: Partial<IAudioEngineV2Options>) {\n Instances.push(this);\n\n if (typeof options.parameterRampDuration === \"number\") {\n this.parameterRampDuration = options.parameterRampDuration;\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 /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n *\n * Due to limitations in some browsers, it is not recommended to set this value to longer than `0.01` seconds.\n *\n * Setting this value to longer than `0.01` seconds may result in errors being throw when setting audio parameters.\n */\n public get parameterRampDuration(): number {\n return this._parameterRampDuration;\n }\n\n public set parameterRampDuration(value: number) {\n this._parameterRampDuration = Math.max(0, value);\n }\n\n /**\n * The list of static and streaming sounds created by the audio engine.\n */\n public get sounds(): ReadonlyArray<AbstractSound> {\n if (!this._soundsArray) {\n this._soundsArray = Array.from(this._sounds);\n }\n return this._soundsArray;\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 * @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 /**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createMicrophoneSoundSourceAsync(name: string, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\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 * @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 * @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 sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createSoundSourceAsync(name: string, source: AudioNode, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\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 this._sounds.clear();\n\n this._disposeSoundsArray();\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 pauseAsync(): 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 resumeAsync(): Promise<void>;\n\n /**\n * Sets the audio output volume with optional ramping.\n * If the duration is 0 then the volume is set immediately, otherwise it is ramped to the new value over the given duration using the given shape.\n * If a ramp is already in progress then the volume is not set and an error is thrown.\n * @param value The value to set the volume to.\n * @param options The options to use for ramping the volume change.\n */\n public abstract setVolume(value: number, options?: Partial<IAudioParameterRampOptions>): 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 // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\n public unlockAsync(): Promise<void> {\n return this.resumeAsync();\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 protected _addSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.add(sound);\n this._addNode(sound);\n }\n\n protected _removeSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.delete(sound);\n this._removeNode(sound);\n }\n\n private _disposeSoundsArray(): void {\n if (this._soundsArray) {\n this._soundsArray.length = 0;\n this._soundsArray = null;\n }\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 */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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 */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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 microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMicrophoneSoundSourceAsync(name: string, options: Partial<ISoundSourceOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createMicrophoneSoundSourceAsync(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 */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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 await engine.createSoundBufferAsync(source, options);\n}\n\n/**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundSourceAsync(\n name: string,\n source: AudioNode,\n options: Partial<ISoundSourceOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundSourceAsync(name, 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 */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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"]}
|
|
@@ -275,8 +275,11 @@ class _WebAudioStaticSoundInstance extends _StaticSoundInstance {
|
|
|
275
275
|
set currentTime(value) {
|
|
276
276
|
const restart = this._state === 2 /* SoundState.Starting */ || this._state === 3 /* SoundState.Started */;
|
|
277
277
|
if (restart) {
|
|
278
|
-
|
|
278
|
+
// Stop source node without sending `onEndedObservable` so instance's `dispose` function is not called.
|
|
279
|
+
const sourceNode = this._sourceNode;
|
|
279
280
|
this._deinitSourceNode();
|
|
281
|
+
sourceNode?.stop();
|
|
282
|
+
this._state = 1 /* SoundState.Stopped */;
|
|
280
283
|
}
|
|
281
284
|
this._options.startOffset = value;
|
|
282
285
|
if (restart) {
|
|
@@ -363,10 +366,12 @@ class _WebAudioStaticSoundInstance extends _StaticSoundInstance {
|
|
|
363
366
|
if (this._state === 1 /* SoundState.Stopped */) {
|
|
364
367
|
return;
|
|
365
368
|
}
|
|
366
|
-
this._setState(1 /* SoundState.Stopped */);
|
|
367
369
|
const engineStopTime = this.engine.currentTime + (options.waitTime ?? 0);
|
|
368
370
|
this._sourceNode?.stop(engineStopTime);
|
|
369
|
-
|
|
371
|
+
if (options.waitTime === undefined || options.waitTime <= 0) {
|
|
372
|
+
this._setState(1 /* SoundState.Stopped */);
|
|
373
|
+
this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);
|
|
374
|
+
}
|
|
370
375
|
}
|
|
371
376
|
_connect(node) {
|
|
372
377
|
const connected = super._connect(node);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webAudioStaticSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/webAudio/webAudioStaticSound.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAC;AAE9F,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAA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M,CAAC,YAAY,CAAC;IACvD,CAAC;CAaJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { AbstractAudioNode } from \"../abstractAudio/abstractAudioNode\";\nimport type { IStaticSoundCloneOptions, IStaticSoundOptions, IStaticSoundPlayOptions, IStaticSoundStopOptions, IStaticSoundStoredOptions } from \"../abstractAudio/staticSound\";\nimport { StaticSound } from \"../abstractAudio/staticSound\";\nimport type { IStaticSoundBufferCloneOptions, IStaticSoundBufferOptions } from \"../abstractAudio/staticSoundBuffer\";\nimport { StaticSoundBuffer } from \"../abstractAudio/staticSoundBuffer\";\nimport type { IStaticSoundInstanceOptions } from \"../abstractAudio/staticSoundInstance\";\nimport { _StaticSoundInstance } from \"../abstractAudio/staticSoundInstance\";\nimport { _HasSpatialAudioOptions } from \"../abstractAudio/subProperties/abstractSpatialAudio\";\nimport type { _SpatialAudio } from \"../abstractAudio/subProperties/spatialAudio\";\nimport { _StereoAudio } from \"../abstractAudio/subProperties/stereoAudio\";\nimport { _CleanUrl, _FileExtensionRegex } from \"../audioUtils\";\nimport { SoundState } from \"../soundState\";\nimport { _WebAudioParameterComponent } from \"./components/webAudioParameterComponent\";\nimport { _WebAudioBusAndSoundSubGraph } from \"./subNodes/webAudioBusAndSoundSubGraph\";\nimport { _SpatialWebAudio } from \"./subProperties/spatialWebAudio\";\nimport type { _WebAudioEngine } from \"./webAudioEngine\";\nimport type { IWebAudioInNode, IWebAudioOutNode, IWebAudioSuperNode } from \"./webAudioNode\";\n\ntype StaticSoundSourceType = ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[];\n\n/** @internal */\nexport class _WebAudioStaticSound extends StaticSound implements IWebAudioSuperNode {\n private _buffer: _WebAudioStaticSoundBuffer;\n private _spatial: Nullable<_SpatialWebAudio> = null;\n private readonly _spatialAutoUpdate: boolean = true;\n private readonly _spatialMinUpdateTime: number = 0;\n private _stereo: Nullable<_StereoAudio> = null;\n\n protected override readonly _options: IStaticSoundStoredOptions;\n protected _subGraph: _WebAudioBusAndSoundSubGraph;\n\n /** @internal */\n public _audioContext: AudioContext | OfflineAudioContext;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public constructor(name: string, engine: _WebAudioEngine, options: Partial<IStaticSoundOptions>) {\n super(name, engine);\n\n if (typeof options.spatialAutoUpdate === \"boolean\") {\n this._spatialAutoUpdate = options.spatialAutoUpdate;\n }\n\n if (typeof options.spatialMinUpdateTime === \"number\") {\n this._spatialMinUpdateTime = options.spatialMinUpdateTime;\n }\n\n this._options = {\n autoplay: options.autoplay ?? false,\n duration: options.duration ?? 0,\n loop: options.loop ?? false,\n loopEnd: options.loopEnd ?? 0,\n loopStart: options.loopStart ?? 0,\n maxInstances: options.maxInstances ?? Infinity,\n pitch: options.pitch ?? 0,\n playbackRate: options.playbackRate ?? 1,\n startOffset: options.startOffset ?? 0,\n };\n\n this._subGraph = new _WebAudioStaticSound._SubGraph(this);\n }\n\n /** @internal */\n public async _initAsync(source: StaticSoundSourceType, options: Partial<IStaticSoundOptions>): Promise<void> {\n this._audioContext = this.engine._audioContext;\n\n if (source instanceof _WebAudioStaticSoundBuffer) {\n this._buffer = source;\n } else if (typeof source === \"string\" || Array.isArray(source) || source instanceof ArrayBuffer || source instanceof AudioBuffer) {\n this._buffer = (await this.engine.createSoundBufferAsync(source, options)) as _WebAudioStaticSoundBuffer;\n }\n\n if (options.outBus) {\n this.outBus = options.outBus;\n } else if (options.outBusAutoDefault !== false) {\n await this.engine.isReadyPromise;\n this.outBus = this.engine.defaultMainBus;\n }\n\n await this._subGraph.initAsync(options);\n\n if (_HasSpatialAudioOptions(options)) {\n this._initSpatialProperty();\n }\n\n if (options.autoplay) {\n this.play();\n }\n\n this.engine._addSound(this);\n }\n\n /** @internal */\n public get buffer(): _WebAudioStaticSoundBuffer {\n return this._buffer;\n }\n\n /** @internal */\n public get _inNode() {\n return this._subGraph._inNode;\n }\n\n /** @internal */\n public get _outNode() {\n return this._subGraph._outNode;\n }\n\n /** @internal */\n public override get spatial(): _SpatialAudio {\n if (this._spatial) {\n return this._spatial;\n }\n return this._initSpatialProperty();\n }\n\n /** @internal */\n public override get stereo(): _StereoAudio {\n return this._stereo ?? (this._stereo = new _StereoAudio(this._subGraph));\n }\n\n /** @internal */\n public override async cloneAsync(options: Nullable<Partial<IStaticSoundCloneOptions>> = null): Promise<StaticSound> {\n const clone = await this.engine.createSoundAsync(this.name, options?.cloneBuffer ? this.buffer.clone() : this.buffer, this._options);\n\n clone.outBus = options?.outBus ? options.outBus : this.outBus;\n\n return clone;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._spatial?.dispose();\n this._spatial = null;\n\n this._stereo = null;\n\n this._subGraph.dispose();\n\n this.engine._removeSound(this);\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioStaticSound\";\n }\n\n protected _createInstance(): _WebAudioStaticSoundInstance {\n return new _WebAudioStaticSoundInstance(this, this._options);\n }\n\n protected override _connect(node: IWebAudioInNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the subgraph.\n if (node._inNode) {\n this._outNode?.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: IWebAudioInNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node._inNode) {\n this._outNode?.disconnect(node._inNode);\n }\n\n return true;\n }\n\n private _initSpatialProperty(): _SpatialAudio {\n if (!this._spatial) {\n this._spatial = new _SpatialWebAudio(this._subGraph, this._spatialAutoUpdate, this._spatialMinUpdateTime);\n }\n\n return this._spatial;\n }\n\n private static _SubGraph = class extends _WebAudioBusAndSoundSubGraph {\n protected override _owner: _WebAudioStaticSound;\n\n protected get _downstreamNodes(): Nullable<Set<AbstractAudioNode>> {\n return this._owner._downstreamNodes ?? null;\n }\n\n protected get _upstreamNodes(): Nullable<Set<AbstractAudioNode>> {\n return this._owner._upstreamNodes ?? null;\n }\n };\n}\n\n/** @internal */\nexport class _WebAudioStaticSoundBuffer extends StaticSoundBuffer {\n /** @internal */\n public _audioBuffer: AudioBuffer;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n }\n\n public async _initAsync(source: StaticSoundSourceType, options: Partial<IStaticSoundBufferOptions>): Promise<void> {\n if (source instanceof AudioBuffer) {\n this._audioBuffer = source;\n } else if (typeof source === \"string\") {\n await this._initFromUrlAsync(source);\n } else if (Array.isArray(source)) {\n await this._initFromUrlsAsync(source, options.skipCodecCheck ?? false);\n } else if (source instanceof ArrayBuffer) {\n await this._initFromArrayBufferAsync(source);\n }\n }\n\n /** @internal */\n public get channelCount(): number {\n return this._audioBuffer.numberOfChannels;\n }\n\n /** @internal */\n public get duration(): number {\n return this._audioBuffer.duration;\n }\n\n /** @internal */\n public get length(): number {\n return this._audioBuffer.length;\n }\n\n /** @internal */\n public get sampleRate(): number {\n return this._audioBuffer.sampleRate;\n }\n\n /** @internal */\n public override clone(options: Nullable<Partial<IStaticSoundBufferCloneOptions>> = null): StaticSoundBuffer {\n const audioBuffer = new AudioBuffer({\n length: this._audioBuffer.length,\n numberOfChannels: this._audioBuffer.numberOfChannels,\n sampleRate: this._audioBuffer.sampleRate,\n });\n\n for (let i = 0; i < this._audioBuffer.numberOfChannels; i++) {\n audioBuffer.copyToChannel(this._audioBuffer.getChannelData(i), i);\n }\n\n const buffer = new _WebAudioStaticSoundBuffer(this.engine);\n buffer._audioBuffer = audioBuffer;\n buffer.name = options?.name ? options.name : this.name;\n\n return buffer;\n }\n\n private async _initFromArrayBufferAsync(arrayBuffer: ArrayBuffer): Promise<void> {\n this._audioBuffer = await this.engine._audioContext.decodeAudioData(arrayBuffer);\n }\n\n private async _initFromUrlAsync(url: string): Promise<void> {\n url = _CleanUrl(url);\n await this._initFromArrayBufferAsync(await (await fetch(url)).arrayBuffer());\n }\n\n private async _initFromUrlsAsync(urls: string[], skipCodecCheck: boolean): Promise<void> {\n for (const url of urls) {\n if (skipCodecCheck) {\n // eslint-disable-next-line no-await-in-loop\n await this._initFromUrlAsync(url);\n } else {\n const matches = url.match(_FileExtensionRegex);\n const format = matches?.at(1);\n if (format && this.engine.isFormatValid(format)) {\n try {\n // eslint-disable-next-line no-await-in-loop\n await this._initFromUrlAsync(url);\n } catch {\n if (format && 0 < format.length) {\n this.engine.flagInvalidFormat(format);\n }\n }\n }\n }\n\n if (this._audioBuffer) {\n break;\n }\n }\n }\n}\n\n/** @internal */\nclass _WebAudioStaticSoundInstance extends _StaticSoundInstance implements IWebAudioOutNode {\n private _enginePlayTime: number = 0;\n private _enginePauseTime: number = 0;\n private _isConnected: boolean = false;\n private _pitch: Nullable<_WebAudioParameterComponent> = null;\n private _playbackRate: Nullable<_WebAudioParameterComponent> = null;\n private _sourceNode: Nullable<AudioBufferSourceNode> = null;\n private _volumeNode: GainNode;\n\n protected override readonly _options: IStaticSoundInstanceOptions;\n protected override _sound: _WebAudioStaticSound;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n public constructor(sound: _WebAudioStaticSound, options: IStaticSoundInstanceOptions) {\n super(sound);\n\n this._options = options;\n\n this._volumeNode = new GainNode(sound._audioContext);\n this._initSourceNode();\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._pitch?.dispose();\n this._playbackRate?.dispose();\n\n this._sourceNode = null;\n\n this.stop();\n\n this._deinitSourceNode();\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n }\n\n /** @internal */\n public get currentTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n const timeSinceLastStart = this._state === SoundState.Paused ? 0 : this.engine.currentTime - this._enginePlayTime;\n return this._enginePauseTime + timeSinceLastStart + this._options.startOffset;\n }\n\n public set currentTime(value: number) {\n const restart = this._state === SoundState.Starting || this._state === SoundState.Started;\n\n if (restart) {\n this.stop();\n this._deinitSourceNode();\n }\n\n this._options.startOffset = value;\n\n if (restart) {\n this.play();\n }\n }\n\n public get _outNode(): Nullable<AudioNode> {\n return this._volumeNode;\n }\n\n /** @internal */\n public set pitch(value: number) {\n this._pitch?.setTargetValue(value);\n }\n\n /** @internal */\n public set playbackRate(value: number) {\n this._playbackRate?.setTargetValue(value);\n }\n\n /** @internal */\n public get startTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n return this._enginePlayTime;\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioStaticSoundInstance\";\n }\n\n /** @internal */\n public play(options: Partial<IStaticSoundPlayOptions> = {}): void {\n if (this._state === SoundState.Started) {\n return;\n }\n\n if (options.duration !== undefined) {\n this._options.duration = options.duration;\n }\n if (options.loop !== undefined) {\n this._options.loop = options.loop;\n }\n if (options.loopStart !== undefined) {\n this._options.loopStart = options.loopStart;\n }\n if (options.loopEnd !== undefined) {\n this._options.loopEnd = options.loopEnd;\n }\n if (options.startOffset !== undefined) {\n this._options.startOffset = options.startOffset;\n }\n\n let startOffset = this._options.startOffset;\n\n if (this._state === SoundState.Paused) {\n startOffset += this.currentTime;\n startOffset %= this._sound.buffer.duration;\n }\n\n this._enginePlayTime = this.engine.currentTime + (options.waitTime ?? 0);\n\n this._volumeNode.gain.value = options.volume ?? 1;\n\n this._initSourceNode();\n\n if (this.engine.state === \"running\") {\n this._setState(SoundState.Started);\n this._sourceNode?.start(this._enginePlayTime, startOffset, this._options.duration > 0 ? this._options.duration : undefined);\n } else if (this._options.loop) {\n this._setState(SoundState.Starting);\n this.engine.stateChangedObservable.add(this._onEngineStateChanged);\n }\n }\n\n /** @internal */\n public pause(): void {\n if (this._state === SoundState.Paused) {\n return;\n }\n\n this._setState(SoundState.Paused);\n this._enginePauseTime += this.engine.currentTime - this._enginePlayTime;\n\n this._sourceNode?.stop();\n this._deinitSourceNode();\n }\n\n /** @internal */\n public resume(): void {\n if (this._state === SoundState.Paused) {\n this.play();\n }\n }\n\n /** @internal */\n public stop(options: Partial<IStaticSoundStopOptions> = {}): void {\n if (this._state === SoundState.Stopped) {\n return;\n }\n\n this._setState(SoundState.Stopped);\n\n const engineStopTime = this.engine.currentTime + (options.waitTime ?? 0);\n this._sourceNode?.stop(engineStopTime);\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n }\n\n protected override _connect(node: AbstractAudioNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the sound's subgraph.\n if (node instanceof _WebAudioStaticSound && node._inNode) {\n this._outNode?.connect(node._inNode);\n this._isConnected = true;\n }\n\n return true;\n }\n\n protected override _disconnect(node: AbstractAudioNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node instanceof _WebAudioStaticSound && node._inNode) {\n this._outNode?.disconnect(node._inNode);\n this._isConnected = false;\n }\n\n return true;\n }\n\n protected _onEnded = () => {\n this._enginePlayTime = 0;\n\n this.onEndedObservable.notifyObservers(this);\n this._deinitSourceNode();\n };\n\n private _deinitSourceNode(): void {\n if (!this._sourceNode) {\n return;\n }\n\n if (this._isConnected && !this._disconnect(this._sound)) {\n throw new Error(\"Disconnect failed\");\n }\n\n this._sourceNode.disconnect(this._volumeNode);\n this._sourceNode.removeEventListener(\"ended\", this._onEnded);\n\n this._sourceNode = null;\n }\n\n private _initSourceNode(): void {\n if (!this._sourceNode) {\n this._sourceNode = new AudioBufferSourceNode(this._sound._audioContext, { buffer: this._sound.buffer._audioBuffer });\n\n this._sourceNode.addEventListener(\"ended\", this._onEnded, { once: true });\n this._sourceNode.connect(this._volumeNode);\n\n if (!this._connect(this._sound)) {\n throw new Error(\"Connect failed\");\n }\n\n this._pitch = new _WebAudioParameterComponent(this.engine, this._sourceNode.detune);\n this._playbackRate = new _WebAudioParameterComponent(this.engine, this._sourceNode.playbackRate);\n }\n\n const node = this._sourceNode;\n node.detune.value = this._sound.pitch;\n node.loop = this._options.loop;\n node.loopEnd = this._options.loopEnd;\n node.loopStart = this._options.loopStart;\n node.playbackRate.value = this._sound.playbackRate;\n }\n\n private _onEngineStateChanged = () => {\n if (this.engine.state !== \"running\") {\n return;\n }\n\n if (this._options.loop && this.state === SoundState.Starting) {\n this.play();\n }\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"webAudioStaticSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/webAudio/webAudioStaticSound.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAC;AAE9F,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,gBAAgB;AAChB,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IAgBjD,gBAAgB;IAChB,YAAmB,IAAY,EAAE,MAAuB,EAAE,OAAqC;QAC3F,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAhBhB,aAAQ,GAA+B,IAAI,CAAC;QACnC,uBAAkB,GAAY,IAAI,CAAC;QACnC,0BAAqB,GAAW,CAAC,CAAC;QAC3C,YAAO,GAA2B,IAAI,CAAC;QAe3C,IAAI,OAAO,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACjD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACxD,CAAC;QAED,IAAI,OA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AAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1E,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAE3C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACtC,CAAC;YAED,IAAI,CAAC,MAAM,GAAG,IAAI,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACpF,IAAI,CAAC,aAAa,GAAG,IAAI,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACrG,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QACzC,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;IACvD,CAAC;CAaJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { AbstractAudioNode } from \"../abstractAudio/abstractAudioNode\";\nimport type { IStaticSoundCloneOptions, IStaticSoundOptions, IStaticSoundPlayOptions, IStaticSoundStopOptions, IStaticSoundStoredOptions } from \"../abstractAudio/staticSound\";\nimport { StaticSound } from \"../abstractAudio/staticSound\";\nimport type { IStaticSoundBufferCloneOptions, IStaticSoundBufferOptions } from \"../abstractAudio/staticSoundBuffer\";\nimport { StaticSoundBuffer } from \"../abstractAudio/staticSoundBuffer\";\nimport type { IStaticSoundInstanceOptions } from \"../abstractAudio/staticSoundInstance\";\nimport { _StaticSoundInstance } from \"../abstractAudio/staticSoundInstance\";\nimport { _HasSpatialAudioOptions } from \"../abstractAudio/subProperties/abstractSpatialAudio\";\nimport type { _SpatialAudio } from \"../abstractAudio/subProperties/spatialAudio\";\nimport { _StereoAudio } from \"../abstractAudio/subProperties/stereoAudio\";\nimport { _CleanUrl, _FileExtensionRegex } from \"../audioUtils\";\nimport { SoundState } from \"../soundState\";\nimport { _WebAudioParameterComponent } from \"./components/webAudioParameterComponent\";\nimport { _WebAudioBusAndSoundSubGraph } from \"./subNodes/webAudioBusAndSoundSubGraph\";\nimport { _SpatialWebAudio } from \"./subProperties/spatialWebAudio\";\nimport type { _WebAudioEngine } from \"./webAudioEngine\";\nimport type { IWebAudioInNode, IWebAudioOutNode, IWebAudioSuperNode } from \"./webAudioNode\";\n\ntype StaticSoundSourceType = ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[];\n\n/** @internal */\nexport class _WebAudioStaticSound extends StaticSound implements IWebAudioSuperNode {\n private _buffer: _WebAudioStaticSoundBuffer;\n private _spatial: Nullable<_SpatialWebAudio> = null;\n private readonly _spatialAutoUpdate: boolean = true;\n private readonly _spatialMinUpdateTime: number = 0;\n private _stereo: Nullable<_StereoAudio> = null;\n\n protected override readonly _options: IStaticSoundStoredOptions;\n protected _subGraph: _WebAudioBusAndSoundSubGraph;\n\n /** @internal */\n public _audioContext: AudioContext | OfflineAudioContext;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public constructor(name: string, engine: _WebAudioEngine, options: Partial<IStaticSoundOptions>) {\n super(name, engine);\n\n if (typeof options.spatialAutoUpdate === \"boolean\") {\n this._spatialAutoUpdate = options.spatialAutoUpdate;\n }\n\n if (typeof options.spatialMinUpdateTime === \"number\") {\n this._spatialMinUpdateTime = options.spatialMinUpdateTime;\n }\n\n this._options = {\n autoplay: options.autoplay ?? false,\n duration: options.duration ?? 0,\n loop: options.loop ?? false,\n loopEnd: options.loopEnd ?? 0,\n loopStart: options.loopStart ?? 0,\n maxInstances: options.maxInstances ?? Infinity,\n pitch: options.pitch ?? 0,\n playbackRate: options.playbackRate ?? 1,\n startOffset: options.startOffset ?? 0,\n };\n\n this._subGraph = new _WebAudioStaticSound._SubGraph(this);\n }\n\n /** @internal */\n public async _initAsync(source: StaticSoundSourceType, options: Partial<IStaticSoundOptions>): Promise<void> {\n this._audioContext = this.engine._audioContext;\n\n if (source instanceof _WebAudioStaticSoundBuffer) {\n this._buffer = source;\n } else if (typeof source === \"string\" || Array.isArray(source) || source instanceof ArrayBuffer || source instanceof AudioBuffer) {\n this._buffer = (await this.engine.createSoundBufferAsync(source, options)) as _WebAudioStaticSoundBuffer;\n }\n\n if (options.outBus) {\n this.outBus = options.outBus;\n } else if (options.outBusAutoDefault !== false) {\n await this.engine.isReadyPromise;\n this.outBus = this.engine.defaultMainBus;\n }\n\n await this._subGraph.initAsync(options);\n\n if (_HasSpatialAudioOptions(options)) {\n this._initSpatialProperty();\n }\n\n if (options.autoplay) {\n this.play();\n }\n\n this.engine._addSound(this);\n }\n\n /** @internal */\n public get buffer(): _WebAudioStaticSoundBuffer {\n return this._buffer;\n }\n\n /** @internal */\n public get _inNode() {\n return this._subGraph._inNode;\n }\n\n /** @internal */\n public get _outNode() {\n return this._subGraph._outNode;\n }\n\n /** @internal */\n public override get spatial(): _SpatialAudio {\n if (this._spatial) {\n return this._spatial;\n }\n return this._initSpatialProperty();\n }\n\n /** @internal */\n public override get stereo(): _StereoAudio {\n return this._stereo ?? (this._stereo = new _StereoAudio(this._subGraph));\n }\n\n /** @internal */\n public override async cloneAsync(options: Nullable<Partial<IStaticSoundCloneOptions>> = null): Promise<StaticSound> {\n const clone = await this.engine.createSoundAsync(this.name, options?.cloneBuffer ? this.buffer.clone() : this.buffer, this._options);\n\n clone.outBus = options?.outBus ? options.outBus : this.outBus;\n\n return clone;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._spatial?.dispose();\n this._spatial = null;\n\n this._stereo = null;\n\n this._subGraph.dispose();\n\n this.engine._removeSound(this);\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioStaticSound\";\n }\n\n protected _createInstance(): _WebAudioStaticSoundInstance {\n return new _WebAudioStaticSoundInstance(this, this._options);\n }\n\n protected override _connect(node: IWebAudioInNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the subgraph.\n if (node._inNode) {\n this._outNode?.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: IWebAudioInNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node._inNode) {\n this._outNode?.disconnect(node._inNode);\n }\n\n return true;\n }\n\n private _initSpatialProperty(): _SpatialAudio {\n if (!this._spatial) {\n this._spatial = new _SpatialWebAudio(this._subGraph, this._spatialAutoUpdate, this._spatialMinUpdateTime);\n }\n\n return this._spatial;\n }\n\n private static _SubGraph = class extends _WebAudioBusAndSoundSubGraph {\n protected override _owner: _WebAudioStaticSound;\n\n protected get _downstreamNodes(): Nullable<Set<AbstractAudioNode>> {\n return this._owner._downstreamNodes ?? null;\n }\n\n protected get _upstreamNodes(): Nullable<Set<AbstractAudioNode>> {\n return this._owner._upstreamNodes ?? null;\n }\n };\n}\n\n/** @internal */\nexport class _WebAudioStaticSoundBuffer extends StaticSoundBuffer {\n /** @internal */\n public _audioBuffer: AudioBuffer;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n }\n\n public async _initAsync(source: StaticSoundSourceType, options: Partial<IStaticSoundBufferOptions>): Promise<void> {\n if (source instanceof AudioBuffer) {\n this._audioBuffer = source;\n } else if (typeof source === \"string\") {\n await this._initFromUrlAsync(source);\n } else if (Array.isArray(source)) {\n await this._initFromUrlsAsync(source, options.skipCodecCheck ?? false);\n } else if (source instanceof ArrayBuffer) {\n await this._initFromArrayBufferAsync(source);\n }\n }\n\n /** @internal */\n public get channelCount(): number {\n return this._audioBuffer.numberOfChannels;\n }\n\n /** @internal */\n public get duration(): number {\n return this._audioBuffer.duration;\n }\n\n /** @internal */\n public get length(): number {\n return this._audioBuffer.length;\n }\n\n /** @internal */\n public get sampleRate(): number {\n return this._audioBuffer.sampleRate;\n }\n\n /** @internal */\n public override clone(options: Nullable<Partial<IStaticSoundBufferCloneOptions>> = null): StaticSoundBuffer {\n const audioBuffer = new AudioBuffer({\n length: this._audioBuffer.length,\n numberOfChannels: this._audioBuffer.numberOfChannels,\n sampleRate: this._audioBuffer.sampleRate,\n });\n\n for (let i = 0; i < this._audioBuffer.numberOfChannels; i++) {\n audioBuffer.copyToChannel(this._audioBuffer.getChannelData(i), i);\n }\n\n const buffer = new _WebAudioStaticSoundBuffer(this.engine);\n buffer._audioBuffer = audioBuffer;\n buffer.name = options?.name ? options.name : this.name;\n\n return buffer;\n }\n\n private async _initFromArrayBufferAsync(arrayBuffer: ArrayBuffer): Promise<void> {\n this._audioBuffer = await this.engine._audioContext.decodeAudioData(arrayBuffer);\n }\n\n private async _initFromUrlAsync(url: string): Promise<void> {\n url = _CleanUrl(url);\n await this._initFromArrayBufferAsync(await (await fetch(url)).arrayBuffer());\n }\n\n private async _initFromUrlsAsync(urls: string[], skipCodecCheck: boolean): Promise<void> {\n for (const url of urls) {\n if (skipCodecCheck) {\n // eslint-disable-next-line no-await-in-loop\n await this._initFromUrlAsync(url);\n } else {\n const matches = url.match(_FileExtensionRegex);\n const format = matches?.at(1);\n if (format && this.engine.isFormatValid(format)) {\n try {\n // eslint-disable-next-line no-await-in-loop\n await this._initFromUrlAsync(url);\n } catch {\n if (format && 0 < format.length) {\n this.engine.flagInvalidFormat(format);\n }\n }\n }\n }\n\n if (this._audioBuffer) {\n break;\n }\n }\n }\n}\n\n/** @internal */\nclass _WebAudioStaticSoundInstance extends _StaticSoundInstance implements IWebAudioOutNode {\n private _enginePlayTime: number = 0;\n private _enginePauseTime: number = 0;\n private _isConnected: boolean = false;\n private _pitch: Nullable<_WebAudioParameterComponent> = null;\n private _playbackRate: Nullable<_WebAudioParameterComponent> = null;\n private _sourceNode: Nullable<AudioBufferSourceNode> = null;\n private _volumeNode: GainNode;\n\n protected override readonly _options: IStaticSoundInstanceOptions;\n protected override _sound: _WebAudioStaticSound;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n public constructor(sound: _WebAudioStaticSound, options: IStaticSoundInstanceOptions) {\n super(sound);\n\n this._options = options;\n\n this._volumeNode = new GainNode(sound._audioContext);\n this._initSourceNode();\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._pitch?.dispose();\n this._playbackRate?.dispose();\n\n this._sourceNode = null;\n\n this.stop();\n\n this._deinitSourceNode();\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n }\n\n /** @internal */\n public get currentTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n const timeSinceLastStart = this._state === SoundState.Paused ? 0 : this.engine.currentTime - this._enginePlayTime;\n return this._enginePauseTime + timeSinceLastStart + this._options.startOffset;\n }\n\n public set currentTime(value: number) {\n const restart = this._state === SoundState.Starting || this._state === SoundState.Started;\n\n if (restart) {\n // Stop source node without sending `onEndedObservable` so instance's `dispose` function is not called.\n const sourceNode = this._sourceNode;\n this._deinitSourceNode();\n sourceNode?.stop();\n this._state = SoundState.Stopped;\n }\n\n this._options.startOffset = value;\n\n if (restart) {\n this.play();\n }\n }\n\n public get _outNode(): Nullable<AudioNode> {\n return this._volumeNode;\n }\n\n /** @internal */\n public set pitch(value: number) {\n this._pitch?.setTargetValue(value);\n }\n\n /** @internal */\n public set playbackRate(value: number) {\n this._playbackRate?.setTargetValue(value);\n }\n\n /** @internal */\n public get startTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n return this._enginePlayTime;\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioStaticSoundInstance\";\n }\n\n /** @internal */\n public play(options: Partial<IStaticSoundPlayOptions> = {}): void {\n if (this._state === SoundState.Started) {\n return;\n }\n\n if (options.duration !== undefined) {\n this._options.duration = options.duration;\n }\n if (options.loop !== undefined) {\n this._options.loop = options.loop;\n }\n if (options.loopStart !== undefined) {\n this._options.loopStart = options.loopStart;\n }\n if (options.loopEnd !== undefined) {\n this._options.loopEnd = options.loopEnd;\n }\n if (options.startOffset !== undefined) {\n this._options.startOffset = options.startOffset;\n }\n\n let startOffset = this._options.startOffset;\n\n if (this._state === SoundState.Paused) {\n startOffset += this.currentTime;\n startOffset %= this._sound.buffer.duration;\n }\n\n this._enginePlayTime = this.engine.currentTime + (options.waitTime ?? 0);\n\n this._volumeNode.gain.value = options.volume ?? 1;\n\n this._initSourceNode();\n\n if (this.engine.state === \"running\") {\n this._setState(SoundState.Started);\n this._sourceNode?.start(this._enginePlayTime, startOffset, this._options.duration > 0 ? this._options.duration : undefined);\n } else if (this._options.loop) {\n this._setState(SoundState.Starting);\n this.engine.stateChangedObservable.add(this._onEngineStateChanged);\n }\n }\n\n /** @internal */\n public pause(): void {\n if (this._state === SoundState.Paused) {\n return;\n }\n\n this._setState(SoundState.Paused);\n this._enginePauseTime += this.engine.currentTime - this._enginePlayTime;\n\n this._sourceNode?.stop();\n this._deinitSourceNode();\n }\n\n /** @internal */\n public resume(): void {\n if (this._state === SoundState.Paused) {\n this.play();\n }\n }\n\n /** @internal */\n public stop(options: Partial<IStaticSoundStopOptions> = {}): void {\n if (this._state === SoundState.Stopped) {\n return;\n }\n\n const engineStopTime = this.engine.currentTime + (options.waitTime ?? 0);\n this._sourceNode?.stop(engineStopTime);\n\n if (options.waitTime === undefined || options.waitTime <= 0) {\n this._setState(SoundState.Stopped);\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n }\n }\n\n protected override _connect(node: AbstractAudioNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the sound's subgraph.\n if (node instanceof _WebAudioStaticSound && node._inNode) {\n this._outNode?.connect(node._inNode);\n this._isConnected = true;\n }\n\n return true;\n }\n\n protected override _disconnect(node: AbstractAudioNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node instanceof _WebAudioStaticSound && node._inNode) {\n this._outNode?.disconnect(node._inNode);\n this._isConnected = false;\n }\n\n return true;\n }\n\n protected _onEnded = () => {\n this._enginePlayTime = 0;\n\n this.onEndedObservable.notifyObservers(this);\n this._deinitSourceNode();\n };\n\n private _deinitSourceNode(): void {\n if (!this._sourceNode) {\n return;\n }\n\n if (this._isConnected && !this._disconnect(this._sound)) {\n throw new Error(\"Disconnect failed\");\n }\n\n this._sourceNode.disconnect(this._volumeNode);\n this._sourceNode.removeEventListener(\"ended\", this._onEnded);\n\n this._sourceNode = null;\n }\n\n private _initSourceNode(): void {\n if (!this._sourceNode) {\n this._sourceNode = new AudioBufferSourceNode(this._sound._audioContext, { buffer: this._sound.buffer._audioBuffer });\n\n this._sourceNode.addEventListener(\"ended\", this._onEnded, { once: true });\n this._sourceNode.connect(this._volumeNode);\n\n if (!this._connect(this._sound)) {\n throw new Error(\"Connect failed\");\n }\n\n this._pitch = new _WebAudioParameterComponent(this.engine, this._sourceNode.detune);\n this._playbackRate = new _WebAudioParameterComponent(this.engine, this._sourceNode.playbackRate);\n }\n\n const node = this._sourceNode;\n node.detune.value = this._sound.pitch;\n node.loop = this._options.loop;\n node.loopEnd = this._options.loopEnd;\n node.loopStart = this._options.loopStart;\n node.playbackRate.value = this._sound.playbackRate;\n }\n\n private _onEngineStateChanged = () => {\n if (this.engine.state !== \"running\") {\n return;\n }\n\n if (this._options.loop && this.state === SoundState.Starting) {\n this.play();\n }\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n };\n}\n"]}
|
package/Collisions/gpuPicker.js
CHANGED
|
@@ -147,7 +147,6 @@ export class GPUPicker {
|
|
|
147
147
|
if (!list || list.length === 0) {
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
-
this._pickableMeshes = list;
|
|
151
150
|
// Prepare target
|
|
152
151
|
const scene = ("mesh" in list[0] ? list[0].mesh : list[0]).getScene();
|
|
153
152
|
if (!this._cachedScene || this._cachedScene !== scene) {
|