@babylonjs/core 6.12.0 → 6.12.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/Audio/sound.d.ts CHANGED
@@ -120,6 +120,8 @@ export declare class Sound {
120
120
  private _urlType;
121
121
  private _length?;
122
122
  private _offset?;
123
+ private _tryToPlayTimeout;
124
+ private _audioUnlockedObserver?;
123
125
  /**
124
126
  * @internal
125
127
  */
@@ -306,4 +308,5 @@ export declare class Sound {
306
308
  */
307
309
  static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
308
310
  private _setOffset;
311
+ private _clearTimeoutsAndObservers;
309
312
  }
package/Audio/sound.js CHANGED
@@ -373,6 +373,7 @@ export class Sound {
373
373
  this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
374
374
  this._connectedTransformNode = null;
375
375
  }
376
+ this._clearTimeoutsAndObservers();
376
377
  }
377
378
  }
378
379
  /**
@@ -668,6 +669,7 @@ export class Sound {
668
669
  var _a, _b, _c, _d;
669
670
  if (this._isReadyToPlay && this._scene.audioEnabled && ((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.audioContext)) {
670
671
  try {
672
+ this._clearTimeoutsAndObservers();
671
673
  let startTime = time ? ((_b = Engine.audioEngine) === null || _b === void 0 ? void 0 : _b.audioContext.currentTime) + time : (_c = Engine.audioEngine) === null || _c === void 0 ? void 0 : _c.audioContext.currentTime;
672
674
  if (!this._soundSource || !this._streamingSource) {
673
675
  if (this._spatialSound && this._soundPanner) {
@@ -719,7 +721,7 @@ export class Sound {
719
721
  // Waiting for the audio engine to be unlocked by user click on unmute
720
722
  (_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.lock();
721
723
  if (this.loop || this.autoplay) {
722
- (_b = Engine.audioEngine) === null || _b === void 0 ? void 0 : _b.onAudioUnlockedObservable.addOnce(() => {
724
+ this._audioUnlockedObserver = (_b = Engine.audioEngine) === null || _b === void 0 ? void 0 : _b.onAudioUnlockedObservable.addOnce(() => {
723
725
  tryToPlay();
724
726
  });
725
727
  }
@@ -728,7 +730,7 @@ export class Sound {
728
730
  }
729
731
  else {
730
732
  if (this.loop || this.autoplay) {
731
- (_b = Engine.audioEngine) === null || _b === void 0 ? void 0 : _b.onAudioUnlockedObservable.addOnce(() => {
733
+ this._audioUnlockedObserver = (_b = Engine.audioEngine) === null || _b === void 0 ? void 0 : _b.onAudioUnlockedObservable.addOnce(() => {
732
734
  tryToPlay();
733
735
  });
734
736
  }
@@ -774,14 +776,14 @@ export class Sound {
774
776
  };
775
777
  if (((_d = Engine.audioEngine) === null || _d === void 0 ? void 0 : _d.audioContext.state) === "suspended") {
776
778
  // Wait a bit for FF as context seems late to be ready.
777
- setTimeout(() => {
779
+ this._tryToPlayTimeout = setTimeout(() => {
778
780
  var _a;
779
781
  if (((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.audioContext.state) === "suspended") {
780
782
  // Automatic playback failed.
781
783
  // Waiting for the audio engine to be unlocked by user click on unmute
782
784
  Engine.audioEngine.lock();
783
785
  if (this.loop || this.autoplay) {
784
- Engine.audioEngine.onAudioUnlockedObservable.addOnce(() => {
786
+ this._audioUnlockedObserver = Engine.audioEngine.onAudioUnlockedObservable.addOnce(() => {
785
787
  tryToPlay();
786
788
  });
787
789
  }
@@ -820,6 +822,7 @@ export class Sound {
820
822
  stop(time) {
821
823
  var _a;
822
824
  if (this.isPlaying) {
825
+ this._clearTimeoutsAndObservers();
823
826
  if (this._streaming) {
824
827
  if (this._htmlAudioElement) {
825
828
  this._htmlAudioElement.pause();
@@ -847,6 +850,9 @@ export class Sound {
847
850
  };
848
851
  this._soundSource.stop(stopTime);
849
852
  }
853
+ else {
854
+ this.isPlaying = false;
855
+ }
850
856
  }
851
857
  else if (this.isPaused) {
852
858
  this.isPaused = false;
@@ -860,6 +866,7 @@ export class Sound {
860
866
  pause() {
861
867
  var _a;
862
868
  if (this.isPlaying) {
869
+ this._clearTimeoutsAndObservers();
863
870
  if (this._streaming) {
864
871
  if (this._htmlAudioElement) {
865
872
  this._htmlAudioElement.pause();
@@ -1158,6 +1165,17 @@ export class Sound {
1158
1165
  }
1159
1166
  this._offset = value;
1160
1167
  }
1168
+ _clearTimeoutsAndObservers() {
1169
+ var _a;
1170
+ if (this._tryToPlayTimeout) {
1171
+ clearTimeout(this._tryToPlayTimeout);
1172
+ this._tryToPlayTimeout = null;
1173
+ }
1174
+ if (this._audioUnlockedObserver) {
1175
+ (_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.onAudioUnlockedObservable.remove(this._audioUnlockedObserver);
1176
+ this._audioUnlockedObserver = null;
1177
+ }
1178
+ }
1161
1179
  }
1162
1180
  /**
1163
1181
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"sound.js","sourceRoot":"","sources":["../../../../dev/core/src/Audio/sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAWd;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI,CAAC,KAAc;QAC1B,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE;YACtB,OAAO;SACV;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAA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a,GAAG,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;YACrE,IAAI,aAAa,EAAE;gBACf,QAAQ,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;aACxC;SACJ;QAED,IAAI,WAAW,CAAC,QAAQ,EAAE;YACtB,QAAQ,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;SAC5C;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,UAAU,CAAC,KAAc;QAC7B,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE;YACxB,OAAO;SACV;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACzB;QACD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB,CAAC;;AA5jCD;;GAEG;AACW,mCAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAC7C,CAAC,AAF0C,CAEzC","sourcesContent":["import { Tools } from \"../Misc/tools\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { ISoundOptions } from \"./Interfaces/ISoundOptions\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n/**\r\n * Defines a sound that can be played in the application.\r\n * The sound can either be an ambient track or a simple sound played in reaction to a user action.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\nexport class Sound {\r\n /**\r\n * The name of the sound in the scene.\r\n */\r\n public name: string;\r\n /**\r\n * Does the sound autoplay once loaded.\r\n */\r\n public autoplay: boolean = false;\r\n\r\n private _loop = false;\r\n /**\r\n * Does the sound loop after it finishes playing once.\r\n */\r\n public get loop(): boolean {\r\n return this._loop;\r\n }\r\n\r\n public set loop(value: boolean) {\r\n if (value === this._loop) {\r\n return;\r\n }\r\n\r\n this._loop = value;\r\n this.updateOptions({ loop: value });\r\n }\r\n\r\n /**\r\n * Does the sound use a custom attenuation curve to simulate the falloff\r\n * happening when the source gets further away from the camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function\r\n */\r\n public useCustomAttenuation: boolean = false;\r\n /**\r\n * The sound track id this sound belongs to.\r\n */\r\n public soundTrackId: number;\r\n /**\r\n * Is this sound currently played.\r\n */\r\n public isPlaying: boolean = false;\r\n /**\r\n * Is this sound currently paused.\r\n */\r\n public isPaused: boolean = false;\r\n /**\r\n * Define the reference distance the sound should be heard perfectly.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public refDistance: number = 1;\r\n /**\r\n * Define the roll off factor of spatial sounds.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public rolloffFactor: number = 1;\r\n /**\r\n * Define the max distance the sound should be heard (intensity just became 0 at this point).\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public maxDistance: number = 100;\r\n /**\r\n * Define the distance attenuation model the sound will follow.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public distanceModel: string = \"linear\";\r\n /**\r\n * @internal\r\n * Back Compat\r\n **/\r\n public onended: () => any;\r\n /**\r\n * Gets or sets an object used to store user defined information for the sound.\r\n */\r\n public metadata: any = null;\r\n\r\n /**\r\n * Observable event when the current playing sound finishes.\r\n */\r\n public onEndedObservable = new Observable<Sound>();\r\n\r\n /**\r\n * Gets the current time for the sound.\r\n */\r\n public get currentTime(): number {\r\n if (this._htmlAudioElement) {\r\n return this._htmlAudioElement.currentTime;\r\n }\r\n\r\n if (Engine.audioEngine?.audioContext && (this.isPlaying || this.isPaused)) {\r\n // The `_currentTime` member is only updated when the sound is paused. Add the time since the last start\r\n // to get the actual current time.\r\n const timeSinceLastStart = this.isPaused ? 0 : Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n return this._currentTime + timeSinceLastStart;\r\n }\r\n\r\n return 0;\r\n }\r\n\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public get spatialSound(): boolean {\r\n return this._spatialSound;\r\n }\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public set spatialSound(newValue: boolean) {\r\n this._spatialSound = newValue;\r\n if (this._spatialSound && Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._createSpatialParameters();\r\n }\r\n }\r\n private _spatialSound: boolean = false;\r\n private _panningModel: string = \"equalpower\";\r\n private _playbackRate: number = 1;\r\n private _streaming: boolean = false;\r\n private _startTime: number = 0;\r\n private _currentTime: number = 0;\r\n private _position: Vector3 = Vector3.Zero();\r\n private _localDirection: Vector3 = new Vector3(1, 0, 0);\r\n private _volume: number = 1;\r\n private _isReadyToPlay: boolean = false;\r\n private _isDirectional: boolean = false;\r\n private _readyToPlayCallback: Nullable<() => any>;\r\n private _audioBuffer: Nullable<AudioBuffer>;\r\n private _soundSource: Nullable<AudioBufferSourceNode>;\r\n private _streamingSource: AudioNode;\r\n private _soundPanner: Nullable<PannerNode>;\r\n private _soundGain: Nullable<GainNode>;\r\n private _inputAudioNode: Nullable<AudioNode>;\r\n private _outputAudioNode: Nullable<AudioNode>;\r\n // Used if you'd like to create a directional sound.\r\n // If not set, the sound will be omnidirectional\r\n private _coneInnerAngle: number = 360;\r\n private _coneOuterAngle: number = 360;\r\n private _coneOuterGain: number = 0;\r\n private _scene: Scene;\r\n private _connectedTransformNode: Nullable<TransformNode>;\r\n private _customAttenuationFunction: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number;\r\n private _registerFunc: Nullable<(connectedMesh: TransformNode) => void>;\r\n private _isOutputConnected = false;\r\n private _htmlAudioElement: HTMLAudioElement;\r\n private _urlType: \"Unknown\" | \"String\" | \"Array\" | \"ArrayBuffer\" | \"MediaStream\" | \"AudioBuffer\" | \"MediaElement\" = \"Unknown\";\r\n private _length?: number;\r\n private _offset?: number;\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"AudioSceneComponent\");\r\n };\r\n\r\n /**\r\n * Create a sound and attach it to a scene\r\n * @param name Name of your sound\r\n * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams and AudioBuffers\r\n * @param scene defines the scene the sound belongs to\r\n * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played\r\n * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming\r\n */\r\n constructor(name: string, urlOrArrayBuffer: any, scene?: Nullable<Scene>, readyToPlayCallback: Nullable<() => void> = null, options?: ISoundOptions) {\r\n this.name = name;\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n Sound._SceneComponentInitialization(scene);\r\n\r\n this._readyToPlayCallback = readyToPlayCallback;\r\n // Default custom attenuation function is a linear attenuation\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n this._customAttenuationFunction = (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => {\r\n if (currentDistance < maxDistance) {\r\n return currentVolume * (1 - currentDistance / maxDistance);\r\n } else {\r\n return 0;\r\n }\r\n };\r\n if (options) {\r\n this.autoplay = options.autoplay || false;\r\n this._loop = options.loop || false;\r\n // if volume === 0, we need another way to check this option\r\n if (options.volume !== undefined) {\r\n this._volume = options.volume;\r\n }\r\n this._spatialSound = options.spatialSound ?? false;\r\n this.maxDistance = options.maxDistance ?? 100;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? false;\r\n this.rolloffFactor = options.rolloffFactor || 1;\r\n this.refDistance = options.refDistance || 1;\r\n this.distanceModel = options.distanceModel || \"linear\";\r\n this._playbackRate = options.playbackRate || 1;\r\n this._streaming = options.streaming ?? false;\r\n this._length = options.length;\r\n this._offset = options.offset;\r\n }\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._soundGain = Engine.audioEngine.audioContext.createGain();\r\n this._soundGain!.gain.value = this._volume;\r\n this._inputAudioNode = this._soundGain;\r\n this._outputAudioNode = this._soundGain;\r\n if (this._spatialSound) {\r\n this._createSpatialParameters();\r\n }\r\n this._scene.mainSoundTrack.addSound(this);\r\n let validParameter = true;\r\n\r\n // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound\r\n if (urlOrArrayBuffer) {\r\n try {\r\n if (typeof urlOrArrayBuffer === \"string\") {\r\n this._urlType = \"String\";\r\n } else if (urlOrArrayBuffer instanceof ArrayBuffer) {\r\n this._urlType = \"ArrayBuffer\";\r\n } else if (urlOrArrayBuffer instanceof HTMLMediaElement) {\r\n this._urlType = \"MediaElement\";\r\n } else if (urlOrArrayBuffer instanceof MediaStream) {\r\n this._urlType = \"MediaStream\";\r\n } else if (urlOrArrayBuffer instanceof AudioBuffer) {\r\n this._urlType = \"AudioBuffer\";\r\n } else if (Array.isArray(urlOrArrayBuffer)) {\r\n this._urlType = \"Array\";\r\n }\r\n\r\n let urls: string[] = [];\r\n let codecSupportedFound = false;\r\n\r\n switch (this._urlType) {\r\n case \"MediaElement\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"MediaStream\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaStreamSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"ArrayBuffer\":\r\n if ((<ArrayBuffer>urlOrArrayBuffer).byteLength > 0) {\r\n codecSupportedFound = true;\r\n this._soundLoaded(urlOrArrayBuffer);\r\n }\r\n break;\r\n case \"AudioBuffer\":\r\n this._audioBufferLoaded(urlOrArrayBuffer);\r\n break;\r\n case \"String\":\r\n urls.push(urlOrArrayBuffer);\r\n // eslint-disable-next-line no-fallthrough\r\n case \"Array\":\r\n if (urls.length === 0) {\r\n urls = urlOrArrayBuffer;\r\n }\r\n // If we found a supported format, we load it immediately and stop the loop\r\n for (let i = 0; i < urls.length; i++) {\r\n const url = urls[i];\r\n codecSupportedFound =\r\n (options && options.skipCodecCheck) ||\r\n (url.indexOf(\".mp3\", url.length - 4) !== -1 && Engine.audioEngine.isMP3supported) ||\r\n (url.indexOf(\".ogg\", url.length - 4) !== -1 && Engine.audioEngine.isOGGsupported) ||\r\n url.indexOf(\".wav\", url.length - 4) !== -1 ||\r\n url.indexOf(\".m4a\", url.length - 4) !== -1 ||\r\n url.indexOf(\".mp4\", url.length - 4) !== -1 ||\r\n url.indexOf(\"blob:\") !== -1;\r\n if (codecSupportedFound) {\r\n // Loading sound\r\n if (!this._streaming) {\r\n this._scene._loadFile(\r\n url,\r\n (data) => {\r\n this._soundLoaded(data as ArrayBuffer);\r\n },\r\n undefined,\r\n true,\r\n true,\r\n (exception) => {\r\n if (exception) {\r\n Logger.Error(\"XHR \" + exception.status + \" error on: \" + url + \".\");\r\n }\r\n Logger.Error(\"Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n );\r\n }\r\n // Streaming sound using HTML5 Audio tag\r\n else {\r\n this._htmlAudioElement = new Audio(url);\r\n this._htmlAudioElement.controls = false;\r\n this._htmlAudioElement.loop = this.loop;\r\n Tools.SetCorsBehavior(url, this._htmlAudioElement);\r\n this._htmlAudioElement.preload = \"auto\";\r\n this._htmlAudioElement.addEventListener(\"canplaythrough\", () => {\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n });\r\n document.body.appendChild(this._htmlAudioElement);\r\n this._htmlAudioElement.load();\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n default:\r\n validParameter = false;\r\n break;\r\n }\r\n\r\n if (!validParameter) {\r\n Logger.Error(\"Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.\");\r\n } else {\r\n if (!codecSupportedFound) {\r\n this._isReadyToPlay = true;\r\n // Simulating a ready to play event to avoid breaking code path\r\n if (this._readyToPlayCallback) {\r\n setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n } catch (ex) {\r\n Logger.Error(\"Unexpected error. Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n }\r\n } else {\r\n // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers\r\n this._scene.mainSoundTrack.addSound(this);\r\n if (Engine.audioEngine && !Engine.audioEngine.WarnedWebAudioUnsupported) {\r\n Logger.Error(\"Web Audio is not supported by your browser.\");\r\n Engine.audioEngine.WarnedWebAudioUnsupported = true;\r\n }\r\n // Simulating a ready to play event to avoid breaking code for non web audio browsers\r\n if (this._readyToPlayCallback) {\r\n setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release the sound and its associated resources\r\n */\r\n public dispose() {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n if (this.isPlaying) {\r\n this.stop();\r\n }\r\n this._isReadyToPlay = false;\r\n if (this.soundTrackId === -1) {\r\n this._scene.mainSoundTrack.removeSound(this);\r\n } else if (this._scene.soundTracks) {\r\n this._scene.soundTracks[this.soundTrackId].removeSound(this);\r\n }\r\n if (this._soundGain) {\r\n this._soundGain.disconnect();\r\n this._soundGain = null;\r\n }\r\n if (this._soundPanner) {\r\n this._soundPanner.disconnect();\r\n this._soundPanner = null;\r\n }\r\n if (this._soundSource) {\r\n this._soundSource.disconnect();\r\n this._soundSource = null;\r\n }\r\n this._audioBuffer = null;\r\n\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n this._htmlAudioElement.src = \"\";\r\n document.body.removeChild(this._htmlAudioElement);\r\n }\r\n\r\n if (this._streamingSource) {\r\n this._streamingSource.disconnect();\r\n }\r\n\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the sounds is ready to be played or not.\r\n * @returns true if ready, otherwise false\r\n */\r\n public isReady(): boolean {\r\n return this._isReadyToPlay;\r\n }\r\n\r\n /**\r\n * Get the current class name.\r\n * @returns current class name\r\n */\r\n public getClassName(): string {\r\n return \"Sound\";\r\n }\r\n\r\n private _audioBufferLoaded(buffer: AudioBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n this._audioBuffer = buffer;\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }\r\n\r\n private _soundLoaded(audioData: ArrayBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n Engine.audioEngine.audioContext.decodeAudioData(\r\n audioData,\r\n (buffer) => {\r\n this._audioBufferLoaded(buffer);\r\n },\r\n (err: any) => {\r\n Logger.Error(\"Error while decoding audio data for: \" + this.name + \" / Error: \" + err);\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Sets the data of the sound from an audiobuffer\r\n * @param audioBuffer The audioBuffer containing the data\r\n */\r\n public setAudioBuffer(audioBuffer: AudioBuffer): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n this._audioBuffer = audioBuffer;\r\n this._isReadyToPlay = true;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the current sounds options such as maxdistance, loop...\r\n * @param options A JSON object containing values named as the object properties\r\n */\r\n public updateOptions(options: ISoundOptions): void {\r\n if (options) {\r\n this.loop = options.loop ?? this.loop;\r\n this.maxDistance = options.maxDistance ?? this.maxDistance;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? this.useCustomAttenuation;\r\n this.rolloffFactor = options.rolloffFactor ?? this.rolloffFactor;\r\n this.refDistance = options.refDistance ?? this.refDistance;\r\n this.distanceModel = options.distanceModel ?? this.distanceModel;\r\n this._playbackRate = options.playbackRate ?? this._playbackRate;\r\n this._length = options.length ?? undefined;\r\n this._setOffset(options.offset ?? undefined);\r\n this.setVolume(options.volume ?? this._volume);\r\n this._updateSpatialParameters();\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n if (this._htmlAudioElement.loop !== this.loop) {\r\n this._htmlAudioElement.loop = this.loop;\r\n }\r\n } else {\r\n if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n if (this._soundSource.loop !== this.loop) {\r\n this._soundSource.loop = this.loop;\r\n }\r\n if (this._offset !== undefined && this._soundSource.loopStart !== this._offset) {\r\n this._soundSource.loopStart = this._offset;\r\n }\r\n if (this._length !== undefined && this._length !== this._soundSource.loopEnd) {\r\n this._soundSource.loopEnd = (this._offset! | 0) + this._length!;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _createSpatialParameters() {\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n if (this._scene.headphone) {\r\n this._panningModel = \"HRTF\";\r\n }\r\n this._soundPanner = this._soundPanner ?? Engine.audioEngine.audioContext.createPanner();\r\n if (this._soundPanner && this._outputAudioNode) {\r\n this._updateSpatialParameters();\r\n this._soundPanner.connect(this._outputAudioNode);\r\n this._inputAudioNode = this._soundPanner;\r\n }\r\n }\r\n }\r\n\r\n private _updateSpatialParameters() {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (this.useCustomAttenuation) {\r\n // Tricks to disable in a way embedded Web Audio attenuation\r\n this._soundPanner.distanceModel = \"linear\";\r\n this._soundPanner.maxDistance = Number.MAX_VALUE;\r\n this._soundPanner.refDistance = 1;\r\n this._soundPanner.rolloffFactor = 1;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n } else {\r\n this._soundPanner.distanceModel = this.distanceModel as any;\r\n this._soundPanner.maxDistance = this.maxDistance;\r\n this._soundPanner.refDistance = this.refDistance;\r\n this._soundPanner.rolloffFactor = this.rolloffFactor;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to HRTF:\r\n * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToHRTF() {\r\n this._panningModel = \"HRTF\";\r\n this._switchPanningModel();\r\n }\r\n\r\n /**\r\n * Switch the panning model to Equal Power:\r\n * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToEqualPower() {\r\n this._panningModel = \"equalpower\";\r\n this._switchPanningModel();\r\n }\r\n\r\n private _switchPanningModel() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n\r\n /**\r\n * Connect this sound to a sound track audio node like gain...\r\n * @param soundTrackAudioNode the sound track audio node to connect to\r\n */\r\n public connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n if (this._isOutputConnected) {\r\n this._outputAudioNode.disconnect();\r\n }\r\n this._outputAudioNode.connect(soundTrackAudioNode);\r\n this._isOutputConnected = true;\r\n }\r\n }\r\n\r\n /**\r\n * Transform this sound into a directional source\r\n * @param coneInnerAngle Size of the inner cone in degree\r\n * @param coneOuterAngle Size of the outer cone in degree\r\n * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)\r\n */\r\n public setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void {\r\n if (coneOuterAngle < coneInnerAngle) {\r\n Logger.Error(\"setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n this._coneInnerAngle = coneInnerAngle;\r\n this._coneOuterAngle = coneOuterAngle;\r\n this._coneOuterGain = coneOuterGain;\r\n this._isDirectional = true;\r\n\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public get directionalConeInnerAngle(): number {\r\n return this._coneInnerAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public set directionalConeInnerAngle(value: number) {\r\n if (value != this._coneInnerAngle) {\r\n if (this._coneOuterAngle < value) {\r\n Logger.Error(\"directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneInnerAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public get directionalConeOuterAngle(): number {\r\n return this._coneOuterAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public set directionalConeOuterAngle(value: number) {\r\n if (value != this._coneOuterAngle) {\r\n if (value < this._coneInnerAngle) {\r\n Logger.Error(\"directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneOuterAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the position of the emitter if spatial sound is enabled\r\n * @param newPosition Defines the new position\r\n */\r\n public setPosition(newPosition: Vector3): void {\r\n if (newPosition.equals(this._position)) {\r\n return;\r\n }\r\n this._position.copyFrom(newPosition);\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n }\r\n\r\n /**\r\n * Sets the local direction of the emitter if spatial sound is enabled\r\n * @param newLocalDirection Defines the new local direction\r\n */\r\n public setLocalDirectionToMesh(newLocalDirection: Vector3): void {\r\n this._localDirection = newLocalDirection;\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n private _updateDirection() {\r\n if (!this._connectedTransformNode || !this._soundPanner) {\r\n return;\r\n }\r\n\r\n const mat = this._connectedTransformNode.getWorldMatrix();\r\n const direction = Vector3.TransformNormal(this._localDirection, mat);\r\n direction.normalize();\r\n this._soundPanner.orientationX.value = direction.x;\r\n this._soundPanner.orientationY.value = direction.y;\r\n this._soundPanner.orientationZ.value = direction.z;\r\n }\r\n\r\n /** @internal */\r\n public updateDistanceFromListener() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {\r\n const distance = this._scene.audioListenerPositionProvider\r\n ? this._connectedTransformNode.position.subtract(this._scene.audioListenerPositionProvider()).length()\r\n : this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);\r\n this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);\r\n }\r\n }\r\n\r\n /**\r\n * Sets a new custom attenuation function for the sound.\r\n * @param callback Defines the function used for the attenuation\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function\r\n */\r\n public setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void {\r\n this._customAttenuationFunction = callback;\r\n }\r\n\r\n /**\r\n * Play the sound\r\n * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.\r\n * @param offset (optional) Start the sound at a specific time in seconds\r\n * @param length (optional) Sound duration (in seconds)\r\n */\r\n public play(time?: number, offset?: number, length?: number): void {\r\n if (this._isReadyToPlay && this._scene.audioEnabled && Engine.audioEngine?.audioContext) {\r\n try {\r\n let startTime = time ? Engine.audioEngine?.audioContext.currentTime + time : Engine.audioEngine?.audioContext.currentTime;\r\n if (!this._soundSource || !this._streamingSource) {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n if (this._isDirectional) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n this._soundPanner.coneOuterGain = this._coneOuterGain;\r\n if (this._connectedTransformNode) {\r\n this._updateDirection();\r\n } else {\r\n this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);\r\n }\r\n }\r\n }\r\n }\r\n if (this._streaming) {\r\n if (!this._streamingSource) {\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);\r\n this._htmlAudioElement.onended = () => {\r\n this._onended();\r\n };\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n }\r\n this._streamingSource.disconnect();\r\n if (this._inputAudioNode) {\r\n this._streamingSource.connect(this._inputAudioNode);\r\n }\r\n if (this._htmlAudioElement) {\r\n // required to manage properly the new suspended default state of Chrome\r\n // When the option 'streaming: true' is used, we need first to wait for\r\n // the audio engine to be unlocked by a user gesture before trying to play\r\n // an HTML Audio element\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.unlocked) {\r\n const playPromise = this._htmlAudioElement.play();\r\n\r\n // In browsers that don’t yet support this functionality,\r\n // playPromise won’t be defined.\r\n if (playPromise !== undefined) {\r\n playPromise.catch(() => {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine?.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n });\r\n }\r\n } else {\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n }\r\n };\r\n tryToPlay();\r\n }\r\n } else {\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.audioContext) {\r\n length = length || this._length;\r\n\r\n if (offset !== undefined) {\r\n this._setOffset(offset);\r\n }\r\n\r\n if (this._soundSource) {\r\n const oldSource = this._soundSource;\r\n oldSource.onended = () => {\r\n oldSource.disconnect();\r\n };\r\n }\r\n this._soundSource = Engine.audioEngine?.audioContext.createBufferSource();\r\n if (this._soundSource && this._inputAudioNode) {\r\n this._soundSource.buffer = this._audioBuffer;\r\n this._soundSource.connect(this._inputAudioNode);\r\n this._soundSource.loop = this.loop;\r\n if (offset !== undefined) {\r\n this._soundSource.loopStart = offset;\r\n }\r\n if (length !== undefined) {\r\n this._soundSource.loopEnd = (offset! | 0) + length!;\r\n }\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n this._soundSource.onended = () => {\r\n this._onended();\r\n };\r\n startTime = time ? Engine.audioEngine?.audioContext!.currentTime + time : Engine.audioEngine.audioContext!.currentTime;\r\n const actualOffset = ((this.isPaused ? this.currentTime : 0) + (this._offset ?? 0)) % this._soundSource!.buffer!.duration;\r\n this._soundSource!.start(startTime, actualOffset, this.loop ? undefined : length);\r\n }\r\n }\r\n };\r\n\r\n if (Engine.audioEngine?.audioContext.state === \"suspended\") {\r\n // Wait a bit for FF as context seems late to be ready.\r\n setTimeout(() => {\r\n if (Engine.audioEngine?.audioContext!.state === \"suspended\") {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n } else {\r\n tryToPlay();\r\n }\r\n }, 500);\r\n } else {\r\n tryToPlay();\r\n }\r\n }\r\n this._startTime = startTime;\r\n this.isPlaying = true;\r\n this.isPaused = false;\r\n } catch (ex) {\r\n Logger.Error(\"Error while trying to play audio: \" + this.name + \", \" + ex.message);\r\n }\r\n }\r\n }\r\n\r\n private _onended() {\r\n this.isPlaying = false;\r\n this._startTime = 0;\r\n this._currentTime = 0;\r\n if (this.onended) {\r\n this.onended();\r\n }\r\n this.onEndedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Stop the sound\r\n * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.\r\n */\r\n public stop(time?: number): void {\r\n if (this.isPlaying) {\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n // Test needed for Firefox or it will generate an Invalid State Error\r\n if (this._htmlAudioElement.currentTime > 0) {\r\n this._htmlAudioElement.currentTime = 0;\r\n }\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext && this._soundSource) {\r\n const stopTime = time ? Engine.audioEngine.audioContext.currentTime + time : undefined;\r\n this._soundSource.onended = () => {\r\n this.isPlaying = false;\r\n this.isPaused = false;\r\n this._startTime = 0;\r\n this._currentTime = 0;\r\n if (this._soundSource) {\r\n this._soundSource.onended = () => void 0;\r\n }\r\n this._onended();\r\n };\r\n this._soundSource.stop(stopTime);\r\n }\r\n } else if (this.isPaused) {\r\n this.isPaused = false;\r\n this._startTime = 0;\r\n this._currentTime = 0;\r\n }\r\n }\r\n\r\n /**\r\n * Put the sound in pause\r\n */\r\n public pause(): void {\r\n if (this.isPlaying) {\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n this.isPaused = true;\r\n } else if (Engine.audioEngine?.audioContext && this._soundSource) {\r\n this._soundSource.onended = () => void 0;\r\n this._soundSource.stop();\r\n this.isPlaying = false;\r\n this.isPaused = true;\r\n this._currentTime += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets a dedicated volume for this sounds\r\n * @param newVolume Define the new volume of the sound\r\n * @param time Define time for gradual change to new volume\r\n */\r\n public setVolume(newVolume: number, time?: number): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._soundGain) {\r\n if (time && Engine.audioEngine.audioContext) {\r\n this._soundGain.gain.cancelScheduledValues(Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.linearRampToValueAtTime(newVolume, Engine.audioEngine.audioContext.currentTime + time);\r\n } else {\r\n this._soundGain.gain.value = newVolume;\r\n }\r\n }\r\n this._volume = newVolume;\r\n }\r\n\r\n /**\r\n * Set the sound play back rate\r\n * @param newPlaybackRate Define the playback rate the sound should be played at\r\n */\r\n public setPlaybackRate(newPlaybackRate: number): void {\r\n this._playbackRate = newPlaybackRate;\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n } else if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sound play back rate.\r\n * @returns the play back rate of the sound\r\n */\r\n public getPlaybackRate(): number {\r\n return this._playbackRate;\r\n }\r\n\r\n /**\r\n * Gets the volume of the sound.\r\n * @returns the volume of the sound\r\n */\r\n public getVolume(): number {\r\n return this._volume;\r\n }\r\n\r\n /**\r\n * Attach the sound to a dedicated mesh\r\n * @param transformNode The transform node to connect the sound with\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh\r\n */\r\n public attachToMesh(transformNode: TransformNode): void {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n }\r\n this._connectedTransformNode = transformNode;\r\n if (!this._spatialSound) {\r\n this._spatialSound = true;\r\n this._createSpatialParameters();\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);\r\n this._registerFunc = (transformNode: TransformNode) => this._onRegisterAfterWorldMatrixUpdate(transformNode);\r\n this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);\r\n }\r\n\r\n /**\r\n * Detach the sound from the previously attached mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh\r\n */\r\n public detachFromMesh() {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n\r\n private _onRegisterAfterWorldMatrixUpdate(node: TransformNode): void {\r\n if (!(<any>node).getBoundingInfo) {\r\n this.setPosition(node.absolutePosition);\r\n } else {\r\n const mesh = node as AbstractMesh;\r\n const boundingInfo = mesh.getBoundingInfo();\r\n this.setPosition(boundingInfo.boundingSphere.centerWorld);\r\n }\r\n if (Engine.audioEngine?.canUseWebAudio && this._isDirectional && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n /**\r\n * Clone the current sound in the scene.\r\n * @returns the new sound clone\r\n */\r\n public clone(): Nullable<Sound> {\r\n if (!this._streaming) {\r\n const setBufferAndRun = () => {\r\n if (this._isReadyToPlay) {\r\n clonedSound._audioBuffer = this.getAudioBuffer();\r\n clonedSound._isReadyToPlay = true;\r\n if (clonedSound.autoplay) {\r\n clonedSound.play(0, this._offset, this._length);\r\n }\r\n } else {\r\n setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n const currentOptions = {\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n useCustomAttenuation: this.useCustomAttenuation,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n };\r\n\r\n const clonedSound = new Sound(this.name + \"_cloned\", new ArrayBuffer(0), this._scene, null, currentOptions);\r\n if (this.useCustomAttenuation) {\r\n clonedSound.setAttenuationFunction(this._customAttenuationFunction);\r\n }\r\n clonedSound.setPosition(this._position);\r\n clonedSound.setPlaybackRate(this._playbackRate);\r\n setBufferAndRun();\r\n\r\n return clonedSound;\r\n }\r\n // Can't clone a streaming sound\r\n else {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current underlying audio buffer containing the data\r\n * @returns the audio buffer\r\n */\r\n public getAudioBuffer(): Nullable<AudioBuffer> {\r\n return this._audioBuffer;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.\r\n * @returns the source node\r\n */\r\n public getSoundSource(): Nullable<AudioBufferSourceNode> {\r\n return this._soundSource;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.\r\n * @returns the gain node\r\n */\r\n public getSoundGain(): Nullable<GainNode> {\r\n return this._soundGain;\r\n }\r\n\r\n /**\r\n * Serializes the Sound in a JSON representation\r\n * @returns the JSON representation of the sound\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {\r\n name: this.name,\r\n url: this.name,\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n playbackRate: this._playbackRate,\r\n panningModel: this._panningModel,\r\n soundTrackId: this.soundTrackId,\r\n metadata: this.metadata,\r\n };\r\n\r\n if (this._spatialSound) {\r\n if (this._connectedTransformNode) {\r\n serializationObject.connectedMeshId = this._connectedTransformNode.id;\r\n }\r\n\r\n serializationObject.position = this._position.asArray();\r\n serializationObject.refDistance = this.refDistance;\r\n serializationObject.distanceModel = this.distanceModel;\r\n\r\n serializationObject.isDirectional = this._isDirectional;\r\n serializationObject.localDirectionToMesh = this._localDirection.asArray();\r\n serializationObject.coneInnerAngle = this._coneInnerAngle;\r\n serializationObject.coneOuterAngle = this._coneOuterAngle;\r\n serializationObject.coneOuterGain = this._coneOuterGain;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse a JSON representation of a sound to instantiate in a given scene\r\n * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)\r\n * @param scene Define the scene the new parsed sound should be created in\r\n * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies\r\n * @param sourceSound Define a sound place holder if do not need to instantiate a new one\r\n * @returns the newly parsed sound\r\n */\r\n public static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound {\r\n const soundName = parsedSound.name;\r\n let soundUrl;\r\n\r\n if (parsedSound.url) {\r\n soundUrl = rootUrl + parsedSound.url;\r\n } else {\r\n soundUrl = rootUrl + soundName;\r\n }\r\n\r\n const options = {\r\n autoplay: parsedSound.autoplay,\r\n loop: parsedSound.loop,\r\n volume: parsedSound.volume,\r\n spatialSound: parsedSound.spatialSound,\r\n maxDistance: parsedSound.maxDistance,\r\n rolloffFactor: parsedSound.rolloffFactor,\r\n refDistance: parsedSound.refDistance,\r\n distanceModel: parsedSound.distanceModel,\r\n playbackRate: parsedSound.playbackRate,\r\n };\r\n\r\n let newSound: Sound;\r\n\r\n if (!sourceSound) {\r\n newSound = new Sound(\r\n soundName,\r\n soundUrl,\r\n scene,\r\n () => {\r\n scene.removePendingData(newSound);\r\n },\r\n options\r\n );\r\n scene.addPendingData(newSound);\r\n } else {\r\n const setBufferAndRun = () => {\r\n if (sourceSound._isReadyToPlay) {\r\n newSound._audioBuffer = sourceSound.getAudioBuffer();\r\n newSound._isReadyToPlay = true;\r\n if (newSound.autoplay) {\r\n newSound.play(0, newSound._offset, newSound._length);\r\n }\r\n } else {\r\n setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);\r\n setBufferAndRun();\r\n }\r\n\r\n if (parsedSound.position) {\r\n const soundPosition = Vector3.FromArray(parsedSound.position);\r\n newSound.setPosition(soundPosition);\r\n }\r\n if (parsedSound.isDirectional) {\r\n newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);\r\n if (parsedSound.localDirectionToMesh) {\r\n const localDirectionToMesh = Vector3.FromArray(parsedSound.localDirectionToMesh);\r\n newSound.setLocalDirectionToMesh(localDirectionToMesh);\r\n }\r\n }\r\n if (parsedSound.connectedMeshId) {\r\n const connectedMesh = scene.getMeshById(parsedSound.connectedMeshId);\r\n if (connectedMesh) {\r\n newSound.attachToMesh(connectedMesh);\r\n }\r\n }\r\n\r\n if (parsedSound.metadata) {\r\n newSound.metadata = parsedSound.metadata;\r\n }\r\n\r\n return newSound;\r\n }\r\n\r\n private _setOffset(value?: number) {\r\n if (this._offset === value) {\r\n return;\r\n }\r\n if (this.isPaused) {\r\n this.stop();\r\n this.isPaused = false;\r\n }\r\n this._offset = value;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"sound.js","sourceRoot":"","sources":["../../../../dev/core/src/Audio/sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAWd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AAC,CAAC;YACrC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;SACjC;QACD,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC7B,MAAA,MAAM,CAAC,WAAW,0CAAE,yBAAyB,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAClF,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC;SACtC;IACL,CAAC;;AA/kCD;;GAEG;AACW,mCAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAC7C,CAAC,AAF0C,CAEzC","sourcesContent":["import { Tools } from \"../Misc/tools\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { ISoundOptions } from \"./Interfaces/ISoundOptions\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { IAudioEngine } from \"./Interfaces/IAudioEngine\";\r\nimport type { Observer } from \"../Misc/observable\";\r\n\r\n/**\r\n * Defines a sound that can be played in the application.\r\n * The sound can either be an ambient track or a simple sound played in reaction to a user action.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\nexport class Sound {\r\n /**\r\n * The name of the sound in the scene.\r\n */\r\n public name: string;\r\n /**\r\n * Does the sound autoplay once loaded.\r\n */\r\n public autoplay: boolean = false;\r\n\r\n private _loop = false;\r\n /**\r\n * Does the sound loop after it finishes playing once.\r\n */\r\n public get loop(): boolean {\r\n return this._loop;\r\n }\r\n\r\n public set loop(value: boolean) {\r\n if (value === this._loop) {\r\n return;\r\n }\r\n\r\n this._loop = value;\r\n this.updateOptions({ loop: value });\r\n }\r\n\r\n /**\r\n * Does the sound use a custom attenuation curve to simulate the falloff\r\n * happening when the source gets further away from the camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function\r\n */\r\n public useCustomAttenuation: boolean = false;\r\n /**\r\n * The sound track id this sound belongs to.\r\n */\r\n public soundTrackId: number;\r\n /**\r\n * Is this sound currently played.\r\n */\r\n public isPlaying: boolean = false;\r\n /**\r\n * Is this sound currently paused.\r\n */\r\n public isPaused: boolean = false;\r\n /**\r\n * Define the reference distance the sound should be heard perfectly.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public refDistance: number = 1;\r\n /**\r\n * Define the roll off factor of spatial sounds.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public rolloffFactor: number = 1;\r\n /**\r\n * Define the max distance the sound should be heard (intensity just became 0 at this point).\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public maxDistance: number = 100;\r\n /**\r\n * Define the distance attenuation model the sound will follow.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public distanceModel: string = \"linear\";\r\n /**\r\n * @internal\r\n * Back Compat\r\n **/\r\n public onended: () => any;\r\n /**\r\n * Gets or sets an object used to store user defined information for the sound.\r\n */\r\n public metadata: any = null;\r\n\r\n /**\r\n * Observable event when the current playing sound finishes.\r\n */\r\n public onEndedObservable = new Observable<Sound>();\r\n\r\n /**\r\n * Gets the current time for the sound.\r\n */\r\n public get currentTime(): number {\r\n if (this._htmlAudioElement) {\r\n return this._htmlAudioElement.currentTime;\r\n }\r\n\r\n if (Engine.audioEngine?.audioContext && (this.isPlaying || this.isPaused)) {\r\n // The `_currentTime` member is only updated when the sound is paused. Add the time since the last start\r\n // to get the actual current time.\r\n const timeSinceLastStart = this.isPaused ? 0 : Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n return this._currentTime + timeSinceLastStart;\r\n }\r\n\r\n return 0;\r\n }\r\n\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public get spatialSound(): boolean {\r\n return this._spatialSound;\r\n }\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public set spatialSound(newValue: boolean) {\r\n this._spatialSound = newValue;\r\n if (this._spatialSound && Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._createSpatialParameters();\r\n }\r\n }\r\n private _spatialSound: boolean = false;\r\n private _panningModel: string = \"equalpower\";\r\n private _playbackRate: number = 1;\r\n private _streaming: boolean = false;\r\n private _startTime: number = 0;\r\n private _currentTime: number = 0;\r\n private _position: Vector3 = Vector3.Zero();\r\n private _localDirection: Vector3 = new Vector3(1, 0, 0);\r\n private _volume: number = 1;\r\n private _isReadyToPlay: boolean = false;\r\n private _isDirectional: boolean = false;\r\n private _readyToPlayCallback: Nullable<() => any>;\r\n private _audioBuffer: Nullable<AudioBuffer>;\r\n private _soundSource: Nullable<AudioBufferSourceNode>;\r\n private _streamingSource: AudioNode;\r\n private _soundPanner: Nullable<PannerNode>;\r\n private _soundGain: Nullable<GainNode>;\r\n private _inputAudioNode: Nullable<AudioNode>;\r\n private _outputAudioNode: Nullable<AudioNode>;\r\n // Used if you'd like to create a directional sound.\r\n // If not set, the sound will be omnidirectional\r\n private _coneInnerAngle: number = 360;\r\n private _coneOuterAngle: number = 360;\r\n private _coneOuterGain: number = 0;\r\n private _scene: Scene;\r\n private _connectedTransformNode: Nullable<TransformNode>;\r\n private _customAttenuationFunction: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number;\r\n private _registerFunc: Nullable<(connectedMesh: TransformNode) => void>;\r\n private _isOutputConnected = false;\r\n private _htmlAudioElement: HTMLAudioElement;\r\n private _urlType: \"Unknown\" | \"String\" | \"Array\" | \"ArrayBuffer\" | \"MediaStream\" | \"AudioBuffer\" | \"MediaElement\" = \"Unknown\";\r\n private _length?: number;\r\n private _offset?: number;\r\n private _tryToPlayTimeout: Nullable<NodeJS.Timeout>;\r\n private _audioUnlockedObserver?: Nullable<Observer<IAudioEngine>>;\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"AudioSceneComponent\");\r\n };\r\n\r\n /**\r\n * Create a sound and attach it to a scene\r\n * @param name Name of your sound\r\n * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams and AudioBuffers\r\n * @param scene defines the scene the sound belongs to\r\n * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played\r\n * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming\r\n */\r\n constructor(name: string, urlOrArrayBuffer: any, scene?: Nullable<Scene>, readyToPlayCallback: Nullable<() => void> = null, options?: ISoundOptions) {\r\n this.name = name;\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n Sound._SceneComponentInitialization(scene);\r\n\r\n this._readyToPlayCallback = readyToPlayCallback;\r\n // Default custom attenuation function is a linear attenuation\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n this._customAttenuationFunction = (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => {\r\n if (currentDistance < maxDistance) {\r\n return currentVolume * (1 - currentDistance / maxDistance);\r\n } else {\r\n return 0;\r\n }\r\n };\r\n if (options) {\r\n this.autoplay = options.autoplay || false;\r\n this._loop = options.loop || false;\r\n // if volume === 0, we need another way to check this option\r\n if (options.volume !== undefined) {\r\n this._volume = options.volume;\r\n }\r\n this._spatialSound = options.spatialSound ?? false;\r\n this.maxDistance = options.maxDistance ?? 100;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? false;\r\n this.rolloffFactor = options.rolloffFactor || 1;\r\n this.refDistance = options.refDistance || 1;\r\n this.distanceModel = options.distanceModel || \"linear\";\r\n this._playbackRate = options.playbackRate || 1;\r\n this._streaming = options.streaming ?? false;\r\n this._length = options.length;\r\n this._offset = options.offset;\r\n }\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._soundGain = Engine.audioEngine.audioContext.createGain();\r\n this._soundGain!.gain.value = this._volume;\r\n this._inputAudioNode = this._soundGain;\r\n this._outputAudioNode = this._soundGain;\r\n if (this._spatialSound) {\r\n this._createSpatialParameters();\r\n }\r\n this._scene.mainSoundTrack.addSound(this);\r\n let validParameter = true;\r\n\r\n // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound\r\n if (urlOrArrayBuffer) {\r\n try {\r\n if (typeof urlOrArrayBuffer === \"string\") {\r\n this._urlType = \"String\";\r\n } else if (urlOrArrayBuffer instanceof ArrayBuffer) {\r\n this._urlType = \"ArrayBuffer\";\r\n } else if (urlOrArrayBuffer instanceof HTMLMediaElement) {\r\n this._urlType = \"MediaElement\";\r\n } else if (urlOrArrayBuffer instanceof MediaStream) {\r\n this._urlType = \"MediaStream\";\r\n } else if (urlOrArrayBuffer instanceof AudioBuffer) {\r\n this._urlType = \"AudioBuffer\";\r\n } else if (Array.isArray(urlOrArrayBuffer)) {\r\n this._urlType = \"Array\";\r\n }\r\n\r\n let urls: string[] = [];\r\n let codecSupportedFound = false;\r\n\r\n switch (this._urlType) {\r\n case \"MediaElement\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"MediaStream\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaStreamSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"ArrayBuffer\":\r\n if ((<ArrayBuffer>urlOrArrayBuffer).byteLength > 0) {\r\n codecSupportedFound = true;\r\n this._soundLoaded(urlOrArrayBuffer);\r\n }\r\n break;\r\n case \"AudioBuffer\":\r\n this._audioBufferLoaded(urlOrArrayBuffer);\r\n break;\r\n case \"String\":\r\n urls.push(urlOrArrayBuffer);\r\n // eslint-disable-next-line no-fallthrough\r\n case \"Array\":\r\n if (urls.length === 0) {\r\n urls = urlOrArrayBuffer;\r\n }\r\n // If we found a supported format, we load it immediately and stop the loop\r\n for (let i = 0; i < urls.length; i++) {\r\n const url = urls[i];\r\n codecSupportedFound =\r\n (options && options.skipCodecCheck) ||\r\n (url.indexOf(\".mp3\", url.length - 4) !== -1 && Engine.audioEngine.isMP3supported) ||\r\n (url.indexOf(\".ogg\", url.length - 4) !== -1 && Engine.audioEngine.isOGGsupported) ||\r\n url.indexOf(\".wav\", url.length - 4) !== -1 ||\r\n url.indexOf(\".m4a\", url.length - 4) !== -1 ||\r\n url.indexOf(\".mp4\", url.length - 4) !== -1 ||\r\n url.indexOf(\"blob:\") !== -1;\r\n if (codecSupportedFound) {\r\n // Loading sound\r\n if (!this._streaming) {\r\n this._scene._loadFile(\r\n url,\r\n (data) => {\r\n this._soundLoaded(data as ArrayBuffer);\r\n },\r\n undefined,\r\n true,\r\n true,\r\n (exception) => {\r\n if (exception) {\r\n Logger.Error(\"XHR \" + exception.status + \" error on: \" + url + \".\");\r\n }\r\n Logger.Error(\"Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n );\r\n }\r\n // Streaming sound using HTML5 Audio tag\r\n else {\r\n this._htmlAudioElement = new Audio(url);\r\n this._htmlAudioElement.controls = false;\r\n this._htmlAudioElement.loop = this.loop;\r\n Tools.SetCorsBehavior(url, this._htmlAudioElement);\r\n this._htmlAudioElement.preload = \"auto\";\r\n this._htmlAudioElement.addEventListener(\"canplaythrough\", () => {\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n });\r\n document.body.appendChild(this._htmlAudioElement);\r\n this._htmlAudioElement.load();\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n default:\r\n validParameter = false;\r\n break;\r\n }\r\n\r\n if (!validParameter) {\r\n Logger.Error(\"Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.\");\r\n } else {\r\n if (!codecSupportedFound) {\r\n this._isReadyToPlay = true;\r\n // Simulating a ready to play event to avoid breaking code path\r\n if (this._readyToPlayCallback) {\r\n setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n } catch (ex) {\r\n Logger.Error(\"Unexpected error. Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n }\r\n } else {\r\n // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers\r\n this._scene.mainSoundTrack.addSound(this);\r\n if (Engine.audioEngine && !Engine.audioEngine.WarnedWebAudioUnsupported) {\r\n Logger.Error(\"Web Audio is not supported by your browser.\");\r\n Engine.audioEngine.WarnedWebAudioUnsupported = true;\r\n }\r\n // Simulating a ready to play event to avoid breaking code for non web audio browsers\r\n if (this._readyToPlayCallback) {\r\n setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release the sound and its associated resources\r\n */\r\n public dispose() {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n if (this.isPlaying) {\r\n this.stop();\r\n }\r\n this._isReadyToPlay = false;\r\n if (this.soundTrackId === -1) {\r\n this._scene.mainSoundTrack.removeSound(this);\r\n } else if (this._scene.soundTracks) {\r\n this._scene.soundTracks[this.soundTrackId].removeSound(this);\r\n }\r\n if (this._soundGain) {\r\n this._soundGain.disconnect();\r\n this._soundGain = null;\r\n }\r\n if (this._soundPanner) {\r\n this._soundPanner.disconnect();\r\n this._soundPanner = null;\r\n }\r\n if (this._soundSource) {\r\n this._soundSource.disconnect();\r\n this._soundSource = null;\r\n }\r\n this._audioBuffer = null;\r\n\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n this._htmlAudioElement.src = \"\";\r\n document.body.removeChild(this._htmlAudioElement);\r\n }\r\n\r\n if (this._streamingSource) {\r\n this._streamingSource.disconnect();\r\n }\r\n\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._connectedTransformNode = null;\r\n }\r\n\r\n this._clearTimeoutsAndObservers();\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the sounds is ready to be played or not.\r\n * @returns true if ready, otherwise false\r\n */\r\n public isReady(): boolean {\r\n return this._isReadyToPlay;\r\n }\r\n\r\n /**\r\n * Get the current class name.\r\n * @returns current class name\r\n */\r\n public getClassName(): string {\r\n return \"Sound\";\r\n }\r\n\r\n private _audioBufferLoaded(buffer: AudioBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n this._audioBuffer = buffer;\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }\r\n\r\n private _soundLoaded(audioData: ArrayBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n Engine.audioEngine.audioContext.decodeAudioData(\r\n audioData,\r\n (buffer) => {\r\n this._audioBufferLoaded(buffer);\r\n },\r\n (err: any) => {\r\n Logger.Error(\"Error while decoding audio data for: \" + this.name + \" / Error: \" + err);\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Sets the data of the sound from an audiobuffer\r\n * @param audioBuffer The audioBuffer containing the data\r\n */\r\n public setAudioBuffer(audioBuffer: AudioBuffer): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n this._audioBuffer = audioBuffer;\r\n this._isReadyToPlay = true;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the current sounds options such as maxdistance, loop...\r\n * @param options A JSON object containing values named as the object properties\r\n */\r\n public updateOptions(options: ISoundOptions): void {\r\n if (options) {\r\n this.loop = options.loop ?? this.loop;\r\n this.maxDistance = options.maxDistance ?? this.maxDistance;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? this.useCustomAttenuation;\r\n this.rolloffFactor = options.rolloffFactor ?? this.rolloffFactor;\r\n this.refDistance = options.refDistance ?? this.refDistance;\r\n this.distanceModel = options.distanceModel ?? this.distanceModel;\r\n this._playbackRate = options.playbackRate ?? this._playbackRate;\r\n this._length = options.length ?? undefined;\r\n this._setOffset(options.offset ?? undefined);\r\n this.setVolume(options.volume ?? this._volume);\r\n this._updateSpatialParameters();\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n if (this._htmlAudioElement.loop !== this.loop) {\r\n this._htmlAudioElement.loop = this.loop;\r\n }\r\n } else {\r\n if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n if (this._soundSource.loop !== this.loop) {\r\n this._soundSource.loop = this.loop;\r\n }\r\n if (this._offset !== undefined && this._soundSource.loopStart !== this._offset) {\r\n this._soundSource.loopStart = this._offset;\r\n }\r\n if (this._length !== undefined && this._length !== this._soundSource.loopEnd) {\r\n this._soundSource.loopEnd = (this._offset! | 0) + this._length!;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _createSpatialParameters() {\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n if (this._scene.headphone) {\r\n this._panningModel = \"HRTF\";\r\n }\r\n this._soundPanner = this._soundPanner ?? Engine.audioEngine.audioContext.createPanner();\r\n if (this._soundPanner && this._outputAudioNode) {\r\n this._updateSpatialParameters();\r\n this._soundPanner.connect(this._outputAudioNode);\r\n this._inputAudioNode = this._soundPanner;\r\n }\r\n }\r\n }\r\n\r\n private _updateSpatialParameters() {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (this.useCustomAttenuation) {\r\n // Tricks to disable in a way embedded Web Audio attenuation\r\n this._soundPanner.distanceModel = \"linear\";\r\n this._soundPanner.maxDistance = Number.MAX_VALUE;\r\n this._soundPanner.refDistance = 1;\r\n this._soundPanner.rolloffFactor = 1;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n } else {\r\n this._soundPanner.distanceModel = this.distanceModel as any;\r\n this._soundPanner.maxDistance = this.maxDistance;\r\n this._soundPanner.refDistance = this.refDistance;\r\n this._soundPanner.rolloffFactor = this.rolloffFactor;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to HRTF:\r\n * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToHRTF() {\r\n this._panningModel = \"HRTF\";\r\n this._switchPanningModel();\r\n }\r\n\r\n /**\r\n * Switch the panning model to Equal Power:\r\n * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToEqualPower() {\r\n this._panningModel = \"equalpower\";\r\n this._switchPanningModel();\r\n }\r\n\r\n private _switchPanningModel() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n\r\n /**\r\n * Connect this sound to a sound track audio node like gain...\r\n * @param soundTrackAudioNode the sound track audio node to connect to\r\n */\r\n public connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n if (this._isOutputConnected) {\r\n this._outputAudioNode.disconnect();\r\n }\r\n this._outputAudioNode.connect(soundTrackAudioNode);\r\n this._isOutputConnected = true;\r\n }\r\n }\r\n\r\n /**\r\n * Transform this sound into a directional source\r\n * @param coneInnerAngle Size of the inner cone in degree\r\n * @param coneOuterAngle Size of the outer cone in degree\r\n * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)\r\n */\r\n public setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void {\r\n if (coneOuterAngle < coneInnerAngle) {\r\n Logger.Error(\"setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n this._coneInnerAngle = coneInnerAngle;\r\n this._coneOuterAngle = coneOuterAngle;\r\n this._coneOuterGain = coneOuterGain;\r\n this._isDirectional = true;\r\n\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public get directionalConeInnerAngle(): number {\r\n return this._coneInnerAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public set directionalConeInnerAngle(value: number) {\r\n if (value != this._coneInnerAngle) {\r\n if (this._coneOuterAngle < value) {\r\n Logger.Error(\"directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneInnerAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public get directionalConeOuterAngle(): number {\r\n return this._coneOuterAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public set directionalConeOuterAngle(value: number) {\r\n if (value != this._coneOuterAngle) {\r\n if (value < this._coneInnerAngle) {\r\n Logger.Error(\"directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneOuterAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the position of the emitter if spatial sound is enabled\r\n * @param newPosition Defines the new position\r\n */\r\n public setPosition(newPosition: Vector3): void {\r\n if (newPosition.equals(this._position)) {\r\n return;\r\n }\r\n this._position.copyFrom(newPosition);\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n }\r\n\r\n /**\r\n * Sets the local direction of the emitter if spatial sound is enabled\r\n * @param newLocalDirection Defines the new local direction\r\n */\r\n public setLocalDirectionToMesh(newLocalDirection: Vector3): void {\r\n this._localDirection = newLocalDirection;\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n private _updateDirection() {\r\n if (!this._connectedTransformNode || !this._soundPanner) {\r\n return;\r\n }\r\n\r\n const mat = this._connectedTransformNode.getWorldMatrix();\r\n const direction = Vector3.TransformNormal(this._localDirection, mat);\r\n direction.normalize();\r\n this._soundPanner.orientationX.value = direction.x;\r\n this._soundPanner.orientationY.value = direction.y;\r\n this._soundPanner.orientationZ.value = direction.z;\r\n }\r\n\r\n /** @internal */\r\n public updateDistanceFromListener() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {\r\n const distance = this._scene.audioListenerPositionProvider\r\n ? this._connectedTransformNode.position.subtract(this._scene.audioListenerPositionProvider()).length()\r\n : this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);\r\n this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);\r\n }\r\n }\r\n\r\n /**\r\n * Sets a new custom attenuation function for the sound.\r\n * @param callback Defines the function used for the attenuation\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function\r\n */\r\n public setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void {\r\n this._customAttenuationFunction = callback;\r\n }\r\n\r\n /**\r\n * Play the sound\r\n * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.\r\n * @param offset (optional) Start the sound at a specific time in seconds\r\n * @param length (optional) Sound duration (in seconds)\r\n */\r\n public play(time?: number, offset?: number, length?: number): void {\r\n if (this._isReadyToPlay && this._scene.audioEnabled && Engine.audioEngine?.audioContext) {\r\n try {\r\n this._clearTimeoutsAndObservers();\r\n\r\n let startTime = time ? Engine.audioEngine?.audioContext.currentTime + time : Engine.audioEngine?.audioContext.currentTime;\r\n if (!this._soundSource || !this._streamingSource) {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n if (this._isDirectional) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n this._soundPanner.coneOuterGain = this._coneOuterGain;\r\n if (this._connectedTransformNode) {\r\n this._updateDirection();\r\n } else {\r\n this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);\r\n }\r\n }\r\n }\r\n }\r\n if (this._streaming) {\r\n if (!this._streamingSource) {\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);\r\n this._htmlAudioElement.onended = () => {\r\n this._onended();\r\n };\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n }\r\n this._streamingSource.disconnect();\r\n if (this._inputAudioNode) {\r\n this._streamingSource.connect(this._inputAudioNode);\r\n }\r\n if (this._htmlAudioElement) {\r\n // required to manage properly the new suspended default state of Chrome\r\n // When the option 'streaming: true' is used, we need first to wait for\r\n // the audio engine to be unlocked by a user gesture before trying to play\r\n // an HTML Audio element\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.unlocked) {\r\n const playPromise = this._htmlAudioElement.play();\r\n\r\n // In browsers that don’t yet support this functionality,\r\n // playPromise won’t be defined.\r\n if (playPromise !== undefined) {\r\n playPromise.catch(() => {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine?.lock();\r\n if (this.loop || this.autoplay) {\r\n this._audioUnlockedObserver = Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n });\r\n }\r\n } else {\r\n if (this.loop || this.autoplay) {\r\n this._audioUnlockedObserver = Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n }\r\n };\r\n tryToPlay();\r\n }\r\n } else {\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.audioContext) {\r\n length = length || this._length;\r\n\r\n if (offset !== undefined) {\r\n this._setOffset(offset);\r\n }\r\n\r\n if (this._soundSource) {\r\n const oldSource = this._soundSource;\r\n oldSource.onended = () => {\r\n oldSource.disconnect();\r\n };\r\n }\r\n this._soundSource = Engine.audioEngine?.audioContext.createBufferSource();\r\n if (this._soundSource && this._inputAudioNode) {\r\n this._soundSource.buffer = this._audioBuffer;\r\n this._soundSource.connect(this._inputAudioNode);\r\n this._soundSource.loop = this.loop;\r\n if (offset !== undefined) {\r\n this._soundSource.loopStart = offset;\r\n }\r\n if (length !== undefined) {\r\n this._soundSource.loopEnd = (offset! | 0) + length!;\r\n }\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n this._soundSource.onended = () => {\r\n this._onended();\r\n };\r\n startTime = time ? Engine.audioEngine?.audioContext!.currentTime + time : Engine.audioEngine.audioContext!.currentTime;\r\n const actualOffset = ((this.isPaused ? this.currentTime : 0) + (this._offset ?? 0)) % this._soundSource!.buffer!.duration;\r\n this._soundSource!.start(startTime, actualOffset, this.loop ? undefined : length);\r\n }\r\n }\r\n };\r\n\r\n if (Engine.audioEngine?.audioContext.state === \"suspended\") {\r\n // Wait a bit for FF as context seems late to be ready.\r\n this._tryToPlayTimeout = setTimeout(() => {\r\n if (Engine.audioEngine?.audioContext!.state === \"suspended\") {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine.lock();\r\n if (this.loop || this.autoplay) {\r\n this._audioUnlockedObserver = Engine.audioEngine.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n } else {\r\n tryToPlay();\r\n }\r\n }, 500);\r\n } else {\r\n tryToPlay();\r\n }\r\n }\r\n this._startTime = startTime;\r\n this.isPlaying = true;\r\n this.isPaused = false;\r\n } catch (ex) {\r\n Logger.Error(\"Error while trying to play audio: \" + this.name + \", \" + ex.message);\r\n }\r\n }\r\n }\r\n\r\n private _onended() {\r\n this.isPlaying = false;\r\n this._startTime = 0;\r\n this._currentTime = 0;\r\n if (this.onended) {\r\n this.onended();\r\n }\r\n this.onEndedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Stop the sound\r\n * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.\r\n */\r\n public stop(time?: number): void {\r\n if (this.isPlaying) {\r\n this._clearTimeoutsAndObservers();\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n // Test needed for Firefox or it will generate an Invalid State Error\r\n if (this._htmlAudioElement.currentTime > 0) {\r\n this._htmlAudioElement.currentTime = 0;\r\n }\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext && this._soundSource) {\r\n const stopTime = time ? Engine.audioEngine.audioContext.currentTime + time : undefined;\r\n this._soundSource.onended = () => {\r\n this.isPlaying = false;\r\n this.isPaused = false;\r\n this._startTime = 0;\r\n this._currentTime = 0;\r\n if (this._soundSource) {\r\n this._soundSource.onended = () => void 0;\r\n }\r\n this._onended();\r\n };\r\n this._soundSource.stop(stopTime);\r\n } else {\r\n this.isPlaying = false;\r\n }\r\n } else if (this.isPaused) {\r\n this.isPaused = false;\r\n this._startTime = 0;\r\n this._currentTime = 0;\r\n }\r\n }\r\n\r\n /**\r\n * Put the sound in pause\r\n */\r\n public pause(): void {\r\n if (this.isPlaying) {\r\n this._clearTimeoutsAndObservers();\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n this.isPaused = true;\r\n } else if (Engine.audioEngine?.audioContext && this._soundSource) {\r\n this._soundSource.onended = () => void 0;\r\n this._soundSource.stop();\r\n this.isPlaying = false;\r\n this.isPaused = true;\r\n this._currentTime += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets a dedicated volume for this sounds\r\n * @param newVolume Define the new volume of the sound\r\n * @param time Define time for gradual change to new volume\r\n */\r\n public setVolume(newVolume: number, time?: number): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._soundGain) {\r\n if (time && Engine.audioEngine.audioContext) {\r\n this._soundGain.gain.cancelScheduledValues(Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.linearRampToValueAtTime(newVolume, Engine.audioEngine.audioContext.currentTime + time);\r\n } else {\r\n this._soundGain.gain.value = newVolume;\r\n }\r\n }\r\n this._volume = newVolume;\r\n }\r\n\r\n /**\r\n * Set the sound play back rate\r\n * @param newPlaybackRate Define the playback rate the sound should be played at\r\n */\r\n public setPlaybackRate(newPlaybackRate: number): void {\r\n this._playbackRate = newPlaybackRate;\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n } else if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sound play back rate.\r\n * @returns the play back rate of the sound\r\n */\r\n public getPlaybackRate(): number {\r\n return this._playbackRate;\r\n }\r\n\r\n /**\r\n * Gets the volume of the sound.\r\n * @returns the volume of the sound\r\n */\r\n public getVolume(): number {\r\n return this._volume;\r\n }\r\n\r\n /**\r\n * Attach the sound to a dedicated mesh\r\n * @param transformNode The transform node to connect the sound with\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh\r\n */\r\n public attachToMesh(transformNode: TransformNode): void {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n }\r\n this._connectedTransformNode = transformNode;\r\n if (!this._spatialSound) {\r\n this._spatialSound = true;\r\n this._createSpatialParameters();\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);\r\n this._registerFunc = (transformNode: TransformNode) => this._onRegisterAfterWorldMatrixUpdate(transformNode);\r\n this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);\r\n }\r\n\r\n /**\r\n * Detach the sound from the previously attached mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh\r\n */\r\n public detachFromMesh() {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n\r\n private _onRegisterAfterWorldMatrixUpdate(node: TransformNode): void {\r\n if (!(<any>node).getBoundingInfo) {\r\n this.setPosition(node.absolutePosition);\r\n } else {\r\n const mesh = node as AbstractMesh;\r\n const boundingInfo = mesh.getBoundingInfo();\r\n this.setPosition(boundingInfo.boundingSphere.centerWorld);\r\n }\r\n if (Engine.audioEngine?.canUseWebAudio && this._isDirectional && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n /**\r\n * Clone the current sound in the scene.\r\n * @returns the new sound clone\r\n */\r\n public clone(): Nullable<Sound> {\r\n if (!this._streaming) {\r\n const setBufferAndRun = () => {\r\n if (this._isReadyToPlay) {\r\n clonedSound._audioBuffer = this.getAudioBuffer();\r\n clonedSound._isReadyToPlay = true;\r\n if (clonedSound.autoplay) {\r\n clonedSound.play(0, this._offset, this._length);\r\n }\r\n } else {\r\n setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n const currentOptions = {\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n useCustomAttenuation: this.useCustomAttenuation,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n };\r\n\r\n const clonedSound = new Sound(this.name + \"_cloned\", new ArrayBuffer(0), this._scene, null, currentOptions);\r\n if (this.useCustomAttenuation) {\r\n clonedSound.setAttenuationFunction(this._customAttenuationFunction);\r\n }\r\n clonedSound.setPosition(this._position);\r\n clonedSound.setPlaybackRate(this._playbackRate);\r\n setBufferAndRun();\r\n\r\n return clonedSound;\r\n }\r\n // Can't clone a streaming sound\r\n else {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current underlying audio buffer containing the data\r\n * @returns the audio buffer\r\n */\r\n public getAudioBuffer(): Nullable<AudioBuffer> {\r\n return this._audioBuffer;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.\r\n * @returns the source node\r\n */\r\n public getSoundSource(): Nullable<AudioBufferSourceNode> {\r\n return this._soundSource;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.\r\n * @returns the gain node\r\n */\r\n public getSoundGain(): Nullable<GainNode> {\r\n return this._soundGain;\r\n }\r\n\r\n /**\r\n * Serializes the Sound in a JSON representation\r\n * @returns the JSON representation of the sound\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {\r\n name: this.name,\r\n url: this.name,\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n playbackRate: this._playbackRate,\r\n panningModel: this._panningModel,\r\n soundTrackId: this.soundTrackId,\r\n metadata: this.metadata,\r\n };\r\n\r\n if (this._spatialSound) {\r\n if (this._connectedTransformNode) {\r\n serializationObject.connectedMeshId = this._connectedTransformNode.id;\r\n }\r\n\r\n serializationObject.position = this._position.asArray();\r\n serializationObject.refDistance = this.refDistance;\r\n serializationObject.distanceModel = this.distanceModel;\r\n\r\n serializationObject.isDirectional = this._isDirectional;\r\n serializationObject.localDirectionToMesh = this._localDirection.asArray();\r\n serializationObject.coneInnerAngle = this._coneInnerAngle;\r\n serializationObject.coneOuterAngle = this._coneOuterAngle;\r\n serializationObject.coneOuterGain = this._coneOuterGain;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse a JSON representation of a sound to instantiate in a given scene\r\n * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)\r\n * @param scene Define the scene the new parsed sound should be created in\r\n * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies\r\n * @param sourceSound Define a sound place holder if do not need to instantiate a new one\r\n * @returns the newly parsed sound\r\n */\r\n public static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound {\r\n const soundName = parsedSound.name;\r\n let soundUrl;\r\n\r\n if (parsedSound.url) {\r\n soundUrl = rootUrl + parsedSound.url;\r\n } else {\r\n soundUrl = rootUrl + soundName;\r\n }\r\n\r\n const options = {\r\n autoplay: parsedSound.autoplay,\r\n loop: parsedSound.loop,\r\n volume: parsedSound.volume,\r\n spatialSound: parsedSound.spatialSound,\r\n maxDistance: parsedSound.maxDistance,\r\n rolloffFactor: parsedSound.rolloffFactor,\r\n refDistance: parsedSound.refDistance,\r\n distanceModel: parsedSound.distanceModel,\r\n playbackRate: parsedSound.playbackRate,\r\n };\r\n\r\n let newSound: Sound;\r\n\r\n if (!sourceSound) {\r\n newSound = new Sound(\r\n soundName,\r\n soundUrl,\r\n scene,\r\n () => {\r\n scene.removePendingData(newSound);\r\n },\r\n options\r\n );\r\n scene.addPendingData(newSound);\r\n } else {\r\n const setBufferAndRun = () => {\r\n if (sourceSound._isReadyToPlay) {\r\n newSound._audioBuffer = sourceSound.getAudioBuffer();\r\n newSound._isReadyToPlay = true;\r\n if (newSound.autoplay) {\r\n newSound.play(0, newSound._offset, newSound._length);\r\n }\r\n } else {\r\n setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);\r\n setBufferAndRun();\r\n }\r\n\r\n if (parsedSound.position) {\r\n const soundPosition = Vector3.FromArray(parsedSound.position);\r\n newSound.setPosition(soundPosition);\r\n }\r\n if (parsedSound.isDirectional) {\r\n newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);\r\n if (parsedSound.localDirectionToMesh) {\r\n const localDirectionToMesh = Vector3.FromArray(parsedSound.localDirectionToMesh);\r\n newSound.setLocalDirectionToMesh(localDirectionToMesh);\r\n }\r\n }\r\n if (parsedSound.connectedMeshId) {\r\n const connectedMesh = scene.getMeshById(parsedSound.connectedMeshId);\r\n if (connectedMesh) {\r\n newSound.attachToMesh(connectedMesh);\r\n }\r\n }\r\n\r\n if (parsedSound.metadata) {\r\n newSound.metadata = parsedSound.metadata;\r\n }\r\n\r\n return newSound;\r\n }\r\n\r\n private _setOffset(value?: number) {\r\n if (this._offset === value) {\r\n return;\r\n }\r\n if (this.isPaused) {\r\n this.stop();\r\n this.isPaused = false;\r\n }\r\n this._offset = value;\r\n }\r\n\r\n private _clearTimeoutsAndObservers() {\r\n if (this._tryToPlayTimeout) {\r\n clearTimeout(this._tryToPlayTimeout);\r\n this._tryToPlayTimeout = null;\r\n }\r\n if (this._audioUnlockedObserver) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.remove(this._audioUnlockedObserver);\r\n this._audioUnlockedObserver = null;\r\n }\r\n }\r\n}\r\n"]}
@@ -37,8 +37,11 @@ export class ShaderCodeCursor {
37
37
  this._lines.push(trimmedLine);
38
38
  }
39
39
  else if (semicolonIndex === trimmedLine.length - 1) {
40
- // Semicolon at the end of the line
41
- this._lines.push(trimmedLine);
40
+ // Single semicolon at the end of the line
41
+ // If trimmedLine == ";", we must not push, to be backward compatible with the old code!
42
+ if (trimmedLine.length > 1) {
43
+ this._lines.push(trimmedLine);
44
+ }
42
45
  }
43
46
  else {
44
47
  // Semicolon in the middle of the line
@@ -1 +1 @@
1
- {"version":3,"file":"shaderCodeCursor.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Processors/shaderCodeCursor.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAA7B;QACY,WAAM,GAAa,EAAE,CAAC;IAqElC,CAAC;IAlEG,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,KAAK,CAAC,KAAe;QACrB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAEvB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACtB,mBAAmB;YACnB,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,EAAE;gBACxB,SAAS;aACZ;YAED,yCAAyC;YACzC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACvB,SAAS;aACZ;YAED,oCAAoC;YACpC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAEhC,IAAI,CAAC,WAAW,EAAE;gBACd,SAAS;aACZ;YAED,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACvB,SAAS;aACZ;YAED,kCAAkC;YAClC,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAEhD,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE;gBACvB,2BAA2B;gBAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;aACjC;iBAAM,IAAI,cAAc,KAAK,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;gBAClD,mCAAmC;gBACnC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;aACjC;iBAAM;gBACH,sCAAsC;gBACtC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAE9B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;oBAC/C,IAAI,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;oBAE3B,IAAI,CAAC,OAAO,EAAE;wBACV,SAAS;qBACZ;oBAED,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;oBAEzB,IAAI,CAAC,OAAO,EAAE;wBACV,SAAS;qBACZ;oBAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBACvE;aACJ;SACJ;IACL,CAAC;CACJ","sourcesContent":["/** @internal */\r\nexport class ShaderCodeCursor {\r\n private _lines: string[] = [];\r\n lineIndex: number;\r\n\r\n get currentLine(): string {\r\n return this._lines[this.lineIndex];\r\n }\r\n\r\n get canRead(): boolean {\r\n return this.lineIndex < this._lines.length - 1;\r\n }\r\n\r\n set lines(value: string[]) {\r\n this._lines.length = 0;\r\n\r\n for (const line of value) {\r\n // Skip empty lines\r\n if (!line || line === \"\\r\") {\r\n continue;\r\n }\r\n\r\n // Prevent removing line break in macros.\r\n if (line[0] === \"#\") {\r\n this._lines.push(line);\r\n continue;\r\n }\r\n\r\n // Do not split single line comments\r\n const trimmedLine = line.trim();\r\n\r\n if (!trimmedLine) {\r\n continue;\r\n }\r\n\r\n if (trimmedLine.startsWith(\"//\")) {\r\n this._lines.push(line);\r\n continue;\r\n }\r\n\r\n // Work with semicolon in the line\r\n const semicolonIndex = trimmedLine.indexOf(\";\");\r\n\r\n if (semicolonIndex === -1) {\r\n // No semicolon in the line\r\n this._lines.push(trimmedLine);\r\n } else if (semicolonIndex === trimmedLine.length - 1) {\r\n // Semicolon at the end of the line\r\n this._lines.push(trimmedLine);\r\n } else {\r\n // Semicolon in the middle of the line\r\n const split = line.split(\";\");\r\n\r\n for (let index = 0; index < split.length; index++) {\r\n let subLine = split[index];\r\n\r\n if (!subLine) {\r\n continue;\r\n }\r\n\r\n subLine = subLine.trim();\r\n\r\n if (!subLine) {\r\n continue;\r\n }\r\n\r\n this._lines.push(subLine + (index !== split.length - 1 ? \";\" : \"\"));\r\n }\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"shaderCodeCursor.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Processors/shaderCodeCursor.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAA7B;QACY,WAAM,GAAa,EAAE,CAAC;IAwElC,CAAC;IArEG,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,KAAK,CAAC,KAAe;QACrB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAEvB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACtB,mBAAmB;YACnB,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,EAAE;gBACxB,SAAS;aACZ;YAED,yCAAyC;YACzC,IA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I,CAAC,OAAO,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBACvE;aACJ;SACJ;IACL,CAAC;CACJ","sourcesContent":["/** @internal */\r\nexport class ShaderCodeCursor {\r\n private _lines: string[] = [];\r\n lineIndex: number;\r\n\r\n get currentLine(): string {\r\n return this._lines[this.lineIndex];\r\n }\r\n\r\n get canRead(): boolean {\r\n return this.lineIndex < this._lines.length - 1;\r\n }\r\n\r\n set lines(value: string[]) {\r\n this._lines.length = 0;\r\n\r\n for (const line of value) {\r\n // Skip empty lines\r\n if (!line || line === \"\\r\") {\r\n continue;\r\n }\r\n\r\n // Prevent removing line break in macros.\r\n if (line[0] === \"#\") {\r\n this._lines.push(line);\r\n continue;\r\n }\r\n\r\n // Do not split single line comments\r\n const trimmedLine = line.trim();\r\n\r\n if (!trimmedLine) {\r\n continue;\r\n }\r\n\r\n if (trimmedLine.startsWith(\"//\")) {\r\n this._lines.push(line);\r\n continue;\r\n }\r\n\r\n // Work with semicolon in the line\r\n const semicolonIndex = trimmedLine.indexOf(\";\");\r\n\r\n if (semicolonIndex === -1) {\r\n // No semicolon in the line\r\n this._lines.push(trimmedLine);\r\n } else if (semicolonIndex === trimmedLine.length - 1) {\r\n // Single semicolon at the end of the line\r\n // If trimmedLine == \";\", we must not push, to be backward compatible with the old code!\r\n if (trimmedLine.length > 1) {\r\n this._lines.push(trimmedLine);\r\n }\r\n } else {\r\n // Semicolon in the middle of the line\r\n const split = line.split(\";\");\r\n\r\n for (let index = 0; index < split.length; index++) {\r\n let subLine = split[index];\r\n\r\n if (!subLine) {\r\n continue;\r\n }\r\n\r\n subLine = subLine.trim();\r\n\r\n if (!subLine) {\r\n continue;\r\n }\r\n\r\n this._lines.push(subLine + (index !== split.length - 1 ? \";\" : \"\"));\r\n }\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -34,13 +34,13 @@ export class ThinEngine {
34
34
  */
35
35
  // Not mixed with Version for tooling purpose.
36
36
  static get NpmPackage() {
37
- return "babylonjs@6.12.0";
37
+ return "babylonjs@6.12.2";
38
38
  }
39
39
  /**
40
40
  * Returns the current version of the framework
41
41
  */
42
42
  static get Version() {
43
- return "6.12.0";
43
+ return "6.12.2";
44
44
  }
45
45
  /**
46
46
  * Returns a string describing the current engine