@babylonjs/core 7.52.1 → 7.52.2
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/AudioV2/abstractAudio/abstractSound.d.ts +1 -2
- package/AudioV2/abstractAudio/abstractSound.js +1 -5
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/audioBus.d.ts +1 -2
- package/AudioV2/abstractAudio/audioBus.js +1 -5
- package/AudioV2/abstractAudio/audioBus.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +1 -2
- package/AudioV2/abstractAudio/audioEngineV2.js +1 -5
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +43 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +71 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -0
- package/AudioV2/abstractAudio/staticSound.d.ts +1 -1
- package/AudioV2/abstractAudio/staticSound.js +2 -2
- package/AudioV2/abstractAudio/staticSound.js.map +1 -1
- package/AudioV2/abstractAudio/streamingSound.d.ts +1 -1
- package/AudioV2/abstractAudio/streamingSound.js +2 -2
- package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +15 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +38 -3
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +29 -8
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +1 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +28 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js +5 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +16 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +48 -14
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +21 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +39 -4
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
- package/AudioV2/index.d.ts +1 -0
- package/AudioV2/index.js +1 -0
- package/AudioV2/index.js.map +1 -1
- package/AudioV2/spatialAudioAttachmentType.d.ts +5 -0
- package/AudioV2/spatialAudioAttachmentType.js +7 -0
- package/AudioV2/spatialAudioAttachmentType.js.map +1 -0
- package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.d.ts +13 -0
- package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js +38 -0
- package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js.map +1 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +13 -14
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +39 -39
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudio.d.ts +6 -2
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js +13 -15
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.d.ts +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +41 -56
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioBus.d.ts +3 -0
- package/AudioV2/webAudio/webAudioBus.js +23 -2
- package/AudioV2/webAudio/webAudioBus.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +3 -1
- package/AudioV2/webAudio/webAudioEngine.js +11 -3
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +3 -0
- package/AudioV2/webAudio/webAudioStaticSound.js +23 -2
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -0
- package/AudioV2/webAudio/webAudioStreamingSound.js +23 -2
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Meshes/geometry.js +14 -7
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +1 -1
- package/Meshes/mesh.vertexData.js +2 -1
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spatialWebAudioListener.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subProperties/spatialWebAudioListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;
|
|
1
|
+
{"version":3,"file":"spatialWebAudioListener.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subProperties/spatialWebAudioListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAC/F,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AAGjG,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;AAChC,MAAM,aAAa,GAAG,IAAI,UAAU,EAAE,CAAC;AACvC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAEjC,gBAAgB;AACh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,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACJ,OAAO;QACX,CAAC;QAED,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;QAE7C,wCAAwC;QACxC,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,0BAA0B,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QACvF,QAAQ,CAAC,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;QACtC,QAAQ,CAAC,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;QACtC,QAAQ,CAAC,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;QAEtC,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QACjE,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;QACjC,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;QACjC,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import { Matrix, Quaternion, Vector3 } from \"../../../Maths/math.vector\";\nimport { _SpatialAudioListener } from \"../../abstractAudio/subProperties/spatialAudioListener\";\nimport { _SpatialWebAudioUpdaterComponent } from \"../components/spatialWebAudioUpdaterComponent\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\n\nconst TmpMatrix = Matrix.Zero();\nconst TmpQuaternion = new Quaternion();\nconst TmpVector = Vector3.Zero();\n\n/** @internal */\nexport function _CreateSpatialAudioListener(engine: _WebAudioEngine, autoUpdate: boolean, minUpdateTime: number): _SpatialAudioListener {\n return new _SpatialWebAudioListener(engine, autoUpdate, minUpdateTime);\n}\n\n/**\n * This sub property is not backed by a sub node and all properties are set directly on the audio context listener.\n *\n * @internal\n */\nclass _SpatialWebAudioListener extends _SpatialAudioListener {\n private _audioContext: AudioContext;\n private _lastPosition: Vector3 = Vector3.Zero();\n private _lastRotation: Vector3 = Vector3.Zero();\n private _lastRotationQuaternion: Quaternion = new Quaternion();\n private _updaterComponent: _SpatialWebAudioUpdaterComponent;\n\n /** @internal */\n public readonly position: Vector3 = Vector3.Zero();\n /** @internal */\n public readonly rotation: Vector3 = Vector3.Zero();\n /** @internal */\n public readonly rotationQuaternion: Quaternion = new Quaternion();\n\n /** @internal */\n public constructor(engine: _WebAudioEngine, autoUpdate: boolean, minUpdateTime: number) {\n super();\n\n this._audioContext = engine.audioContext;\n this._updaterComponent = new _SpatialWebAudioUpdaterComponent(this, autoUpdate, minUpdateTime);\n }\n\n /** @internal */\n public get minUpdateTime(): number {\n return this._updaterComponent.minUpdateTime;\n }\n\n /** @internal */\n public set minUpdateTime(value: number) {\n this._updaterComponent.minUpdateTime = value;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._updaterComponent.dispose();\n this._updaterComponent = null!;\n }\n\n /** @internal */\n public update(): void {\n if (this.isAttached) {\n this._attacherComponent?.update();\n } else {\n this.updatePosition();\n this.updateRotation();\n }\n }\n\n /** @internal */\n public updatePosition(): void {\n if (this._lastPosition.equalsWithEpsilon(this.position)) {\n return;\n }\n\n const listener = this._audioContext.listener;\n listener.positionX.value = this.position.x;\n listener.positionY.value = this.position.y;\n listener.positionZ.value = this.position.z;\n\n this._lastPosition.copyFrom(this.position);\n }\n\n /** @internal */\n public updateRotation(): void {\n if (!this._lastRotationQuaternion.equalsWithEpsilon(this.rotationQuaternion)) {\n TmpQuaternion.copyFrom(this.rotationQuaternion);\n this._lastRotationQuaternion.copyFrom(this.rotationQuaternion);\n } else if (!this._lastRotation.equalsWithEpsilon(this.rotation)) {\n Quaternion.FromEulerAnglesToRef(this.rotation.x, this.rotation.y, this.rotation.z, TmpQuaternion);\n this._lastRotation.copyFrom(this.rotation);\n } else {\n return;\n }\n\n Matrix.FromQuaternionToRef(TmpQuaternion, TmpMatrix);\n const listener = this._audioContext.listener;\n\n // NB: The WebAudio API is right-handed.\n Vector3.TransformNormalToRef(Vector3.RightHandedForwardReadOnly, TmpMatrix, TmpVector);\n listener.forwardX.value = TmpVector.x;\n listener.forwardY.value = TmpVector.y;\n listener.forwardZ.value = TmpVector.z;\n\n Vector3.TransformNormalToRef(Vector3.Up(), TmpMatrix, TmpVector);\n listener.upX.value = TmpVector.x;\n listener.upY.value = TmpVector.y;\n listener.upZ.value = TmpVector.z;\n }\n}\n"]}
|
|
@@ -9,6 +9,8 @@ import type { IWebAudioSuperNode } from "./webAudioNode";
|
|
|
9
9
|
/** @internal */
|
|
10
10
|
export declare class _WebAudioBus extends AudioBus implements IWebAudioSuperNode {
|
|
11
11
|
private _spatial;
|
|
12
|
+
private readonly _spatialAutoUpdate;
|
|
13
|
+
private readonly _spatialMinUpdateTime;
|
|
12
14
|
private _stereo;
|
|
13
15
|
protected _subGraph: _WebAudioBusAndSoundSubGraph;
|
|
14
16
|
/** @internal */
|
|
@@ -31,5 +33,6 @@ export declare class _WebAudioBus extends AudioBus implements IWebAudioSuperNode
|
|
|
31
33
|
get stereo(): _StereoAudio;
|
|
32
34
|
/** @internal */
|
|
33
35
|
getClassName(): string;
|
|
36
|
+
private _initSpatialProperty;
|
|
34
37
|
private static _SubGraph;
|
|
35
38
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AudioBus } from "../abstractAudio/audioBus.js";
|
|
2
|
+
import { _HasSpatialAudioOptions } from "../abstractAudio/subProperties/abstractSpatialAudio.js";
|
|
2
3
|
import { _StereoAudio } from "../abstractAudio/subProperties/stereoAudio.js";
|
|
3
4
|
import { _WebAudioBusAndSoundSubGraph } from "./subNodes/webAudioBusAndSoundSubGraph.js";
|
|
4
5
|
import { _SpatialWebAudio } from "./subProperties/spatialWebAudio.js";
|
|
@@ -6,9 +7,17 @@ import { _SpatialWebAudio } from "./subProperties/spatialWebAudio.js";
|
|
|
6
7
|
export class _WebAudioBus extends AudioBus {
|
|
7
8
|
/** @internal */
|
|
8
9
|
constructor(name, engine, options) {
|
|
9
|
-
super(name, engine
|
|
10
|
+
super(name, engine);
|
|
10
11
|
this._spatial = null;
|
|
12
|
+
this._spatialAutoUpdate = true;
|
|
13
|
+
this._spatialMinUpdateTime = 0;
|
|
11
14
|
this._stereo = null;
|
|
15
|
+
if (typeof options.spatialAutoUpdate === "boolean") {
|
|
16
|
+
this._spatialAutoUpdate = options.spatialAutoUpdate;
|
|
17
|
+
}
|
|
18
|
+
if (typeof options.spatialMinUpdateTime === "number") {
|
|
19
|
+
this._spatialMinUpdateTime = options.spatialMinUpdateTime;
|
|
20
|
+
}
|
|
12
21
|
this._subGraph = new _WebAudioBus._SubGraph(this);
|
|
13
22
|
this.audioContext = engine.audioContext;
|
|
14
23
|
}
|
|
@@ -22,6 +31,9 @@ export class _WebAudioBus extends AudioBus {
|
|
|
22
31
|
this.outBus = this.engine.defaultMainBus;
|
|
23
32
|
}
|
|
24
33
|
await this._subGraph.init(options);
|
|
34
|
+
if (_HasSpatialAudioOptions(options)) {
|
|
35
|
+
this._initSpatialProperty();
|
|
36
|
+
}
|
|
25
37
|
this.engine.addNode(this);
|
|
26
38
|
}
|
|
27
39
|
/** @internal */
|
|
@@ -41,7 +53,10 @@ export class _WebAudioBus extends AudioBus {
|
|
|
41
53
|
}
|
|
42
54
|
/** @internal */
|
|
43
55
|
get spatial() {
|
|
44
|
-
|
|
56
|
+
if (this._spatial) {
|
|
57
|
+
return this._spatial;
|
|
58
|
+
}
|
|
59
|
+
return this._initSpatialProperty();
|
|
45
60
|
}
|
|
46
61
|
/** @internal */
|
|
47
62
|
get stereo() {
|
|
@@ -51,6 +66,12 @@ export class _WebAudioBus extends AudioBus {
|
|
|
51
66
|
getClassName() {
|
|
52
67
|
return "_WebAudioBus";
|
|
53
68
|
}
|
|
69
|
+
_initSpatialProperty() {
|
|
70
|
+
if (!this._spatial) {
|
|
71
|
+
this._spatial = new _SpatialWebAudio(this._subGraph, this._spatialAutoUpdate, this._spatialMinUpdateTime);
|
|
72
|
+
}
|
|
73
|
+
return this._spatial;
|
|
74
|
+
}
|
|
54
75
|
}
|
|
55
76
|
_WebAudioBus._SubGraph = class extends _WebAudioBusAndSoundSubGraph {
|
|
56
77
|
get _downstreamNodes() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webAudioBus.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/webAudio/webAudioBus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"webAudioBus.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/webAudio/webAudioBus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAC;AAE9F,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAInE,gBAAgB;AAChB,MAAM,OAAO,YAAa,SAAQ,QAAQ;IActC,gBAAgB;IAChB,YAAmB,IAAY,EAAE,MAAuB,EAAE,OAAkC;QACxF,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAfhB,aAAQ,GAA4B,IAAI,CAAC;QAChC,uBAAkB,GAAY,IAAI,CAAC;QACnC,0BAAqB,GAAW,CAAC,CAAC;QAC3C,YAAO,GAA2B,IAAI,CAAC;QAc3C,IAAI,OAAO,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACjD,IAAI,CAAC,kBAAkB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CAAC,OAAO,CAAC;IAClC,CAAC;IAED,gBAAgB;IAChB,IAAoB,OAAO;QACvB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;QACD,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACvC,CAAC;IAED,gBAAgB;IAChB,IAAoB,MAAM;QACtB,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,gBAAgB;IACT,YAAY;QACf,OAAO,cAAc,CAAC;IAC1B,CAAC;IAEO,oBAAoB;QACxB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC9G,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;;AAEc,sBAAS,GAAG,KAAM,SAAQ,4BAA4B;IAGjE,IAAc,gBAAgB;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,IAAI,CAAC;IAChD,CAAC;IAED,IAAc,cAAc;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC;IAC9C,CAAC;CACJ,AAVuB,CAUtB","sourcesContent":["import type { Nullable } from \"core/types\";\nimport type { AbstractAudioNode } from \"../abstractAudio/abstractAudioNode\";\nimport type { IAudioBusOptions } from \"../abstractAudio/audioBus\";\nimport { AudioBus } from \"../abstractAudio/audioBus\";\nimport { _HasSpatialAudioOptions } from \"../abstractAudio/subProperties/abstractSpatialAudio\";\nimport type { _SpatialAudio } from \"../abstractAudio/subProperties/spatialAudio\";\nimport { _StereoAudio } from \"../abstractAudio/subProperties/stereoAudio\";\nimport { _WebAudioBusAndSoundSubGraph } from \"./subNodes/webAudioBusAndSoundSubGraph\";\nimport { _SpatialWebAudio } from \"./subProperties/spatialWebAudio\";\nimport type { _WebAudioEngine } from \"./webAudioEngine\";\nimport type { IWebAudioSuperNode } from \"./webAudioNode\";\n\n/** @internal */\nexport class _WebAudioBus extends AudioBus implements IWebAudioSuperNode {\n private _spatial: Nullable<_SpatialAudio> = null;\n private readonly _spatialAutoUpdate: boolean = true;\n private readonly _spatialMinUpdateTime: number = 0;\n private _stereo: Nullable<_StereoAudio> = null;\n\n protected _subGraph: _WebAudioBusAndSoundSubGraph;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public readonly audioContext: AudioContext;\n\n /** @internal */\n public constructor(name: string, engine: _WebAudioEngine, options: Partial<IAudioBusOptions>) {\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._subGraph = new _WebAudioBus._SubGraph(this);\n\n this.audioContext = engine.audioContext;\n }\n\n /** @internal */\n public async init(options: Partial<IAudioBusOptions>): Promise<void> {\n if (options.outBus) {\n this.outBus = options.outBus;\n } else {\n await this.engine.isReadyPromise;\n this.outBus = this.engine.defaultMainBus;\n }\n\n await this._subGraph.init(options);\n\n if (_HasSpatialAudioOptions(options)) {\n this._initSpatialProperty();\n }\n\n this.engine.addNode(this);\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._spatial = null;\n this._stereo = null;\n\n this.engine.removeNode(this);\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 getClassName(): string {\n return \"_WebAudioBus\";\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: _WebAudioBus;\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"]}
|
|
@@ -47,7 +47,9 @@ export declare class _WebAudioEngine extends AudioEngineV2 {
|
|
|
47
47
|
private _resumeOnPauseRetryInterval;
|
|
48
48
|
private _resumeOnPauseTimerId;
|
|
49
49
|
private _resumePromise;
|
|
50
|
-
private
|
|
50
|
+
private readonly _listenerAutoUpdate;
|
|
51
|
+
private readonly _listenerMinUpdateTime;
|
|
52
|
+
private readonly _validFormats;
|
|
51
53
|
private _volume;
|
|
52
54
|
/** @internal */
|
|
53
55
|
readonly audioContext: AudioContext;
|
|
@@ -28,7 +28,7 @@ const FormatMimeTypes = {
|
|
|
28
28
|
export class _WebAudioEngine extends AudioEngineV2 {
|
|
29
29
|
/** @internal */
|
|
30
30
|
constructor(options = {}) {
|
|
31
|
-
super(
|
|
31
|
+
super();
|
|
32
32
|
this._audioContextStarted = false;
|
|
33
33
|
this._invalidFormats = new Set();
|
|
34
34
|
this._listener = null;
|
|
@@ -37,6 +37,8 @@ export class _WebAudioEngine extends AudioEngineV2 {
|
|
|
37
37
|
this._resumeOnPauseRetryInterval = 1000;
|
|
38
38
|
this._resumeOnPauseTimerId = null;
|
|
39
39
|
this._resumePromise = null;
|
|
40
|
+
this._listenerAutoUpdate = true;
|
|
41
|
+
this._listenerMinUpdateTime = 0;
|
|
40
42
|
this._validFormats = new Set();
|
|
41
43
|
this._volume = 1;
|
|
42
44
|
/** @internal */
|
|
@@ -75,6 +77,12 @@ export class _WebAudioEngine extends AudioEngineV2 {
|
|
|
75
77
|
}
|
|
76
78
|
this.userGestureObservable.notifyObservers();
|
|
77
79
|
};
|
|
80
|
+
if (typeof options.listenerAutoUpdate === "boolean") {
|
|
81
|
+
this._listenerAutoUpdate = options.listenerAutoUpdate;
|
|
82
|
+
}
|
|
83
|
+
if (typeof options.listenerMinUpdateTime === "number") {
|
|
84
|
+
this._listenerMinUpdateTime = options.listenerMinUpdateTime;
|
|
85
|
+
}
|
|
78
86
|
this._volume = options.volume ?? 1;
|
|
79
87
|
this.audioContext = options.audioContext ?? new AudioContext();
|
|
80
88
|
}
|
|
@@ -86,7 +94,7 @@ export class _WebAudioEngine extends AudioEngineV2 {
|
|
|
86
94
|
document.addEventListener("click", this._onUserGesture);
|
|
87
95
|
await this._initAudioContext();
|
|
88
96
|
if (_HasSpatialAudioListenerOptions(options)) {
|
|
89
|
-
this._listener = _CreateSpatialAudioListener(this, this._listenerAutoUpdate);
|
|
97
|
+
this._listener = _CreateSpatialAudioListener(this, this._listenerAutoUpdate, this._listenerMinUpdateTime);
|
|
90
98
|
this._listener.setOptions(options);
|
|
91
99
|
}
|
|
92
100
|
this._resolveIsReadyPromise();
|
|
@@ -105,7 +113,7 @@ export class _WebAudioEngine extends AudioEngineV2 {
|
|
|
105
113
|
}
|
|
106
114
|
/** @internal */
|
|
107
115
|
get listener() {
|
|
108
|
-
return this._listener ?? (this._listener = _CreateSpatialAudioListener(this, this._listenerAutoUpdate));
|
|
116
|
+
return this._listener ?? (this._listener = _CreateSpatialAudioListener(this, this._listenerAutoUpdate, this._listenerMinUpdateTime));
|
|
109
117
|
}
|
|
110
118
|
/** @internal */
|
|
111
119
|
get state() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webAudioEngine.js","sourceRoot":"","sources":["../../../../../dev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AAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjC,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gBAAgB;IACA,KAAK,CAAC,KAAK;QACvB,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;IAED,gBAAgB;IACA,KAAK,CAAC,MAAM;QACxB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,cAAc,CAAC;QAC/B,CAAC;QAED,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,gBAAgB;IACT,UAAU,CAAC,OAAqB;QACnC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,gBAAgB;IACT,aAAa,CAAC,OAAqB;QACtC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,gBAAgB;IACT,OAAO,CAAC,IAA4B;QACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,UAAU,CAAC,IAA4B;QAC1C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CAuCJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport type { Nullable } from \"../../types\";\nimport type { AbstractNamedAudioNode } from \"../abstractAudio/abstractAudioNode\";\nimport type { AudioBus, IAudioBusOptions } from \"../abstractAudio/audioBus\";\nimport type { AudioEngineV2State, IAudioEngineV2Options } from \"../abstractAudio/audioEngineV2\";\nimport { AudioEngineV2 } from \"../abstractAudio/audioEngineV2\";\nimport type { IMainAudioBusOptions, MainAudioBus } from \"../abstractAudio/mainAudioBus\";\nimport type { IStaticSoundOptions, StaticSound } from \"../abstractAudio/staticSound\";\nimport type { StaticSoundBuffer } from \"../abstractAudio/staticSoundBuffer\";\nimport type { IStreamingSoundOptions, StreamingSound } from \"../abstractAudio/streamingSound\";\nimport type { AbstractSpatialAudioListener } from \"../abstractAudio/subProperties/abstractSpatialAudioListener\";\nimport { _HasSpatialAudioListenerOptions } from \"../abstractAudio/subProperties/abstractSpatialAudioListener\";\nimport type { _SpatialAudioListener } from \"../abstractAudio/subProperties/spatialAudioListener\";\nimport { _CreateSpatialAudioListener } from \"./subProperties/spatialWebAudioListener\";\nimport { _WebAudioMainOut } from \"./webAudioMainOut\";\n\n/**\n * Options for creating a v2 audio engine that uses the WebAudio API.\n */\nexport interface IWebAudioEngineOptions extends IAudioEngineV2Options {\n /**\n * The audio context to be used by the engine.\n */\n audioContext: AudioContext;\n /**\n * Set to `true` to automatically resume the audio context when the user interacts with the page. Defaults to `true`.\n */\n resumeOnInteraction: boolean;\n /**\n * Set to `true` to automatically resume the audio context when the browser pauses audio playback. Defaults to `true`.\n */\n resumeOnPause: boolean;\n /**\n * The interval in milliseconds to try resuming audio playback when `resumeOnPause` is `true`. Defaults to `1000`.\n */\n resumeOnPauseRetryInterval: number;\n}\n\n/**\n * Creates a new v2 audio engine that uses the WebAudio API.\n * @param options - The options for creating the audio engine.\n * @returns A promise that resolves with the created audio engine.\n */\nexport async function CreateAudioEngineAsync(options: Partial<IWebAudioEngineOptions> = {}): Promise<AudioEngineV2> {\n const engine = new _WebAudioEngine(options);\n await engine.init(options);\n return engine;\n}\n\nconst FormatMimeTypes: { [key: string]: string } = {\n aac: \"audio/aac\",\n ac3: \"audio/ac3\",\n flac: \"audio/flac\",\n m4a: \"audio/mp4\",\n mp3: 'audio/mpeg; codecs=\"mp3\"',\n mp4: \"audio/mp4\",\n ogg: 'audio/ogg; codecs=\"vorbis\"',\n wav: \"audio/wav\",\n webm: 'audio/webm; codecs=\"vorbis\"',\n};\n\n/** @internal */\nexport class _WebAudioEngine extends AudioEngineV2 {\n private _audioContextStarted = false;\n private _invalidFormats = new Set<string>();\n private _listener: Nullable<_SpatialAudioListener> = null;\n private _mainOut: _WebAudioMainOut;\n private _resumeOnInteraction = true;\n private _resumeOnPause = true;\n private _resumeOnPauseRetryInterval = 1000;\n private _resumeOnPauseTimerId: any = null;\n private _resumePromise: Nullable<Promise<void>> = null;\n private _validFormats = new Set<string>();\n private _volume = 1;\n\n /** @internal */\n public readonly audioContext: AudioContext;\n\n /** @internal */\n public readonly isReadyPromise: Promise<void> = new Promise((resolve) => {\n this._resolveIsReadyPromise = resolve;\n });\n\n /** @internal */\n public stateChangedObservable: Observable<string> = new Observable();\n\n /** @internal */\n public userGestureObservable: Observable<void> = new Observable();\n\n /** @internal */\n public constructor(options: Partial<IWebAudioEngineOptions> = {}) {\n super(options);\n\n this._volume = options.volume ?? 1;\n this.audioContext = options.audioContext ?? new AudioContext();\n }\n\n /** @internal */\n public async init(options: Partial<IWebAudioEngineOptions>): Promise<void> {\n this._resumeOnInteraction = typeof options.resumeOnInteraction === \"boolean\" ? options.resumeOnInteraction : true;\n this._resumeOnPause = typeof options.resumeOnPause === \"boolean\" ? options.resumeOnPause : true;\n this._resumeOnPauseRetryInterval = options.resumeOnPauseRetryInterval ?? 1000;\n\n document.addEventListener(\"click\", this._onUserGesture);\n\n await this._initAudioContext();\n\n if (_HasSpatialAudioListenerOptions(options)) {\n this._listener = _CreateSpatialAudioListener(this, this._listenerAutoUpdate);\n this._listener.setOptions(options);\n }\n\n this._resolveIsReadyPromise();\n }\n\n /** @internal */\n public get currentTime(): number {\n return this.audioContext.currentTime ?? 0;\n }\n\n /** @internal */\n public get inNode(): AudioNode {\n return this.audioContext.destination;\n }\n\n /** @internal */\n public get mainOut(): _WebAudioMainOut {\n return this._mainOut;\n }\n\n /** @internal */\n public get listener(): AbstractSpatialAudioListener {\n return this._listener ?? (this._listener = _CreateSpatialAudioListener(this, this._listenerAutoUpdate));\n }\n\n /** @internal */\n public get state(): AudioEngineV2State {\n return this.audioContext.state;\n }\n\n /** @internal */\n public get volume(): number {\n return this._volume;\n }\n\n /** @internal */\n public set volume(value: number) {\n if (this._volume === value) {\n return;\n }\n\n this._volume = value;\n\n if (this._mainOut) {\n this._mainOut.volume = value;\n }\n }\n\n /** @internal */\n public async createBusAsync(name: string, options: Partial<IAudioBusOptions> = {}): Promise<AudioBus> {\n const module = await import(\"./webAudioBus\");\n\n const bus = new module._WebAudioBus(name, this, options);\n await bus.init(options);\n\n return bus;\n }\n\n /** @internal */\n public async createMainBusAsync(name: string, options: Partial<IMainAudioBusOptions> = {}): Promise<MainAudioBus> {\n const module = await import(\"./webAudioMainBus\");\n\n const bus = new module._WebAudioMainBus(name, this);\n await bus.init(options);\n\n return bus;\n }\n\n /** @internal */\n public async createSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {}\n ): Promise<StaticSound> {\n const module = await import(\"./webAudioStaticSound\");\n\n const sound = new module._WebAudioStaticSound(name, this, options);\n await sound.init(source, options);\n\n return sound;\n }\n\n /** @internal */\n public async createSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {}\n ): Promise<StaticSoundBuffer> {\n const module = await import(\"./webAudioStaticSound\");\n\n const soundBuffer = new module._WebAudioStaticSoundBuffer(this);\n await soundBuffer.init(source, options);\n\n return soundBuffer;\n }\n\n /** @internal */\n public async createStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options: Partial<IStreamingSoundOptions> = {}): Promise<StreamingSound> {\n const module = await import(\"./webAudioStreamingSound\");\n\n const sound = new module._WebAudioStreamingSound(name, this, options);\n await sound.init(source, options);\n\n return sound;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._listener?.dispose();\n this._listener = null;\n\n if (this.audioContext.state !== \"closed\") {\n this.audioContext.close();\n }\n\n document.removeEventListener(\"click\", this._onUserGesture);\n this.audioContext.removeEventListener(\"statechange\", this._onAudioContextStateChange);\n }\n\n /** @internal */\n public flagInvalidFormat(format: string): void {\n this._invalidFormats.add(format);\n }\n\n /** @internal */\n public isFormatValid(format: string): boolean {\n if (this._validFormats.has(format)) {\n return true;\n }\n\n if (this._invalidFormats.has(format)) {\n return false;\n }\n\n const mimeType = FormatMimeTypes[format];\n if (mimeType === undefined) {\n return false;\n }\n\n const audio = new Audio();\n if (audio.canPlayType(mimeType) === \"\") {\n this._invalidFormats.add(format);\n return false;\n }\n\n this._validFormats.add(format);\n\n return true;\n }\n\n /** @internal */\n public override async pause(): Promise<void> {\n await this.audioContext.suspend();\n }\n\n /** @internal */\n public override async resume(): Promise<void> {\n if (this._resumePromise) {\n return this._resumePromise;\n }\n\n this._resumePromise = this.audioContext.resume();\n return this._resumePromise;\n }\n\n /** @internal */\n public addMainBus(mainBus: MainAudioBus): void {\n this._addMainBus(mainBus);\n }\n\n /** @internal */\n public removeMainBus(mainBus: MainAudioBus): void {\n this._removeMainBus(mainBus);\n }\n\n /** @internal */\n public addNode(node: AbstractNamedAudioNode): void {\n this._addNode(node);\n }\n\n /** @internal */\n public removeNode(node: AbstractNamedAudioNode): void {\n this._removeNode(node);\n }\n\n private _initAudioContext: () => Promise<void> = async () => {\n this.audioContext.addEventListener(\"statechange\", this._onAudioContextStateChange);\n\n this._mainOut = new _WebAudioMainOut(this);\n this._mainOut.volume = this._volume;\n\n await this.createMainBusAsync(\"default\");\n };\n\n private _onAudioContextStateChange = () => {\n if (this.state === \"running\") {\n clearInterval(this._resumeOnPauseTimerId);\n this._audioContextStarted = true;\n this._resumePromise = null;\n }\n if (this.state === \"suspended\" || this.state === \"interrupted\") {\n if (this._audioContextStarted && this._resumeOnPause) {\n clearInterval(this._resumeOnPauseTimerId);\n\n this._resumeOnPauseTimerId = setInterval(() => {\n this.resume();\n }, this._resumeOnPauseRetryInterval);\n }\n }\n\n this.stateChangedObservable.notifyObservers(this.state);\n };\n\n private _onUserGesture: () => void = async () => {\n if (this._resumeOnInteraction) {\n await this.audioContext.resume();\n }\n\n this.userGestureObservable.notifyObservers();\n };\n\n private _resolveIsReadyPromise: () => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"webAudioEngine.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/webAudio/webAudioEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAKnD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAM/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,6DAA6D,CAAC;AAE9G,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAwBrD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,UAA2C,EAAE;IACtF,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,MAAM,eAAe,GAA8B;IAC/C,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,0BAA0B;IAC/B,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,4BAA4B;IACjC,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,6BAA6B;CACtC,CAAC;AAEF,gBAAgB;AAChB,MAAM,OAAO,eAAgB,SAAQ,aAAa;IA6B9C,gBAAgB;IAChB,YAAmB,UAA2C,EAAE;QAC5D,KAAK,EAAE,CAAC;QA9BJ,yBAAoB,GAAG,KAAK,CAAC;QAC7B,oBAAe,GAAG,IAAI,GAAG,EAAU,CAAC;QACpC,cAAS,GAAoC,IAAI,CAAC;QAEl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OAAqB;QACtC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,gBAAgB;IACT,OAAO,CAAC,IAA4B;QACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,UAAU,CAAC,IAA4B;QAC1C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CAuCJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport type { Nullable } from \"../../types\";\nimport type { AbstractNamedAudioNode } from \"../abstractAudio/abstractAudioNode\";\nimport type { AudioBus, IAudioBusOptions } from \"../abstractAudio/audioBus\";\nimport type { AudioEngineV2State, IAudioEngineV2Options } from \"../abstractAudio/audioEngineV2\";\nimport { AudioEngineV2 } from \"../abstractAudio/audioEngineV2\";\nimport type { IMainAudioBusOptions, MainAudioBus } from \"../abstractAudio/mainAudioBus\";\nimport type { IStaticSoundOptions, StaticSound } from \"../abstractAudio/staticSound\";\nimport type { StaticSoundBuffer } from \"../abstractAudio/staticSoundBuffer\";\nimport type { IStreamingSoundOptions, StreamingSound } from \"../abstractAudio/streamingSound\";\nimport type { AbstractSpatialAudioListener } from \"../abstractAudio/subProperties/abstractSpatialAudioListener\";\nimport { _HasSpatialAudioListenerOptions } from \"../abstractAudio/subProperties/abstractSpatialAudioListener\";\nimport type { _SpatialAudioListener } from \"../abstractAudio/subProperties/spatialAudioListener\";\nimport { _CreateSpatialAudioListener } from \"./subProperties/spatialWebAudioListener\";\nimport { _WebAudioMainOut } from \"./webAudioMainOut\";\n\n/**\n * Options for creating a v2 audio engine that uses the WebAudio API.\n */\nexport interface IWebAudioEngineOptions extends IAudioEngineV2Options {\n /**\n * The audio context to be used by the engine.\n */\n audioContext: AudioContext;\n /**\n * Set to `true` to automatically resume the audio context when the user interacts with the page. Defaults to `true`.\n */\n resumeOnInteraction: boolean;\n /**\n * Set to `true` to automatically resume the audio context when the browser pauses audio playback. Defaults to `true`.\n */\n resumeOnPause: boolean;\n /**\n * The interval in milliseconds to try resuming audio playback when `resumeOnPause` is `true`. Defaults to `1000`.\n */\n resumeOnPauseRetryInterval: number;\n}\n\n/**\n * Creates a new v2 audio engine that uses the WebAudio API.\n * @param options - The options for creating the audio engine.\n * @returns A promise that resolves with the created audio engine.\n */\nexport async function CreateAudioEngineAsync(options: Partial<IWebAudioEngineOptions> = {}): Promise<AudioEngineV2> {\n const engine = new _WebAudioEngine(options);\n await engine.init(options);\n return engine;\n}\n\nconst FormatMimeTypes: { [key: string]: string } = {\n aac: \"audio/aac\",\n ac3: \"audio/ac3\",\n flac: \"audio/flac\",\n m4a: \"audio/mp4\",\n mp3: 'audio/mpeg; codecs=\"mp3\"',\n mp4: \"audio/mp4\",\n ogg: 'audio/ogg; codecs=\"vorbis\"',\n wav: \"audio/wav\",\n webm: 'audio/webm; codecs=\"vorbis\"',\n};\n\n/** @internal */\nexport class _WebAudioEngine extends AudioEngineV2 {\n private _audioContextStarted = false;\n private _invalidFormats = new Set<string>();\n private _listener: Nullable<_SpatialAudioListener> = null;\n private _mainOut: _WebAudioMainOut;\n private _resumeOnInteraction = true;\n private _resumeOnPause = true;\n private _resumeOnPauseRetryInterval = 1000;\n private _resumeOnPauseTimerId: any = null;\n private _resumePromise: Nullable<Promise<void>> = null;\n private readonly _listenerAutoUpdate: boolean = true;\n private readonly _listenerMinUpdateTime: number = 0;\n private readonly _validFormats = new Set<string>();\n private _volume = 1;\n\n /** @internal */\n public readonly audioContext: AudioContext;\n\n /** @internal */\n public readonly isReadyPromise: Promise<void> = new Promise((resolve) => {\n this._resolveIsReadyPromise = resolve;\n });\n\n /** @internal */\n public stateChangedObservable: Observable<string> = new Observable();\n\n /** @internal */\n public userGestureObservable: Observable<void> = new Observable();\n\n /** @internal */\n public constructor(options: Partial<IWebAudioEngineOptions> = {}) {\n super();\n\n if (typeof options.listenerAutoUpdate === \"boolean\") {\n this._listenerAutoUpdate = options.listenerAutoUpdate;\n }\n\n if (typeof options.listenerMinUpdateTime === \"number\") {\n this._listenerMinUpdateTime = options.listenerMinUpdateTime;\n }\n\n this._volume = options.volume ?? 1;\n this.audioContext = options.audioContext ?? new AudioContext();\n }\n\n /** @internal */\n public async init(options: Partial<IWebAudioEngineOptions>): Promise<void> {\n this._resumeOnInteraction = typeof options.resumeOnInteraction === \"boolean\" ? options.resumeOnInteraction : true;\n this._resumeOnPause = typeof options.resumeOnPause === \"boolean\" ? options.resumeOnPause : true;\n this._resumeOnPauseRetryInterval = options.resumeOnPauseRetryInterval ?? 1000;\n\n document.addEventListener(\"click\", this._onUserGesture);\n\n await this._initAudioContext();\n\n if (_HasSpatialAudioListenerOptions(options)) {\n this._listener = _CreateSpatialAudioListener(this, this._listenerAutoUpdate, this._listenerMinUpdateTime);\n this._listener.setOptions(options);\n }\n\n this._resolveIsReadyPromise();\n }\n\n /** @internal */\n public get currentTime(): number {\n return this.audioContext.currentTime ?? 0;\n }\n\n /** @internal */\n public get inNode(): AudioNode {\n return this.audioContext.destination;\n }\n\n /** @internal */\n public get mainOut(): _WebAudioMainOut {\n return this._mainOut;\n }\n\n /** @internal */\n public get listener(): AbstractSpatialAudioListener {\n return this._listener ?? (this._listener = _CreateSpatialAudioListener(this, this._listenerAutoUpdate, this._listenerMinUpdateTime));\n }\n\n /** @internal */\n public get state(): AudioEngineV2State {\n return this.audioContext.state;\n }\n\n /** @internal */\n public get volume(): number {\n return this._volume;\n }\n\n /** @internal */\n public set volume(value: number) {\n if (this._volume === value) {\n return;\n }\n\n this._volume = value;\n\n if (this._mainOut) {\n this._mainOut.volume = value;\n }\n }\n\n /** @internal */\n public async createBusAsync(name: string, options: Partial<IAudioBusOptions> = {}): Promise<AudioBus> {\n const module = await import(\"./webAudioBus\");\n\n const bus = new module._WebAudioBus(name, this, options);\n await bus.init(options);\n\n return bus;\n }\n\n /** @internal */\n public async createMainBusAsync(name: string, options: Partial<IMainAudioBusOptions> = {}): Promise<MainAudioBus> {\n const module = await import(\"./webAudioMainBus\");\n\n const bus = new module._WebAudioMainBus(name, this);\n await bus.init(options);\n\n return bus;\n }\n\n /** @internal */\n public async createSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {}\n ): Promise<StaticSound> {\n const module = await import(\"./webAudioStaticSound\");\n\n const sound = new module._WebAudioStaticSound(name, this, options);\n await sound.init(source, options);\n\n return sound;\n }\n\n /** @internal */\n public async createSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {}\n ): Promise<StaticSoundBuffer> {\n const module = await import(\"./webAudioStaticSound\");\n\n const soundBuffer = new module._WebAudioStaticSoundBuffer(this);\n await soundBuffer.init(source, options);\n\n return soundBuffer;\n }\n\n /** @internal */\n public async createStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options: Partial<IStreamingSoundOptions> = {}): Promise<StreamingSound> {\n const module = await import(\"./webAudioStreamingSound\");\n\n const sound = new module._WebAudioStreamingSound(name, this, options);\n await sound.init(source, options);\n\n return sound;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._listener?.dispose();\n this._listener = null;\n\n if (this.audioContext.state !== \"closed\") {\n this.audioContext.close();\n }\n\n document.removeEventListener(\"click\", this._onUserGesture);\n this.audioContext.removeEventListener(\"statechange\", this._onAudioContextStateChange);\n }\n\n /** @internal */\n public flagInvalidFormat(format: string): void {\n this._invalidFormats.add(format);\n }\n\n /** @internal */\n public isFormatValid(format: string): boolean {\n if (this._validFormats.has(format)) {\n return true;\n }\n\n if (this._invalidFormats.has(format)) {\n return false;\n }\n\n const mimeType = FormatMimeTypes[format];\n if (mimeType === undefined) {\n return false;\n }\n\n const audio = new Audio();\n if (audio.canPlayType(mimeType) === \"\") {\n this._invalidFormats.add(format);\n return false;\n }\n\n this._validFormats.add(format);\n\n return true;\n }\n\n /** @internal */\n public override async pause(): Promise<void> {\n await this.audioContext.suspend();\n }\n\n /** @internal */\n public override async resume(): Promise<void> {\n if (this._resumePromise) {\n return this._resumePromise;\n }\n\n this._resumePromise = this.audioContext.resume();\n return this._resumePromise;\n }\n\n /** @internal */\n public addMainBus(mainBus: MainAudioBus): void {\n this._addMainBus(mainBus);\n }\n\n /** @internal */\n public removeMainBus(mainBus: MainAudioBus): void {\n this._removeMainBus(mainBus);\n }\n\n /** @internal */\n public addNode(node: AbstractNamedAudioNode): void {\n this._addNode(node);\n }\n\n /** @internal */\n public removeNode(node: AbstractNamedAudioNode): void {\n this._removeNode(node);\n }\n\n private _initAudioContext: () => Promise<void> = async () => {\n this.audioContext.addEventListener(\"statechange\", this._onAudioContextStateChange);\n\n this._mainOut = new _WebAudioMainOut(this);\n this._mainOut.volume = this._volume;\n\n await this.createMainBusAsync(\"default\");\n };\n\n private _onAudioContextStateChange = () => {\n if (this.state === \"running\") {\n clearInterval(this._resumeOnPauseTimerId);\n this._audioContextStarted = true;\n this._resumePromise = null;\n }\n if (this.state === \"suspended\" || this.state === \"interrupted\") {\n if (this._audioContextStarted && this._resumeOnPause) {\n clearInterval(this._resumeOnPauseTimerId);\n\n this._resumeOnPauseTimerId = setInterval(() => {\n this.resume();\n }, this._resumeOnPauseRetryInterval);\n }\n }\n\n this.stateChangedObservable.notifyObservers(this.state);\n };\n\n private _onUserGesture: () => void = async () => {\n if (this._resumeOnInteraction) {\n await this.audioContext.resume();\n }\n\n this.userGestureObservable.notifyObservers();\n };\n\n private _resolveIsReadyPromise: () => void;\n}\n"]}
|
|
@@ -16,6 +16,8 @@ type StaticSoundSourceType = ArrayBuffer | AudioBuffer | StaticSoundBuffer | str
|
|
|
16
16
|
export declare class _WebAudioStaticSound extends StaticSound implements IWebAudioSuperNode {
|
|
17
17
|
private _buffer;
|
|
18
18
|
private _spatial;
|
|
19
|
+
private readonly _spatialAutoUpdate;
|
|
20
|
+
private readonly _spatialMinUpdateTime;
|
|
19
21
|
private _stereo;
|
|
20
22
|
protected readonly _options: IStaticSoundStoredOptions;
|
|
21
23
|
protected _subGraph: _WebAudioBusAndSoundSubGraph;
|
|
@@ -44,6 +46,7 @@ export declare class _WebAudioStaticSound extends StaticSound implements IWebAud
|
|
|
44
46
|
protected _createInstance(): _WebAudioStaticSoundInstance;
|
|
45
47
|
protected _connect(node: IWebAudioInNode): boolean;
|
|
46
48
|
protected _disconnect(node: IWebAudioInNode): boolean;
|
|
49
|
+
private _initSpatialProperty;
|
|
47
50
|
private static _SubGraph;
|
|
48
51
|
}
|
|
49
52
|
/** @internal */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StaticSound } from "../abstractAudio/staticSound.js";
|
|
2
2
|
import { StaticSoundBuffer } from "../abstractAudio/staticSoundBuffer.js";
|
|
3
3
|
import { _StaticSoundInstance } from "../abstractAudio/staticSoundInstance.js";
|
|
4
|
+
import { _HasSpatialAudioOptions } from "../abstractAudio/subProperties/abstractSpatialAudio.js";
|
|
4
5
|
import { _StereoAudio } from "../abstractAudio/subProperties/stereoAudio.js";
|
|
5
6
|
import { _CleanUrl, _FileExtensionRegex } from "../audioUtils.js";
|
|
6
7
|
import { _WebAudioBusAndSoundSubGraph } from "./subNodes/webAudioBusAndSoundSubGraph.js";
|
|
@@ -9,9 +10,17 @@ import { _SpatialWebAudio } from "./subProperties/spatialWebAudio.js";
|
|
|
9
10
|
export class _WebAudioStaticSound extends StaticSound {
|
|
10
11
|
/** @internal */
|
|
11
12
|
constructor(name, engine, options) {
|
|
12
|
-
super(name, engine
|
|
13
|
+
super(name, engine);
|
|
13
14
|
this._spatial = null;
|
|
15
|
+
this._spatialAutoUpdate = true;
|
|
16
|
+
this._spatialMinUpdateTime = 0;
|
|
14
17
|
this._stereo = null;
|
|
18
|
+
if (typeof options.spatialAutoUpdate === "boolean") {
|
|
19
|
+
this._spatialAutoUpdate = options.spatialAutoUpdate;
|
|
20
|
+
}
|
|
21
|
+
if (typeof options.spatialMinUpdateTime === "number") {
|
|
22
|
+
this._spatialMinUpdateTime = options.spatialMinUpdateTime;
|
|
23
|
+
}
|
|
15
24
|
this._options = {
|
|
16
25
|
autoplay: options.autoplay ?? false,
|
|
17
26
|
duration: options.duration ?? 0,
|
|
@@ -42,6 +51,9 @@ export class _WebAudioStaticSound extends StaticSound {
|
|
|
42
51
|
this.outBus = this.engine.defaultMainBus;
|
|
43
52
|
}
|
|
44
53
|
await this._subGraph.init(options);
|
|
54
|
+
if (_HasSpatialAudioOptions(options)) {
|
|
55
|
+
this._initSpatialProperty();
|
|
56
|
+
}
|
|
45
57
|
if (options.autoplay) {
|
|
46
58
|
this.play();
|
|
47
59
|
}
|
|
@@ -61,7 +73,10 @@ export class _WebAudioStaticSound extends StaticSound {
|
|
|
61
73
|
}
|
|
62
74
|
/** @internal */
|
|
63
75
|
get spatial() {
|
|
64
|
-
|
|
76
|
+
if (this._spatial) {
|
|
77
|
+
return this._spatial;
|
|
78
|
+
}
|
|
79
|
+
return this._initSpatialProperty();
|
|
65
80
|
}
|
|
66
81
|
/** @internal */
|
|
67
82
|
get stereo() {
|
|
@@ -104,6 +119,12 @@ export class _WebAudioStaticSound extends StaticSound {
|
|
|
104
119
|
}
|
|
105
120
|
return true;
|
|
106
121
|
}
|
|
122
|
+
_initSpatialProperty() {
|
|
123
|
+
if (!this._spatial) {
|
|
124
|
+
this._spatial = new _SpatialWebAudio(this._subGraph, this._spatialAutoUpdate, this._spatialMinUpdateTime);
|
|
125
|
+
}
|
|
126
|
+
return this._spatial;
|
|
127
|
+
}
|
|
107
128
|
}
|
|
108
129
|
_WebAudioStaticSound._SubGraph = class extends _WebAudioBusAndSoundSubGraph {
|
|
109
130
|
get _downstreamNodes() {
|
|
@@ -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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AC/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,QAAQ,CAAC,YAAY,CAAC;IACzD,CAAC;CAaJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { AbstractAudioNode } from \"../abstractAudio/abstractAudioNode\";\nimport type { IStaticSoundOptions, IStaticSoundPlayOptions, IStaticSoundStopOptions, IStaticSoundStoredOptions } from \"../abstractAudio/staticSound\";\nimport { StaticSound } from \"../abstractAudio/staticSound\";\nimport type { IStaticSoundBufferOptions } from \"../abstractAudio/staticSoundBuffer\";\nimport { StaticSoundBuffer } from \"../abstractAudio/staticSoundBuffer\";\nimport type { IStaticSoundInstanceOptions } from \"../abstractAudio/staticSoundInstance\";\nimport { _StaticSoundInstance } from \"../abstractAudio/staticSoundInstance\";\nimport type { _SpatialAudio } from \"../abstractAudio/subProperties/spatialAudio\";\nimport { _StereoAudio } from \"../abstractAudio/subProperties/stereoAudio\";\nimport { _CleanUrl, _FileExtensionRegex } from \"../audioUtils\";\nimport { SoundState } from \"../soundState\";\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 _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, options);\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 init(source: StaticSoundSourceType, options: Partial<IStaticSoundOptions>): Promise<void> {\n this.audioContext = this.engine.audioContext;\n\n if (source instanceof _WebAudioStaticSoundBuffer) {\n this._buffer = source as _WebAudioStaticSoundBuffer;\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 {\n await this.engine.isReadyPromise;\n this.outBus = this.engine.defaultMainBus;\n }\n\n await this._subGraph.init(options);\n\n if (options.autoplay) {\n this.play();\n }\n\n this.engine.addNode(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 return this._spatial ?? (this._spatial = new _SpatialWebAudio(this._subGraph, this._spatialAutoUpdate));\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 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.removeNode(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 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 init(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._initFromUrl(source);\n } else if (Array.isArray(source)) {\n await this._initFromUrls(source, options.skipCodecCheck ?? false);\n } else if (source instanceof ArrayBuffer) {\n await this._initFromArrayBuffer(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 private async _initFromArrayBuffer(arrayBuffer: ArrayBuffer): Promise<void> {\n this.audioBuffer = await this.engine.audioContext.decodeAudioData(arrayBuffer);\n }\n\n private async _initFromUrl(url: string): Promise<void> {\n url = _CleanUrl(url);\n await this._initFromArrayBuffer(await (await fetch(url)).arrayBuffer());\n }\n\n private async _initFromUrls(urls: string[], skipCodecCheck: boolean): Promise<void> {\n for (const url of urls) {\n if (skipCodecCheck) {\n await this._initFromUrl(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 await this._initFromUrl(url);\n } catch (e) {\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 _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 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 get startTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n return this._enginePlayTime;\n }\n\n /** @internal */\n public override dispose(): void {\n super.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 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.pitch !== undefined) {\n this._options.pitch = options.pitch;\n }\n if (options.playbackRate !== undefined) {\n this._options.playbackRate = options.playbackRate;\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 }\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 }\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._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\n const node = this._sourceNode;\n node.detune.value = this._options.pitch;\n node.loop = this._options.loop;\n node.loopEnd = this._options.loopEnd;\n node.loopStart = this._options.loopStart;\n node.playbackRate.value = this._options.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,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,OAAO,OAAO,CAAC,oBAAoB,KAAK,QAAQ,EAAE,CAAC;YACnD,IAAI,CAAC,qBA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,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;IACzD,CAAC;CAaJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { AbstractAudioNode } from \"../abstractAudio/abstractAudioNode\";\nimport type { IStaticSoundOptions, IStaticSoundPlayOptions, IStaticSoundStopOptions, IStaticSoundStoredOptions } from \"../abstractAudio/staticSound\";\nimport { StaticSound } from \"../abstractAudio/staticSound\";\nimport type { 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 { _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 init(source: StaticSoundSourceType, options: Partial<IStaticSoundOptions>): Promise<void> {\n this.audioContext = this.engine.audioContext;\n\n if (source instanceof _WebAudioStaticSoundBuffer) {\n this._buffer = source as _WebAudioStaticSoundBuffer;\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 {\n await this.engine.isReadyPromise;\n this.outBus = this.engine.defaultMainBus;\n }\n\n await this._subGraph.init(options);\n\n if (_HasSpatialAudioOptions(options)) {\n this._initSpatialProperty();\n }\n\n if (options.autoplay) {\n this.play();\n }\n\n this.engine.addNode(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 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.removeNode(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 init(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._initFromUrl(source);\n } else if (Array.isArray(source)) {\n await this._initFromUrls(source, options.skipCodecCheck ?? false);\n } else if (source instanceof ArrayBuffer) {\n await this._initFromArrayBuffer(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 private async _initFromArrayBuffer(arrayBuffer: ArrayBuffer): Promise<void> {\n this.audioBuffer = await this.engine.audioContext.decodeAudioData(arrayBuffer);\n }\n\n private async _initFromUrl(url: string): Promise<void> {\n url = _CleanUrl(url);\n await this._initFromArrayBuffer(await (await fetch(url)).arrayBuffer());\n }\n\n private async _initFromUrls(urls: string[], skipCodecCheck: boolean): Promise<void> {\n for (const url of urls) {\n if (skipCodecCheck) {\n await this._initFromUrl(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 await this._initFromUrl(url);\n } catch (e) {\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 _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 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 get startTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n return this._enginePlayTime;\n }\n\n /** @internal */\n public override dispose(): void {\n super.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 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.pitch !== undefined) {\n this._options.pitch = options.pitch;\n }\n if (options.playbackRate !== undefined) {\n this._options.playbackRate = options.playbackRate;\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 }\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 }\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._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\n const node = this._sourceNode;\n node.detune.value = this._options.pitch;\n node.loop = this._options.loop;\n node.loopEnd = this._options.loopEnd;\n node.loopStart = this._options.loopStart;\n node.playbackRate.value = this._options.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"]}
|
|
@@ -12,6 +12,8 @@ type StreamingSoundSourceType = HTMLMediaElement | string | string[];
|
|
|
12
12
|
/** @internal */
|
|
13
13
|
export declare class _WebAudioStreamingSound extends StreamingSound implements IWebAudioSuperNode {
|
|
14
14
|
private _spatial;
|
|
15
|
+
private readonly _spatialAutoUpdate;
|
|
16
|
+
private readonly _spatialMinUpdateTime;
|
|
15
17
|
private _stereo;
|
|
16
18
|
protected readonly _options: IStreamingSoundStoredOptions;
|
|
17
19
|
protected _subGraph: _WebAudioBusAndSoundSubGraph;
|
|
@@ -40,6 +42,7 @@ export declare class _WebAudioStreamingSound extends StreamingSound implements I
|
|
|
40
42
|
protected _createInstance(): _WebAudioStreamingSoundInstance;
|
|
41
43
|
protected _connect(node: IWebAudioInNode): boolean;
|
|
42
44
|
protected _disconnect(node: IWebAudioInNode): boolean;
|
|
45
|
+
private _initSpatialProperty;
|
|
43
46
|
private static _SubGraph;
|
|
44
47
|
}
|
|
45
48
|
/** @internal */
|
|
@@ -2,6 +2,7 @@ import { Logger } from "../../Misc/logger.js";
|
|
|
2
2
|
import { Tools } from "../../Misc/tools.js";
|
|
3
3
|
import { StreamingSound } from "../abstractAudio/streamingSound.js";
|
|
4
4
|
import { _StreamingSoundInstance } from "../abstractAudio/streamingSoundInstance.js";
|
|
5
|
+
import { _HasSpatialAudioOptions } from "../abstractAudio/subProperties/abstractSpatialAudio.js";
|
|
5
6
|
import { _StereoAudio } from "../abstractAudio/subProperties/stereoAudio.js";
|
|
6
7
|
import { _CleanUrl } from "../audioUtils.js";
|
|
7
8
|
import { _WebAudioBusAndSoundSubGraph } from "./subNodes/webAudioBusAndSoundSubGraph.js";
|
|
@@ -10,9 +11,17 @@ import { _SpatialWebAudio } from "./subProperties/spatialWebAudio.js";
|
|
|
10
11
|
export class _WebAudioStreamingSound extends StreamingSound {
|
|
11
12
|
/** @internal */
|
|
12
13
|
constructor(name, engine, options) {
|
|
13
|
-
super(name, engine
|
|
14
|
+
super(name, engine);
|
|
14
15
|
this._spatial = null;
|
|
16
|
+
this._spatialAutoUpdate = true;
|
|
17
|
+
this._spatialMinUpdateTime = 0;
|
|
15
18
|
this._stereo = null;
|
|
19
|
+
if (typeof options.spatialAutoUpdate === "boolean") {
|
|
20
|
+
this._spatialAutoUpdate = options.spatialAutoUpdate;
|
|
21
|
+
}
|
|
22
|
+
if (typeof options.spatialMinUpdateTime === "number") {
|
|
23
|
+
this._spatialMinUpdateTime = options.spatialMinUpdateTime;
|
|
24
|
+
}
|
|
16
25
|
this._options = {
|
|
17
26
|
autoplay: options.autoplay ?? false,
|
|
18
27
|
loop: options.loop ?? false,
|
|
@@ -38,6 +47,9 @@ export class _WebAudioStreamingSound extends StreamingSound {
|
|
|
38
47
|
this.outBus = this.engine.defaultMainBus;
|
|
39
48
|
}
|
|
40
49
|
await this._subGraph.init(options);
|
|
50
|
+
if (_HasSpatialAudioOptions(options)) {
|
|
51
|
+
this._initSpatialProperty();
|
|
52
|
+
}
|
|
41
53
|
if (this.preloadCount) {
|
|
42
54
|
await this.preloadInstances(this.preloadCount);
|
|
43
55
|
}
|
|
@@ -56,7 +68,10 @@ export class _WebAudioStreamingSound extends StreamingSound {
|
|
|
56
68
|
}
|
|
57
69
|
/** @internal */
|
|
58
70
|
get spatial() {
|
|
59
|
-
|
|
71
|
+
if (this._spatial) {
|
|
72
|
+
return this._spatial;
|
|
73
|
+
}
|
|
74
|
+
return this._initSpatialProperty();
|
|
60
75
|
}
|
|
61
76
|
/** @internal */
|
|
62
77
|
get stereo() {
|
|
@@ -98,6 +113,12 @@ export class _WebAudioStreamingSound extends StreamingSound {
|
|
|
98
113
|
}
|
|
99
114
|
return true;
|
|
100
115
|
}
|
|
116
|
+
_initSpatialProperty() {
|
|
117
|
+
if (!this._spatial) {
|
|
118
|
+
this._spatial = new _SpatialWebAudio(this._subGraph, this._spatialAutoUpdate, this._spatialMinUpdateTime);
|
|
119
|
+
}
|
|
120
|
+
return this._spatial;
|
|
121
|
+
}
|
|
101
122
|
}
|
|
102
123
|
_WebAudioStreamingSound._SubGraph = class extends _WebAudioBusAndSoundSubGraph {
|
|
103
124
|
get _downstreamNodes() {
|