@babylonjs/core 7.51.3 → 7.52.1
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/Audio/Interfaces/IAudioEngineOptions.d.ts +2 -0
- package/Audio/Interfaces/IAudioEngineOptions.js.map +1 -1
- package/AudioV2/abstractAudio/abstractAudioBus.d.ts +22 -0
- package/AudioV2/abstractAudio/abstractAudioBus.js +35 -0
- package/AudioV2/abstractAudio/abstractAudioBus.js.map +1 -0
- package/AudioV2/abstractAudio/abstractAudioNode.d.ts +99 -0
- package/AudioV2/abstractAudio/abstractAudioNode.js +149 -0
- package/AudioV2/abstractAudio/abstractAudioNode.js.map +1 -0
- package/AudioV2/abstractAudio/abstractSound.d.ts +152 -0
- package/AudioV2/abstractAudio/abstractSound.js +202 -0
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -0
- package/AudioV2/abstractAudio/abstractSoundInstance.d.ts +34 -0
- package/AudioV2/abstractAudio/abstractSoundInstance.js +35 -0
- package/AudioV2/abstractAudio/abstractSoundInstance.js.map +1 -0
- package/AudioV2/abstractAudio/audioBus.d.ts +48 -0
- package/AudioV2/abstractAudio/audioBus.js +53 -0
- package/AudioV2/abstractAudio/audioBus.js.map +1 -0
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +193 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +155 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -0
- package/AudioV2/abstractAudio/index.d.ts +10 -0
- package/AudioV2/abstractAudio/index.js +12 -0
- package/AudioV2/abstractAudio/index.js.map +1 -0
- package/AudioV2/abstractAudio/mainAudioBus.d.ts +22 -0
- package/AudioV2/abstractAudio/mainAudioBus.js +18 -0
- package/AudioV2/abstractAudio/mainAudioBus.js.map +1 -0
- package/AudioV2/abstractAudio/mainAudioOut.d.ts +13 -0
- package/AudioV2/abstractAudio/mainAudioOut.js +15 -0
- package/AudioV2/abstractAudio/mainAudioOut.js.map +1 -0
- package/AudioV2/abstractAudio/staticSound.d.ts +134 -0
- package/AudioV2/abstractAudio/staticSound.js +113 -0
- package/AudioV2/abstractAudio/staticSound.js.map +1 -0
- package/AudioV2/abstractAudio/staticSoundBuffer.d.ts +46 -0
- package/AudioV2/abstractAudio/staticSoundBuffer.js +17 -0
- package/AudioV2/abstractAudio/staticSoundBuffer.js.map +1 -0
- package/AudioV2/abstractAudio/staticSoundInstance.d.ts +15 -0
- package/AudioV2/abstractAudio/staticSoundInstance.js +5 -0
- package/AudioV2/abstractAudio/staticSoundInstance.js.map +1 -0
- package/AudioV2/abstractAudio/streamingSound.d.ts +77 -0
- package/AudioV2/abstractAudio/streamingSound.js +109 -0
- package/AudioV2/abstractAudio/streamingSound.js.map +1 -0
- package/AudioV2/abstractAudio/streamingSoundInstance.d.ts +25 -0
- package/AudioV2/abstractAudio/streamingSoundInstance.js +29 -0
- package/AudioV2/abstractAudio/streamingSoundInstance.js.map +1 -0
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.d.ts +53 -0
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +97 -0
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -0
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubNode.d.ts +13 -0
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubNode.js +33 -0
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubNode.js.map +1 -0
- package/AudioV2/abstractAudio/subNodes/audioSubNode.d.ts +6 -0
- package/AudioV2/abstractAudio/subNodes/audioSubNode.js +8 -0
- package/AudioV2/abstractAudio/subNodes/audioSubNode.js.map +1 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +31 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +46 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -0
- package/AudioV2/abstractAudio/subNodes/stereoAudioSubNode.d.ts +19 -0
- package/AudioV2/abstractAudio/subNodes/stereoAudioSubNode.js +27 -0
- package/AudioV2/abstractAudio/subNodes/stereoAudioSubNode.js.map +1 -0
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.d.ts +28 -0
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +24 -0
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +187 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +41 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +59 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js +21 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -0
- package/AudioV2/abstractAudio/subProperties/abstractStereoAudio.d.ts +38 -0
- package/AudioV2/abstractAudio/subProperties/abstractStereoAudio.js +18 -0
- package/AudioV2/abstractAudio/subProperties/abstractStereoAudio.js.map +1 -0
- package/AudioV2/abstractAudio/subProperties/index.d.ts +3 -0
- package/AudioV2/abstractAudio/subProperties/index.js +4 -0
- package/AudioV2/abstractAudio/subProperties/index.js.map +1 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +49 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +129 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +9 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +22 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -0
- package/AudioV2/abstractAudio/subProperties/stereoAudio.d.ts +11 -0
- package/AudioV2/abstractAudio/subProperties/stereoAudio.js +18 -0
- package/AudioV2/abstractAudio/subProperties/stereoAudio.js.map +1 -0
- package/AudioV2/audioUtils.d.ts +3 -0
- package/AudioV2/audioUtils.js +6 -0
- package/AudioV2/audioUtils.js.map +1 -0
- package/AudioV2/index.d.ts +3 -0
- package/AudioV2/index.js +5 -0
- package/AudioV2/index.js.map +1 -0
- package/AudioV2/soundState.d.ts +29 -0
- package/AudioV2/soundState.js +31 -0
- package/AudioV2/soundState.js.map +1 -0
- package/AudioV2/webAudio/index.d.ts +5 -0
- package/AudioV2/webAudio/index.js +6 -0
- package/AudioV2/webAudio/index.js.map +1 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +59 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +156 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -0
- package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.d.ts +24 -0
- package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.js +55 -0
- package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.js.map +1 -0
- package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.d.ts +24 -0
- package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.js +55 -0
- package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.js.map +1 -0
- package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.d.ts +26 -0
- package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js +54 -0
- package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js.map +1 -0
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.d.ts +21 -0
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +112 -0
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -0
- package/AudioV2/webAudio/subProperties/spatialWebAudio.d.ts +10 -0
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js +26 -0
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js.map +1 -0
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.d.ts +4 -0
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +108 -0
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -0
- package/AudioV2/webAudio/webAudioBus.d.ts +35 -0
- package/AudioV2/webAudio/webAudioBus.js +63 -0
- package/AudioV2/webAudio/webAudioBus.js.map +1 -0
- package/AudioV2/webAudio/webAudioEngine.d.ts +110 -0
- package/AudioV2/webAudio/webAudioEngine.js +227 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -0
- package/AudioV2/webAudio/webAudioMainBus.d.ts +29 -0
- package/AudioV2/webAudio/webAudioMainBus.js +64 -0
- package/AudioV2/webAudio/webAudioMainBus.js.map +1 -0
- package/AudioV2/webAudio/webAudioMainOut.d.ts +20 -0
- package/AudioV2/webAudio/webAudioMainOut.js +35 -0
- package/AudioV2/webAudio/webAudioMainOut.js.map +1 -0
- package/AudioV2/webAudio/webAudioNode.d.ts +24 -0
- package/AudioV2/webAudio/webAudioNode.js +2 -0
- package/AudioV2/webAudio/webAudioNode.js.map +1 -0
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +106 -0
- package/AudioV2/webAudio/webAudioStaticSound.js +368 -0
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -0
- package/AudioV2/webAudio/webAudioStreamingSound.d.ts +94 -0
- package/AudioV2/webAudio/webAudioStreamingSound.js +358 -0
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -0
- package/Engines/abstractEngine.d.ts +6 -1
- package/Engines/abstractEngine.js +8 -5
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.common.js +0 -4
- package/Engines/engine.common.js.map +1 -1
- package/Engines/engine.d.ts +0 -1
- package/Engines/engine.js +0 -1
- package/Engines/engine.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +33 -20
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js +4 -1
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Meshes/geometry.js +7 -15
- package/Meshes/geometry.js.map +1 -1
- package/Misc/fileTools.d.ts +3 -1
- package/Misc/fileTools.js +2 -2
- package/Misc/fileTools.js.map +1 -1
- package/Shaders/ShadersInclude/shadowMapFragment.js +1 -0
- package/Shaders/ShadersInclude/shadowMapFragment.js.map +1 -1
- package/Shaders/iblCdfDebug.fragment.js +2 -2
- package/Shaders/iblCdfDebug.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowMapFragment.js +1 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragment.js.map +1 -1
- package/ShadersWGSL/iblCdfDebug.fragment.js +2 -2
- package/ShadersWGSL/iblCdfDebug.fragment.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { Observable } from "../../Misc/observable.js";
|
|
2
|
+
import { AbstractNamedAudioNode } from "./abstractAudioNode.js";
|
|
3
|
+
import { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from "./subNodes/volumeAudioSubNode.js";
|
|
4
|
+
/**
|
|
5
|
+
* Abstract class representing a sound in the audio engine.
|
|
6
|
+
*/
|
|
7
|
+
export class AbstractSound extends AbstractNamedAudioNode {
|
|
8
|
+
constructor(name, engine, options) {
|
|
9
|
+
super(name, engine, 3 /* AudioNodeType.HAS_INPUTS_AND_OUTPUTS */); // Inputs are for instances.
|
|
10
|
+
this._newestInstance = null;
|
|
11
|
+
this._outBus = null;
|
|
12
|
+
this._privateInstances = new Set();
|
|
13
|
+
this._state = 1 /* SoundState.Stopped */;
|
|
14
|
+
this._instances = this._privateInstances;
|
|
15
|
+
this._spatialAutoUpdate = true;
|
|
16
|
+
/**
|
|
17
|
+
* Observable for when the sound stops playing.
|
|
18
|
+
*/
|
|
19
|
+
this.onEndedObservable = new Observable();
|
|
20
|
+
this._onInstanceEnded = (instance) => {
|
|
21
|
+
if (this._newestInstance === instance) {
|
|
22
|
+
this._newestInstance = null;
|
|
23
|
+
}
|
|
24
|
+
this._privateInstances.delete(instance);
|
|
25
|
+
if (this._instances.size === 0) {
|
|
26
|
+
this._state = 1 /* SoundState.Stopped */;
|
|
27
|
+
this.onEndedObservable.notifyObservers(this);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
this._onOutBusDisposed = () => {
|
|
31
|
+
this.outBus = null;
|
|
32
|
+
};
|
|
33
|
+
if (typeof options.spatialAutoUpdate === "boolean") {
|
|
34
|
+
this._spatialAutoUpdate = options.spatialAutoUpdate;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether the sound should start playing automatically. Defaults to `false`.
|
|
39
|
+
*/
|
|
40
|
+
get autoplay() {
|
|
41
|
+
return this._options.autoplay;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The current playback time of the sound, in seconds.
|
|
45
|
+
*/
|
|
46
|
+
get currentTime() {
|
|
47
|
+
const instance = this._getNewestInstance();
|
|
48
|
+
return instance ? instance.currentTime : 0;
|
|
49
|
+
}
|
|
50
|
+
set currentTime(value) {
|
|
51
|
+
this.startOffset = value;
|
|
52
|
+
const instance = this._getNewestInstance();
|
|
53
|
+
if (instance) {
|
|
54
|
+
instance.currentTime = value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether the sound should loop. Defaults to `false`.
|
|
59
|
+
*/
|
|
60
|
+
get loop() {
|
|
61
|
+
return this._options.loop;
|
|
62
|
+
}
|
|
63
|
+
set loop(value) {
|
|
64
|
+
this._options.loop = value;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The maximum number of instances that can play at the same time. Defaults to `Infinity`.
|
|
68
|
+
*/
|
|
69
|
+
get maxInstances() {
|
|
70
|
+
return this._options.maxInstances;
|
|
71
|
+
}
|
|
72
|
+
set maxInstances(value) {
|
|
73
|
+
this._options.maxInstances = value;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The output bus for the sound. Defaults to `null`.
|
|
77
|
+
* - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.
|
|
78
|
+
* @see {@link AudioEngineV2.defaultMainBus}
|
|
79
|
+
*/
|
|
80
|
+
get outBus() {
|
|
81
|
+
return this._outBus;
|
|
82
|
+
}
|
|
83
|
+
set outBus(outBus) {
|
|
84
|
+
if (this._outBus === outBus) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (this._outBus) {
|
|
88
|
+
this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);
|
|
89
|
+
if (!this._disconnect(this._outBus)) {
|
|
90
|
+
throw new Error("Disconnect failed");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
this._outBus = outBus;
|
|
94
|
+
if (this._outBus) {
|
|
95
|
+
this._outBus.onDisposeObservable.add(this._onOutBusDisposed);
|
|
96
|
+
if (!this._connect(this._outBus)) {
|
|
97
|
+
throw new Error("Connect failed");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The time within the sound buffer to start playing at, in seconds. Defaults to `0`.
|
|
103
|
+
*/
|
|
104
|
+
get startOffset() {
|
|
105
|
+
return this._options.startOffset;
|
|
106
|
+
}
|
|
107
|
+
set startOffset(value) {
|
|
108
|
+
this._options.startOffset = value;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The state of the sound.
|
|
112
|
+
*/
|
|
113
|
+
get state() {
|
|
114
|
+
return this._state;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The output volume of the sound.
|
|
118
|
+
*/
|
|
119
|
+
get volume() {
|
|
120
|
+
return _GetVolumeAudioProperty(this._subGraph, "volume");
|
|
121
|
+
}
|
|
122
|
+
set volume(value) {
|
|
123
|
+
// The volume subnode is created on initialization and should always exist.
|
|
124
|
+
const node = _GetVolumeAudioSubNode(this._subGraph);
|
|
125
|
+
if (!node) {
|
|
126
|
+
throw new Error("No volume subnode");
|
|
127
|
+
}
|
|
128
|
+
node.volume = value;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Releases associated resources.
|
|
132
|
+
*/
|
|
133
|
+
dispose() {
|
|
134
|
+
super.dispose();
|
|
135
|
+
this.stop();
|
|
136
|
+
this._newestInstance = null;
|
|
137
|
+
this._outBus = null;
|
|
138
|
+
this._privateInstances.clear();
|
|
139
|
+
this.onEndedObservable.clear();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Pauses the sound.
|
|
143
|
+
*/
|
|
144
|
+
pause() {
|
|
145
|
+
const it = this._instances.values();
|
|
146
|
+
for (let next = it.next(); !next.done; next = it.next()) {
|
|
147
|
+
next.value.pause();
|
|
148
|
+
}
|
|
149
|
+
this._state = 5 /* SoundState.Paused */;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resumes the sound.
|
|
153
|
+
*/
|
|
154
|
+
resume() {
|
|
155
|
+
if (this._state !== 5 /* SoundState.Paused */) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const it = this._instances.values();
|
|
159
|
+
for (let next = it.next(); !next.done; next = it.next()) {
|
|
160
|
+
next.value.resume();
|
|
161
|
+
}
|
|
162
|
+
this._state = 3 /* SoundState.Started */;
|
|
163
|
+
}
|
|
164
|
+
_beforePlay(instance) {
|
|
165
|
+
if (this.state === 5 /* SoundState.Paused */ && this._instances.size > 0) {
|
|
166
|
+
this.resume();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
instance.onEndedObservable.addOnce(this._onInstanceEnded);
|
|
170
|
+
this._privateInstances.add(instance);
|
|
171
|
+
this._newestInstance = instance;
|
|
172
|
+
}
|
|
173
|
+
_afterPlay(instance) {
|
|
174
|
+
this._state = instance.state;
|
|
175
|
+
}
|
|
176
|
+
_setState(state) {
|
|
177
|
+
this._state = state;
|
|
178
|
+
}
|
|
179
|
+
_stopExcessInstances() {
|
|
180
|
+
if (this.maxInstances < Infinity) {
|
|
181
|
+
const numberOfInstancesToStop = Array.from(this._instances).filter((instance) => instance.state === 3 /* SoundState.Started */).length - this.maxInstances;
|
|
182
|
+
const it = this._instances.values();
|
|
183
|
+
for (let i = 0; i < numberOfInstancesToStop; i++) {
|
|
184
|
+
const instance = it.next().value;
|
|
185
|
+
instance.stop();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
_getNewestInstance() {
|
|
190
|
+
if (this._instances.size === 0) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
if (!this._newestInstance) {
|
|
194
|
+
const it = this._instances.values();
|
|
195
|
+
for (let next = it.next(); !next.done; next = it.next()) {
|
|
196
|
+
this._newestInstance = next.value;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return this._newestInstance;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=abstractSound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/abstractSound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,sBAAsB,EAAiB,MAAM,qBAAqB,CAAC;AAM5E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAmDhG;;GAEG;AACH,MAAM,OAAgB,aAAc,SAAQ,sBAAsB;IAgB9D,YAAsB,IAAY,EAAE,MAAqB,EAAE,OAAuC;QAC9F,KAAK,CAAC,IAAI,EAAE,MAAM,+CAAuC,CAAC,CAAC,4BAA4B;QAhBnF,oBAAe,GAAqC,IAAI,CAAC;QACzD,YAAO,GAA8B,IAAI,CAAC;QAC1C,sBAAiB,GAAG,IAAI,GAAG,EAA0B,CAAC;QACtD,WAAM,8BAAkC;QAEtC,eAAU,GAAwC,IAAI,CAAC,iBAAiB,CAAC;QAEzE,uB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YAAY,CAAC;YACnJ,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,uBAAuB,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/C,MAAM,QAAQ,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;gBACjC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpB,CAAC;QACL,CAAC;IACL,CAAC;IAEO,kBAAkB;QACtB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACpC,KAAK,IAAI,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC;YACtC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;CAkBJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport type { Nullable } from \"../../types\";\nimport { SoundState } from \"../soundState\";\nimport { AbstractNamedAudioNode, AudioNodeType } from \"./abstractAudioNode\";\nimport type { _AbstractSoundInstance } from \"./abstractSoundInstance\";\nimport type { PrimaryAudioBus } from \"./audioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { _AbstractAudioSubGraph } from \"./subNodes/abstractAudioSubGraph\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\nimport { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from \"./subNodes/volumeAudioSubNode\";\nimport type { AbstractSpatialAudio, ISpatialAudioOptions } from \"./subProperties/abstractSpatialAudio\";\nimport type { AbstractStereoAudio, IStereoAudioOptions } from \"./subProperties/abstractStereoAudio\";\n\n/** @internal */\nexport interface IAbstractSoundOptionsBase {\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n autoplay: boolean;\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n maxInstances: number;\n}\n\n/** @internal */\nexport interface IAbstractSoundPlayOptionsBase {\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n loop: boolean;\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n startOffset: number;\n}\n\n/**\n * Options for creating a sound.\n */\nexport interface IAbstractSoundOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptions, ISpatialAudioOptions, IStereoAudioOptions {\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n outBus: Nullable<PrimaryAudioBus>;\n}\n\n/**\n * Options for playing a sound.\n */\nexport interface IAbstractSoundPlayOptions extends IAbstractSoundPlayOptionsBase, IVolumeAudioOptions {}\n\n/**\n * Options stored in a sound.\n * @internal\n */\nexport interface IAbstractSoundStoredOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptionsBase {}\n\n/**\n * Abstract class representing a sound in the audio engine.\n */\nexport abstract class AbstractSound extends AbstractNamedAudioNode {\n private _newestInstance: Nullable<_AbstractSoundInstance> = null;\n private _outBus: Nullable<PrimaryAudioBus> = null;\n private _privateInstances = new Set<_AbstractSoundInstance>();\n private _state: SoundState = SoundState.Stopped;\n\n protected _instances: ReadonlySet<_AbstractSoundInstance> = this._privateInstances;\n protected abstract readonly _options: IAbstractSoundStoredOptions;\n protected _spatialAutoUpdate: boolean = true;\n protected abstract _subGraph: _AbstractAudioSubGraph;\n\n /**\n * Observable for when the sound stops playing.\n */\n public readonly onEndedObservable = new Observable<AbstractSound>();\n\n protected constructor(name: string, engine: AudioEngineV2, options: Partial<IAbstractSoundOptions>) {\n super(name, engine, AudioNodeType.HAS_INPUTS_AND_OUTPUTS); // Inputs are for instances.\n\n if (typeof options.spatialAutoUpdate === \"boolean\") {\n this._spatialAutoUpdate = options.spatialAutoUpdate;\n }\n }\n\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n public get autoplay(): boolean {\n return this._options.autoplay;\n }\n\n /**\n * The current playback time of the sound, in seconds.\n */\n public get currentTime(): number {\n const instance = this._getNewestInstance();\n return instance ? instance.currentTime : 0;\n }\n\n public set currentTime(value: number) {\n this.startOffset = value;\n\n const instance = this._getNewestInstance();\n if (instance) {\n instance.currentTime = value;\n }\n }\n\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n public get loop(): boolean {\n return this._options.loop;\n }\n\n public set loop(value: boolean) {\n this._options.loop = value;\n }\n\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n public get maxInstances(): number {\n return this._options.maxInstances;\n }\n\n public set maxInstances(value: number) {\n this._options.maxInstances = value;\n }\n\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n public get outBus(): Nullable<PrimaryAudioBus> {\n return this._outBus;\n }\n\n public set outBus(outBus: Nullable<PrimaryAudioBus>) {\n if (this._outBus === outBus) {\n return;\n }\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n if (!this._disconnect(this._outBus)) {\n throw new Error(\"Disconnect failed\");\n }\n }\n\n this._outBus = outBus;\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n if (!this._connect(this._outBus)) {\n throw new Error(\"Connect failed\");\n }\n }\n }\n\n /**\n * The spatial properties of the sound.\n */\n public abstract spatial: AbstractSpatialAudio;\n\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n public get startOffset(): number {\n return this._options.startOffset;\n }\n\n public set startOffset(value: number) {\n this._options.startOffset = value;\n }\n\n /**\n * The state of the sound.\n */\n public get state(): SoundState {\n return this._state;\n }\n\n /**\n * The stereo properties of the sound.\n */\n public abstract stereo: AbstractStereoAudio;\n\n /**\n * The output volume of the sound.\n */\n public get volume(): number {\n return _GetVolumeAudioProperty(this._subGraph, \"volume\");\n }\n\n public set volume(value: number) {\n // The volume subnode is created on initialization and should always exist.\n const node = _GetVolumeAudioSubNode(this._subGraph);\n if (!node) {\n throw new Error(\"No volume subnode\");\n }\n\n node.volume = value;\n }\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n\n this.stop();\n\n this._newestInstance = null;\n this._outBus = null;\n\n this._privateInstances.clear();\n this.onEndedObservable.clear();\n }\n\n /**\n * Plays the sound.\n * - Triggers `onEndedObservable` if played for the full duration and the `loop` option is not set.\n * @param options The options to use when playing the sound. Options set here override the sound's options.\n */\n public abstract play(options?: Partial<IAbstractSoundPlayOptions>): void;\n\n /**\n * Pauses the sound.\n */\n public pause(): void {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.pause();\n }\n\n this._state = SoundState.Paused;\n }\n\n /**\n * Resumes the sound.\n */\n public resume(): void {\n if (this._state !== SoundState.Paused) {\n return;\n }\n\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.resume();\n }\n\n this._state = SoundState.Started;\n }\n\n /**\n * Stops the sound.\n * - Triggers `onEndedObservable` if the sound is playing.\n */\n public abstract stop(): void;\n\n protected _beforePlay(instance: _AbstractSoundInstance): void {\n if (this.state === SoundState.Paused && this._instances.size > 0) {\n this.resume();\n return;\n }\n\n instance.onEndedObservable.addOnce(this._onInstanceEnded);\n this._privateInstances.add(instance);\n this._newestInstance = instance;\n }\n\n protected _afterPlay(instance: _AbstractSoundInstance): void {\n this._state = instance.state;\n }\n\n protected _setState(state: SoundState): void {\n this._state = state;\n }\n\n protected abstract _createInstance(): _AbstractSoundInstance;\n\n protected _stopExcessInstances(): void {\n if (this.maxInstances < Infinity) {\n const numberOfInstancesToStop = Array.from(this._instances).filter((instance) => instance.state === SoundState.Started).length - this.maxInstances;\n const it = this._instances.values();\n\n for (let i = 0; i < numberOfInstancesToStop; i++) {\n const instance = it.next().value;\n instance.stop();\n }\n }\n }\n\n private _getNewestInstance(): Nullable<_AbstractSoundInstance> {\n if (this._instances.size === 0) {\n return null;\n }\n\n if (!this._newestInstance) {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n this._newestInstance = next.value;\n }\n }\n\n return this._newestInstance;\n }\n\n private _onInstanceEnded: (instance: _AbstractSoundInstance) => void = (instance) => {\n if (this._newestInstance === instance) {\n this._newestInstance = null;\n }\n\n this._privateInstances.delete(instance);\n\n if (this._instances.size === 0) {\n this._state = SoundState.Stopped;\n this.onEndedObservable.notifyObservers(this);\n }\n };\n\n private _onOutBusDisposed = () => {\n this.outBus = null;\n };\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Observable } from "../../Misc/observable";
|
|
2
|
+
import { SoundState } from "../soundState";
|
|
3
|
+
import { AbstractAudioNode } from "./abstractAudioNode";
|
|
4
|
+
import type { AbstractSound, IAbstractSoundPlayOptions, IAbstractSoundPlayOptionsBase } from "./abstractSound";
|
|
5
|
+
/**
|
|
6
|
+
* Options for creating a sound instance.
|
|
7
|
+
* @internal
|
|
8
|
+
* */
|
|
9
|
+
export interface IAbstractSoundInstanceOptions extends IAbstractSoundPlayOptionsBase {
|
|
10
|
+
}
|
|
11
|
+
/** @internal */
|
|
12
|
+
export declare abstract class _AbstractSoundInstance extends AbstractAudioNode {
|
|
13
|
+
protected _sound: AbstractSound;
|
|
14
|
+
protected _state: SoundState;
|
|
15
|
+
/** Observable triggered when the sound instance's playback ends */
|
|
16
|
+
readonly onEndedObservable: Observable<_AbstractSoundInstance>;
|
|
17
|
+
/** Observable triggered if the sound instance encounters an error and can not be played */
|
|
18
|
+
readonly onErrorObservable: Observable<any>;
|
|
19
|
+
/** Observable triggered when the sound instance's state changes */
|
|
20
|
+
readonly onStateChangedObservable: Observable<_AbstractSoundInstance>;
|
|
21
|
+
protected abstract readonly _options: IAbstractSoundInstanceOptions;
|
|
22
|
+
protected constructor(sound: AbstractSound);
|
|
23
|
+
abstract currentTime: number;
|
|
24
|
+
abstract readonly startTime: number;
|
|
25
|
+
/** The playback state of the sound instance */
|
|
26
|
+
get state(): SoundState;
|
|
27
|
+
/** @internal */
|
|
28
|
+
dispose(): void;
|
|
29
|
+
abstract play(options: Partial<IAbstractSoundPlayOptions>): void;
|
|
30
|
+
abstract pause(): void;
|
|
31
|
+
abstract resume(): void;
|
|
32
|
+
abstract stop(): void;
|
|
33
|
+
protected _setState(value: SoundState): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Observable } from "../../Misc/observable.js";
|
|
2
|
+
import { AbstractAudioNode } from "./abstractAudioNode.js";
|
|
3
|
+
/** @internal */
|
|
4
|
+
export class _AbstractSoundInstance extends AbstractAudioNode {
|
|
5
|
+
constructor(sound) {
|
|
6
|
+
super(sound.engine, 2 /* AudioNodeType.HAS_OUTPUTS */);
|
|
7
|
+
this._state = 1 /* SoundState.Stopped */;
|
|
8
|
+
/** Observable triggered when the sound instance's playback ends */
|
|
9
|
+
this.onEndedObservable = new Observable();
|
|
10
|
+
/** Observable triggered if the sound instance encounters an error and can not be played */
|
|
11
|
+
this.onErrorObservable = new Observable();
|
|
12
|
+
/** Observable triggered when the sound instance's state changes */
|
|
13
|
+
this.onStateChangedObservable = new Observable();
|
|
14
|
+
this._sound = sound;
|
|
15
|
+
}
|
|
16
|
+
/** The playback state of the sound instance */
|
|
17
|
+
get state() {
|
|
18
|
+
return this._state;
|
|
19
|
+
}
|
|
20
|
+
/** @internal */
|
|
21
|
+
dispose() {
|
|
22
|
+
super.dispose();
|
|
23
|
+
this.stop();
|
|
24
|
+
this.onEndedObservable.clear();
|
|
25
|
+
this.onStateChangedObservable.clear();
|
|
26
|
+
}
|
|
27
|
+
_setState(value) {
|
|
28
|
+
if (this._state === value) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this._state = value;
|
|
32
|
+
this.onStateChangedObservable.notifyObservers(this);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=abstractSoundInstance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractSoundInstance.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/abstractSoundInstance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAiB,MAAM,qBAAqB,CAAC;AASvE,gBAAgB;AAChB,MAAM,OAAgB,sBAAuB,SAAQ,iBAAiB;IAelE,YAAsB,KAAoB;QACtC,KAAK,CAAC,KAAK,CAAC,MAAM,oCAA4B,CAAC;QAdzC,WAAM,8BAAkC;QAElD,mEAAmE;QACnD,sBAAiB,GAAG,IAAI,UAAU,EAA0B,CAAC;QAE7E,2FAA2F;QAC3E,sBAAiB,GAAG,IAAI,UAAU,EAAO,CAAC;QAE1D,mEAAmE;QACnD,6BAAwB,GAAG,IAAI,UAAU,EAA0B,CAAC;QAOhF,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAMD,+CAA+C;IAC/C,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,gBAAgB;IACA,OAAO;QACnB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;IAC1C,CAAC;IAOS,SAAS,CAAC,KAAiB;QACjC,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,wBAAwB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;CACJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport { SoundState } from \"../soundState\";\nimport { AbstractAudioNode, AudioNodeType } from \"./abstractAudioNode\";\nimport type { AbstractSound, IAbstractSoundPlayOptions, IAbstractSoundPlayOptionsBase } from \"./abstractSound\";\n\n/**\n * Options for creating a sound instance.\n * @internal\n * */\nexport interface IAbstractSoundInstanceOptions extends IAbstractSoundPlayOptionsBase {}\n\n/** @internal */\nexport abstract class _AbstractSoundInstance extends AbstractAudioNode {\n protected _sound: AbstractSound;\n protected _state: SoundState = SoundState.Stopped;\n\n /** Observable triggered when the sound instance's playback ends */\n public readonly onEndedObservable = new Observable<_AbstractSoundInstance>();\n\n /** Observable triggered if the sound instance encounters an error and can not be played */\n public readonly onErrorObservable = new Observable<any>();\n\n /** Observable triggered when the sound instance's state changes */\n public readonly onStateChangedObservable = new Observable<_AbstractSoundInstance>();\n\n protected abstract readonly _options: IAbstractSoundInstanceOptions;\n\n protected constructor(sound: AbstractSound) {\n super(sound.engine, AudioNodeType.HAS_OUTPUTS);\n\n this._sound = sound;\n }\n\n public abstract currentTime: number;\n\n public abstract readonly startTime: number;\n\n /** The playback state of the sound instance */\n public get state(): SoundState {\n return this._state;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n this.stop();\n this.onEndedObservable.clear();\n this.onStateChangedObservable.clear();\n }\n\n public abstract play(options: Partial<IAbstractSoundPlayOptions>): void;\n public abstract pause(): void;\n public abstract resume(): void;\n public abstract stop(): void;\n\n protected _setState(value: SoundState) {\n if (this._state === value) {\n return;\n }\n\n this._state = value;\n this.onStateChangedObservable.notifyObservers(this);\n }\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Nullable } from "../../types";
|
|
2
|
+
import { AbstractAudioBus } from "./abstractAudioBus";
|
|
3
|
+
import type { AudioEngineV2 } from "./audioEngineV2";
|
|
4
|
+
import type { MainAudioBus } from "./mainAudioBus";
|
|
5
|
+
import type { IVolumeAudioOptions } from "./subNodes/volumeAudioSubNode";
|
|
6
|
+
import type { AbstractSpatialAudio, ISpatialAudioOptions } from "./subProperties/abstractSpatialAudio";
|
|
7
|
+
import type { AbstractStereoAudio, IStereoAudioOptions } from "./subProperties/abstractStereoAudio";
|
|
8
|
+
export type PrimaryAudioBus = MainAudioBus | AudioBus;
|
|
9
|
+
/**
|
|
10
|
+
* Options for creating an audio bus.
|
|
11
|
+
*/
|
|
12
|
+
export interface IAudioBusOptions extends ISpatialAudioOptions, IStereoAudioOptions, IVolumeAudioOptions {
|
|
13
|
+
/**
|
|
14
|
+
* The output bus of the audio bus. Defaults to the audio engine's default main bus.
|
|
15
|
+
* @see {@link AudioEngineV2.defaultMainBus}
|
|
16
|
+
*/
|
|
17
|
+
outBus: PrimaryAudioBus;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Abstract class for an audio bus that has spatial audio and stereo output capabilities.
|
|
21
|
+
*
|
|
22
|
+
* Instances of this class can be connected to other audio buses.
|
|
23
|
+
*
|
|
24
|
+
* Audio buses are created by the {@link CreateAudioBusAsync} function.
|
|
25
|
+
*/
|
|
26
|
+
export declare abstract class AudioBus extends AbstractAudioBus {
|
|
27
|
+
private _outBus;
|
|
28
|
+
protected _spatialAutoUpdate: boolean;
|
|
29
|
+
protected constructor(name: string, engine: AudioEngineV2, options: Partial<IAudioBusOptions>);
|
|
30
|
+
/**
|
|
31
|
+
* The output bus of the audio bus. Defaults to the audio engine's default main bus.
|
|
32
|
+
*/
|
|
33
|
+
get outBus(): Nullable<PrimaryAudioBus>;
|
|
34
|
+
set outBus(outBus: Nullable<PrimaryAudioBus>);
|
|
35
|
+
/**
|
|
36
|
+
* The spatial audio properties of the audio bus.
|
|
37
|
+
*/
|
|
38
|
+
abstract readonly spatial: AbstractSpatialAudio;
|
|
39
|
+
/**
|
|
40
|
+
* The stereo audio properties of the audio bus.
|
|
41
|
+
*/
|
|
42
|
+
abstract readonly stereo: AbstractStereoAudio;
|
|
43
|
+
/**
|
|
44
|
+
* Releases associated resources.
|
|
45
|
+
*/
|
|
46
|
+
dispose(): void;
|
|
47
|
+
private _onOutBusDisposed;
|
|
48
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AbstractAudioBus } from "./abstractAudioBus.js";
|
|
2
|
+
/**
|
|
3
|
+
* Abstract class for an audio bus that has spatial audio and stereo output capabilities.
|
|
4
|
+
*
|
|
5
|
+
* Instances of this class can be connected to other audio buses.
|
|
6
|
+
*
|
|
7
|
+
* Audio buses are created by the {@link CreateAudioBusAsync} function.
|
|
8
|
+
*/
|
|
9
|
+
export class AudioBus extends AbstractAudioBus {
|
|
10
|
+
constructor(name, engine, options) {
|
|
11
|
+
super(name, engine);
|
|
12
|
+
this._outBus = null;
|
|
13
|
+
this._spatialAutoUpdate = true;
|
|
14
|
+
this._onOutBusDisposed = () => {
|
|
15
|
+
this.outBus = this.engine.defaultMainBus;
|
|
16
|
+
};
|
|
17
|
+
if (typeof options.spatialAutoUpdate === "boolean") {
|
|
18
|
+
this._spatialAutoUpdate = options.spatialAutoUpdate;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The output bus of the audio bus. Defaults to the audio engine's default main bus.
|
|
23
|
+
*/
|
|
24
|
+
get outBus() {
|
|
25
|
+
return this._outBus;
|
|
26
|
+
}
|
|
27
|
+
set outBus(outBus) {
|
|
28
|
+
if (this._outBus === outBus) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (this._outBus) {
|
|
32
|
+
this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);
|
|
33
|
+
if (!this._disconnect(this._outBus)) {
|
|
34
|
+
throw new Error("Disconnect failed");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
this._outBus = outBus;
|
|
38
|
+
if (this._outBus) {
|
|
39
|
+
this._outBus.onDisposeObservable.add(this._onOutBusDisposed);
|
|
40
|
+
if (!this._connect(this._outBus)) {
|
|
41
|
+
throw new Error("Connect failed");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Releases associated resources.
|
|
47
|
+
*/
|
|
48
|
+
dispose() {
|
|
49
|
+
super.dispose();
|
|
50
|
+
this._outBus = null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=audioBus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audioBus.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/audioBus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAqBtD;;;;;;GAMG;AACH,MAAM,OAAgB,QAAS,SAAQ,gBAAgB;IAKnD,YAAsB,IAAY,EAAE,MAAqB,EAAE,OAAkC;QACzF,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QALhB,YAAO,GAA8B,IAAI,CAAC;QAExC,uBAAkB,GAAY,IAAI,CAAC;QA2DrC,sBAAiB,GAAG,GAAG,EAAE;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAC7C,CAAC,CAAC;QAxDE,IAAI,OAAO,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACjD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACxD,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAiC;QAC/C,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;YAC1B,OAAO;QACX,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAExE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACzC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAE7D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACtC,CAAC;QACL,CAAC;IACL,CAAC;IAYD;;OAEG;IACa,OAAO;QACnB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;CAKJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport { AbstractAudioBus } from \"./abstractAudioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { MainAudioBus } from \"./mainAudioBus\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\nimport type { AbstractSpatialAudio, ISpatialAudioOptions } from \"./subProperties/abstractSpatialAudio\";\nimport type { AbstractStereoAudio, IStereoAudioOptions } from \"./subProperties/abstractStereoAudio\";\n\n// NB: Secondary audio buses will be added later.\nexport type PrimaryAudioBus = MainAudioBus | AudioBus;\n\n/**\n * Options for creating an audio bus.\n */\nexport interface IAudioBusOptions extends ISpatialAudioOptions, IStereoAudioOptions, IVolumeAudioOptions {\n /**\n * The output bus of the audio bus. Defaults to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n outBus: PrimaryAudioBus;\n}\n\n/**\n * Abstract class for an audio bus that has spatial audio and stereo output capabilities.\n *\n * Instances of this class can be connected to other audio buses.\n *\n * Audio buses are created by the {@link CreateAudioBusAsync} function.\n */\nexport abstract class AudioBus extends AbstractAudioBus {\n private _outBus: Nullable<PrimaryAudioBus> = null;\n\n protected _spatialAutoUpdate: boolean = true;\n\n protected constructor(name: string, engine: AudioEngineV2, options: Partial<IAudioBusOptions>) {\n super(name, engine);\n\n if (typeof options.spatialAutoUpdate === \"boolean\") {\n this._spatialAutoUpdate = options.spatialAutoUpdate;\n }\n }\n\n /**\n * The output bus of the audio bus. Defaults to the audio engine's default main bus.\n */\n public get outBus(): Nullable<PrimaryAudioBus> {\n return this._outBus;\n }\n\n public set outBus(outBus: Nullable<PrimaryAudioBus>) {\n if (this._outBus === outBus) {\n return;\n }\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n\n if (!this._disconnect(this._outBus)) {\n throw new Error(\"Disconnect failed\");\n }\n }\n\n this._outBus = outBus;\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n\n if (!this._connect(this._outBus)) {\n throw new Error(\"Connect failed\");\n }\n }\n }\n\n /**\n * The spatial audio properties of the audio bus.\n */\n public abstract readonly spatial: AbstractSpatialAudio;\n\n /**\n * The stereo audio properties of the audio bus.\n */\n public abstract readonly stereo: AbstractStereoAudio;\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n this._outBus = null;\n }\n\n private _onOutBusDisposed = () => {\n this.outBus = this.engine.defaultMainBus;\n };\n}\n"]}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { Nullable } from "../../types";
|
|
2
|
+
import type { AbstractAudioNode, AbstractNamedAudioNode } from "./abstractAudioNode";
|
|
3
|
+
import type { AudioBus, IAudioBusOptions } from "./audioBus";
|
|
4
|
+
import type { IMainAudioBusOptions, MainAudioBus } from "./mainAudioBus";
|
|
5
|
+
import type { IStaticSoundOptions, StaticSound } from "./staticSound";
|
|
6
|
+
import type { IStaticSoundBufferOptions, StaticSoundBuffer } from "./staticSoundBuffer";
|
|
7
|
+
import type { IStreamingSoundOptions, StreamingSound } from "./streamingSound";
|
|
8
|
+
import type { AbstractSpatialAudioListener, ISpatialAudioListenerOptions } from "./subProperties/abstractSpatialAudioListener";
|
|
9
|
+
/**
|
|
10
|
+
* Gets the most recently created v2 audio engine.
|
|
11
|
+
* @returns The most recently created v2 audio engine.
|
|
12
|
+
*/
|
|
13
|
+
export declare function LastCreatedAudioEngine(): Nullable<AudioEngineV2>;
|
|
14
|
+
/**
|
|
15
|
+
* Options for creating a v2 audio engine.
|
|
16
|
+
*/
|
|
17
|
+
export interface IAudioEngineV2Options extends ISpatialAudioListenerOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The initial output volume of the audio engine. Defaults to `1`.
|
|
20
|
+
*/
|
|
21
|
+
volume: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The state of a v2 audio engine.
|
|
25
|
+
* @see {@link AudioEngineV2.state}
|
|
26
|
+
*/
|
|
27
|
+
export type AudioEngineV2State = "closed" | "interrupted" | "running" | "suspended";
|
|
28
|
+
/**
|
|
29
|
+
* Abstract base class for v2 audio engines.
|
|
30
|
+
*
|
|
31
|
+
* A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.
|
|
32
|
+
*/
|
|
33
|
+
export declare abstract class AudioEngineV2 {
|
|
34
|
+
/** Not owned, but all items should be in `_nodes` container, too, which is owned. */
|
|
35
|
+
private readonly _mainBuses;
|
|
36
|
+
/** Owned top-level sound and bus nodes. */
|
|
37
|
+
private readonly _nodes;
|
|
38
|
+
private _defaultMainBus;
|
|
39
|
+
protected _listenerAutoUpdate: boolean;
|
|
40
|
+
protected constructor(options: Partial<IAudioEngineV2Options>);
|
|
41
|
+
/**
|
|
42
|
+
* The elapsed time since the audio engine was started, in seconds.
|
|
43
|
+
*/
|
|
44
|
+
abstract readonly currentTime: number;
|
|
45
|
+
/**
|
|
46
|
+
* The default main bus that will be used for audio buses and sounds if their `outBus` option is not set.
|
|
47
|
+
* @see {@link IAudioBusOptions.outBus}
|
|
48
|
+
* @see {@link IAbstractSoundOptions.outBus}
|
|
49
|
+
*/
|
|
50
|
+
get defaultMainBus(): Nullable<MainAudioBus>;
|
|
51
|
+
/**
|
|
52
|
+
* The spatial audio listener properties for the audio engine.
|
|
53
|
+
* - Each audio engine has exactly one listener.
|
|
54
|
+
*/
|
|
55
|
+
abstract readonly listener: AbstractSpatialAudioListener;
|
|
56
|
+
/**
|
|
57
|
+
* The main output node.
|
|
58
|
+
* - This is the last node in the audio graph before the audio is sent to the speakers.
|
|
59
|
+
*/
|
|
60
|
+
abstract readonly mainOut: AbstractAudioNode;
|
|
61
|
+
/**
|
|
62
|
+
* The current state of the audio engine.
|
|
63
|
+
*
|
|
64
|
+
* Possible values are:
|
|
65
|
+
* - `"closed"`: The audio engine has been closed.
|
|
66
|
+
* - `"interrupted"`: The audio engine has been interrupted and is not running.
|
|
67
|
+
* - `"running"`: The audio engine is running normally.
|
|
68
|
+
* - `"suspended"`: The audio engine is suspended and is not running.
|
|
69
|
+
*/
|
|
70
|
+
abstract readonly state: AudioEngineV2State;
|
|
71
|
+
/**
|
|
72
|
+
* The output volume of the audio engine.
|
|
73
|
+
*/
|
|
74
|
+
abstract volume: number;
|
|
75
|
+
/**
|
|
76
|
+
* Creates a new audio bus.
|
|
77
|
+
* @param name - The name of the audio bus.
|
|
78
|
+
* @param options - The options to use when creating the audio bus.
|
|
79
|
+
* @param engine - The audio engine.
|
|
80
|
+
* @returns A promise that resolves with the created audio bus.
|
|
81
|
+
*/
|
|
82
|
+
abstract createBusAsync(name: string, options?: Partial<IAudioBusOptions>): Promise<AudioBus>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new main audio bus.
|
|
85
|
+
* @param name - The name of the main audio bus.
|
|
86
|
+
* @param options - The options to use when creating the main audio bus.
|
|
87
|
+
* @returns A promise that resolves with the created main audio bus.
|
|
88
|
+
*/
|
|
89
|
+
abstract createMainBusAsync(name: string, options?: Partial<IMainAudioBusOptions>): Promise<MainAudioBus>;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new static sound.
|
|
92
|
+
* @param name - The name of the sound.
|
|
93
|
+
* @param source - The source of the sound.
|
|
94
|
+
* @param options - The options for the static sound.
|
|
95
|
+
* @returns A promise that resolves to the created static sound.
|
|
96
|
+
*/
|
|
97
|
+
abstract createSoundAsync(name: string, source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[], options?: Partial<IStaticSoundOptions>): Promise<StaticSound>;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a new static sound buffer.
|
|
100
|
+
* @param source - The source of the sound buffer.
|
|
101
|
+
* @param options - The options for the static sound buffer.
|
|
102
|
+
* @param engine - The audio engine.
|
|
103
|
+
* @returns A promise that resolves to the created static sound buffer.
|
|
104
|
+
*/
|
|
105
|
+
abstract createSoundBufferAsync(source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[], options?: Partial<IStaticSoundBufferOptions>): Promise<StaticSoundBuffer>;
|
|
106
|
+
/**
|
|
107
|
+
* Creates a new streaming sound.
|
|
108
|
+
* @param name - The name of the sound.
|
|
109
|
+
* @param source - The source of the sound.
|
|
110
|
+
* @param options - The options for the streaming sound.
|
|
111
|
+
* @returns A promise that resolves to the created streaming sound.
|
|
112
|
+
*/
|
|
113
|
+
abstract createStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options?: Partial<IStreamingSoundOptions>): Promise<StreamingSound>;
|
|
114
|
+
/**
|
|
115
|
+
* Releases associated resources.
|
|
116
|
+
*/
|
|
117
|
+
dispose(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Checks if the specified format is valid.
|
|
120
|
+
* @param format The format to check as an audio file extension like "mp3" or "wav".
|
|
121
|
+
* @returns `true` if the format is valid; otherwise `false`.
|
|
122
|
+
*/
|
|
123
|
+
abstract isFormatValid(format: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Pauses the audio engine if it is running.
|
|
126
|
+
* @returns A promise that resolves when the audio engine is paused.
|
|
127
|
+
*/
|
|
128
|
+
abstract pause(): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Resumes the audio engine if it is not running.
|
|
131
|
+
* @returns A promise that resolves when the audio engine is running.
|
|
132
|
+
*/
|
|
133
|
+
abstract resume(): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Unlocks the audio engine if it is locked.
|
|
136
|
+
* - Note that the returned promise may already be resolved if the audio engine is already unlocked.
|
|
137
|
+
* @returns A promise that is resolved when the audio engine is unlocked.
|
|
138
|
+
*/
|
|
139
|
+
unlock(): Promise<void>;
|
|
140
|
+
protected _addMainBus(mainBus: MainAudioBus): void;
|
|
141
|
+
protected _removeMainBus(mainBus: MainAudioBus): void;
|
|
142
|
+
protected _addNode(node: AbstractNamedAudioNode): void;
|
|
143
|
+
protected _removeNode(node: AbstractNamedAudioNode): void;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @internal
|
|
147
|
+
* @param engine - The given audio engine. If `null` then the last created audio engine is used.
|
|
148
|
+
* @returns the given audio engine or the last created audio engine.
|
|
149
|
+
* @throws An error if the resulting engine is `null`.
|
|
150
|
+
*/
|
|
151
|
+
export declare function _GetAudioEngine(engine: Nullable<AudioEngineV2>): AudioEngineV2;
|
|
152
|
+
/**
|
|
153
|
+
* Creates a new audio bus.
|
|
154
|
+
* @param name - The name of the audio bus.
|
|
155
|
+
* @param options - The options to use when creating the audio bus.
|
|
156
|
+
* @param engine - The audio engine.
|
|
157
|
+
* @returns A promise that resolves with the created audio bus.
|
|
158
|
+
*/
|
|
159
|
+
export declare function CreateAudioBusAsync(name: string, options?: Partial<IAudioBusOptions>, engine?: Nullable<AudioEngineV2>): Promise<AudioBus>;
|
|
160
|
+
/**
|
|
161
|
+
* Creates a new main audio bus.
|
|
162
|
+
* @param name - The name of the main audio bus.
|
|
163
|
+
* @param options - The options to use when creating the main audio bus.
|
|
164
|
+
* @param engine - The audio engine.
|
|
165
|
+
* @returns A promise that resolves with the created main audio bus.
|
|
166
|
+
*/
|
|
167
|
+
export declare function CreateMainAudioBusAsync(name: string, options?: Partial<IMainAudioBusOptions>, engine?: Nullable<AudioEngineV2>): Promise<MainAudioBus>;
|
|
168
|
+
/**
|
|
169
|
+
* Creates a new static sound.
|
|
170
|
+
* @param name - The name of the sound.
|
|
171
|
+
* @param source - The source of the sound.
|
|
172
|
+
* @param options - The options for the static sound.
|
|
173
|
+
* @param engine - The audio engine.
|
|
174
|
+
* @returns A promise that resolves to the created static sound.
|
|
175
|
+
*/
|
|
176
|
+
export declare function CreateSoundAsync(name: string, source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[], options?: Partial<IStaticSoundOptions>, engine?: Nullable<AudioEngineV2>): Promise<StaticSound>;
|
|
177
|
+
/**
|
|
178
|
+
* Creates a new static sound buffer.
|
|
179
|
+
* @param source - The source of the sound buffer.
|
|
180
|
+
* @param options - The options for the static sound buffer.
|
|
181
|
+
* @param engine - The audio engine.
|
|
182
|
+
* @returns A promise that resolves to the created static sound buffer.
|
|
183
|
+
*/
|
|
184
|
+
export declare function CreateSoundBufferAsync(source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[], options?: Partial<IStaticSoundBufferOptions>, engine?: Nullable<AudioEngineV2>): Promise<StaticSoundBuffer>;
|
|
185
|
+
/**
|
|
186
|
+
* Creates a new streaming sound.
|
|
187
|
+
* @param name - The name of the sound.
|
|
188
|
+
* @param source - The source of the sound.
|
|
189
|
+
* @param options - The options for the streaming sound.
|
|
190
|
+
* @param engine - The audio engine.
|
|
191
|
+
* @returns A promise that resolves to the created streaming sound.
|
|
192
|
+
*/
|
|
193
|
+
export declare function CreateStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options?: Partial<IStreamingSoundOptions>, engine?: Nullable<AudioEngineV2>): Promise<StreamingSound>;
|