@babylonjs/core 8.13.0 → 8.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/AudioV2/abstractAudio/abstractAudioBus.d.ts +4 -21
  2. package/AudioV2/abstractAudio/abstractAudioBus.js +2 -34
  3. package/AudioV2/abstractAudio/abstractAudioBus.js.map +1 -1
  4. package/AudioV2/abstractAudio/abstractAudioOutNode.d.ts +40 -0
  5. package/AudioV2/abstractAudio/abstractAudioOutNode.js +56 -0
  6. package/AudioV2/abstractAudio/abstractAudioOutNode.js.map +1 -0
  7. package/AudioV2/abstractAudio/abstractSoundSource.d.ts +5 -16
  8. package/AudioV2/abstractAudio/abstractSoundSource.js +2 -27
  9. package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
  10. package/AudioV2/abstractAudio/audioEngineV2.d.ts +13 -0
  11. package/AudioV2/abstractAudio/audioEngineV2.js +4 -0
  12. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  13. package/AudioV2/abstractAudio/index.d.ts +1 -0
  14. package/AudioV2/abstractAudio/index.js +1 -0
  15. package/AudioV2/abstractAudio/index.js.map +1 -1
  16. package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.d.ts +3 -0
  17. package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
  18. package/AudioV2/audioParameter.d.ts +31 -0
  19. package/AudioV2/audioParameter.js +19 -0
  20. package/AudioV2/audioParameter.js.map +1 -0
  21. package/AudioV2/audioUtils.d.ts +3 -0
  22. package/AudioV2/audioUtils.js +61 -0
  23. package/AudioV2/audioUtils.js.map +1 -1
  24. package/AudioV2/index.d.ts +1 -0
  25. package/AudioV2/index.js +1 -0
  26. package/AudioV2/index.js.map +1 -1
  27. package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +37 -0
  28. package/AudioV2/webAudio/components/webAudioParameterComponent.js +89 -0
  29. package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -0
  30. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +8 -0
  31. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +24 -6
  32. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
  33. package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.d.ts +2 -0
  34. package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.js +9 -4
  35. package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.js.map +1 -1
  36. package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.d.ts +7 -1
  37. package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.js +14 -5
  38. package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.js.map +1 -1
  39. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +92 -30
  40. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
  41. package/AudioV2/webAudio/webAudioEngine.d.ts +4 -2
  42. package/AudioV2/webAudio/webAudioEngine.js +9 -4
  43. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  44. package/AudioV2/webAudio/webAudioMainOut.d.ts +6 -2
  45. package/AudioV2/webAudio/webAudioMainOut.js +15 -10
  46. package/AudioV2/webAudio/webAudioMainOut.js.map +1 -1
  47. package/AudioV2/webAudio/webAudioStaticSound.d.ts +4 -2
  48. package/AudioV2/webAudio/webAudioStaticSound.js +17 -14
  49. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  50. package/BakedVertexAnimation/vertexAnimationBaker.js +17 -20
  51. package/BakedVertexAnimation/vertexAnimationBaker.js.map +1 -1
  52. package/Behaviors/Meshes/pointerDragBehavior.d.ts +5 -0
  53. package/Behaviors/Meshes/pointerDragBehavior.js +7 -1
  54. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  55. package/Engines/abstractEngine.js +2 -2
  56. package/Engines/abstractEngine.js.map +1 -1
  57. package/Gizmos/boundingBoxGizmo.d.ts +6 -0
  58. package/Gizmos/boundingBoxGizmo.js +16 -1
  59. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  60. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +2 -0
  61. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  62. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +3 -1
  63. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
  64. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +1 -0
  65. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  66. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +5 -5
  67. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
  68. package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +10 -3
  69. package/Materials/PBR/pbrSubSurfaceConfiguration.js +16 -5
  70. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  71. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +6 -0
  72. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +11 -4
  73. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  74. package/Meshes/linesMesh.d.ts +2 -11
  75. package/Meshes/linesMesh.js +10 -24
  76. package/Meshes/linesMesh.js.map +1 -1
  77. package/Particles/Node/Blocks/particleDebugBlock.d.ts +6 -0
  78. package/Particles/Node/Blocks/particleDebugBlock.js +10 -0
  79. package/Particles/Node/Blocks/particleDebugBlock.js.map +1 -1
  80. package/Shaders/ShadersInclude/hdrFilteringFunctions.js +16 -2
  81. package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  82. package/Shaders/gaussianSplatting.vertex.js +2 -3
  83. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  84. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +17 -2
  85. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  86. package/ShadersWGSL/gaussianSplatting.vertex.js +2 -3
  87. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  88. package/XR/features/WebXRControllerPointerSelection.js +3 -3
  89. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  90. package/package.json +1 -1
@@ -1,4 +1,65 @@
1
1
  export const _FileExtensionRegex = new RegExp("\\.(\\w{3,4})($|\\?)");
2
+ const CurveLength = 100;
3
+ const TmpLineValues = new Float32Array([0, 0]);
4
+ let TmpCurveValues = null;
5
+ let ExpCurve = null;
6
+ let LogCurve = null;
7
+ /**
8
+ * @returns A Float32Array representing an exponential ramp from (0, 0) to (1, 1).
9
+ */
10
+ function GetExpCurve() {
11
+ if (!ExpCurve) {
12
+ ExpCurve = new Float32Array(CurveLength);
13
+ const increment = 1 / (CurveLength - 1);
14
+ let x = increment;
15
+ for (let i = 1; i < CurveLength; i++) {
16
+ ExpCurve[i] = Math.exp(-11.512925464970227 * (1 - x));
17
+ x += increment;
18
+ }
19
+ }
20
+ return ExpCurve;
21
+ }
22
+ /**
23
+ * @returns A Float32Array representing a logarithmic ramp from (0, 0) to (1, 1).
24
+ */
25
+ function GetLogCurve() {
26
+ if (!LogCurve) {
27
+ LogCurve = new Float32Array(CurveLength);
28
+ const increment = 1 / CurveLength;
29
+ let x = increment;
30
+ for (let i = 0; i < CurveLength; i++) {
31
+ LogCurve[i] = 1 + Math.log10(x) / Math.log10(CurveLength);
32
+ x += increment;
33
+ }
34
+ }
35
+ return LogCurve;
36
+ }
37
+ /** @internal */
38
+ export function _GetAudioParamCurveValues(shape, from, to) {
39
+ if (!TmpCurveValues) {
40
+ TmpCurveValues = new Float32Array(CurveLength);
41
+ }
42
+ let normalizedCurve;
43
+ if (shape === "linear" /* AudioParameterRampShape.Linear */) {
44
+ TmpLineValues[0] = from;
45
+ TmpLineValues[1] = to;
46
+ return TmpLineValues;
47
+ }
48
+ else if (shape === "exponential" /* AudioParameterRampShape.Exponential */) {
49
+ normalizedCurve = GetExpCurve();
50
+ }
51
+ else if (shape === "logarithmic" /* AudioParameterRampShape.Logarithmic */) {
52
+ normalizedCurve = GetLogCurve();
53
+ }
54
+ else {
55
+ throw new Error(`Unknown ramp shape: ${shape}`);
56
+ }
57
+ const range = to - from;
58
+ for (let i = 0; i < normalizedCurve.length; i++) {
59
+ TmpCurveValues[i] = from + range * normalizedCurve[i];
60
+ }
61
+ return TmpCurveValues;
62
+ }
2
63
  /** @internal */
3
64
  export function _CleanUrl(url) {
4
65
  return url.replace(/#/gm, "%23");
@@ -1 +1 @@
1
- {"version":3,"file":"audioUtils.js","sourceRoot":"","sources":["../../../../dev/core/src/AudioV2/audioUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEtE,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAC,GAAW;IACjC,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC","sourcesContent":["export const _FileExtensionRegex = new RegExp(\"\\\\.(\\\\w{3,4})($|\\\\?)\");\n\n/** @internal */\nexport function _CleanUrl(url: string) {\n return url.replace(/#/gm, \"%23\");\n}\n"]}
1
+ {"version":3,"file":"audioUtils.js","sourceRoot":"","sources":["../../../../dev/core/src/AudioV2/audioUtils.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEtE,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,MAAM,aAAa,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/C,IAAI,cAAc,GAA2B,IAAI,CAAC;AAElD,IAAI,QAAQ,GAA2B,IAAI,CAAC;AAC5C,IAAI,QAAQ,GAA2B,IAAI,CAAC;AAE5C;;GAEG;AACH,SAAS,WAAW;IA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C,IAAI,KAAK,kDAAmC,EAAE,CAAC;QAC3C,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACxB,aAAa,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QACtB,OAAO,aAAa,CAAC;IACzB,CAAC;SAAM,IAAI,KAAK,4DAAwC,EAAE,CAAC;QACvD,eAAe,GAAG,WAAW,EAAE,CAAC;IACpC,CAAC;SAAM,IAAI,KAAK,4DAAwC,EAAE,CAAC;QACvD,eAAe,GAAG,WAAW,EAAE,CAAC;IACpC,CAAC;SAAM,CAAC;QACJ,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAC,GAAW;IACjC,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\nimport { AudioParameterRampShape } from \"./audioParameter\";\n\nexport const _FileExtensionRegex = new RegExp(\"\\\\.(\\\\w{3,4})($|\\\\?)\");\n\nconst CurveLength = 100;\n\nconst TmpLineValues = new Float32Array([0, 0]);\nlet TmpCurveValues: Nullable<Float32Array> = null;\n\nlet ExpCurve: Nullable<Float32Array> = null;\nlet LogCurve: Nullable<Float32Array> = null;\n\n/**\n * @returns A Float32Array representing an exponential ramp from (0, 0) to (1, 1).\n */\nfunction GetExpCurve(): Float32Array {\n if (!ExpCurve) {\n ExpCurve = new Float32Array(CurveLength);\n\n const increment = 1 / (CurveLength - 1);\n let x = increment;\n for (let i = 1; i < CurveLength; i++) {\n ExpCurve[i] = Math.exp(-11.512925464970227 * (1 - x));\n x += increment;\n }\n }\n\n return ExpCurve;\n}\n\n/**\n * @returns A Float32Array representing a logarithmic ramp from (0, 0) to (1, 1).\n */\nfunction GetLogCurve(): Float32Array {\n if (!LogCurve) {\n LogCurve = new Float32Array(CurveLength);\n\n const increment = 1 / CurveLength;\n let x = increment;\n for (let i = 0; i < CurveLength; i++) {\n LogCurve[i] = 1 + Math.log10(x) / Math.log10(CurveLength);\n x += increment;\n }\n }\n\n return LogCurve;\n}\n\n/** @internal */\nexport function _GetAudioParamCurveValues(shape: AudioParameterRampShape, from: number, to: number): Float32Array {\n if (!TmpCurveValues) {\n TmpCurveValues = new Float32Array(CurveLength);\n }\n\n let normalizedCurve: Float32Array;\n\n if (shape === AudioParameterRampShape.Linear) {\n TmpLineValues[0] = from;\n TmpLineValues[1] = to;\n return TmpLineValues;\n } else if (shape === AudioParameterRampShape.Exponential) {\n normalizedCurve = GetExpCurve();\n } else if (shape === AudioParameterRampShape.Logarithmic) {\n normalizedCurve = GetLogCurve();\n } else {\n throw new Error(`Unknown ramp shape: ${shape}`);\n }\n\n const range = to - from;\n for (let i = 0; i < normalizedCurve.length; i++) {\n TmpCurveValues[i] = from + range * normalizedCurve[i];\n }\n\n return TmpCurveValues;\n}\n\n/** @internal */\nexport function _CleanUrl(url: string) {\n return url.replace(/#/gm, \"%23\");\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export * from "./abstractAudio/index.js";
2
+ export * from "./audioParameter.js";
2
3
  export * from "./soundState.js";
3
4
  export * from "./spatialAudioAttachmentType.js";
4
5
  export * from "./webAudio/index.js";
package/AudioV2/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable import/no-internal-modules */
2
2
  export * from "./abstractAudio/index.js";
3
+ export * from "./audioParameter.js";
3
4
  export * from "./soundState.js";
4
5
  export * from "./spatialAudioAttachmentType.js";
5
6
  export * from "./webAudio/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/AudioV2/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\nexport * from \"./abstractAudio/index\";\nexport * from \"./soundState\";\nexport * from \"./spatialAudioAttachmentType\";\nexport * from \"./webAudio/index\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/AudioV2/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\nexport * from \"./abstractAudio/index\";\nexport * from \"./audioParameter\";\nexport * from \"./soundState\";\nexport * from \"./spatialAudioAttachmentType\";\nexport * from \"./webAudio/index\";\n"]}
@@ -0,0 +1,37 @@
1
+ import type { Nullable } from "../../../types.js";
2
+ import type { IAudioParameterRampOptions } from "../../audioParameter.js";
3
+ import type { _WebAudioEngine } from "../webAudioEngine.js";
4
+ /** @internal */
5
+ export declare class _WebAudioParameterComponent {
6
+ private _rampEndTime;
7
+ private _engine;
8
+ private _param;
9
+ private _targetValue;
10
+ /** @internal */
11
+ constructor(engine: _WebAudioEngine, param: AudioParam);
12
+ /** @internal */
13
+ get targetValue(): number;
14
+ set targetValue(value: number);
15
+ /** @internal */
16
+ get value(): number;
17
+ /** @internal */
18
+ dispose(): void;
19
+ /**
20
+ * Sets the target value of the audio parameter with an optional ramping duration and shape.
21
+ *
22
+ * If a ramp is close to finishing, it will wait for the ramp to finish before setting the new value; otherwise it
23
+ * will throw an error because of a bug in Firefox that prevents active ramps from being cancelled with
24
+ * `cancelScheduledValues`. See https://bugzilla.mozilla.org/show_bug.cgi?id=1752775. Other browsers do not have
25
+ * this issue, but we throw an error in all browsers to ensure consistent behavior.
26
+ *
27
+ * There are other similar WebAudio APIs for ramping parameters, (e.g. `linearRampToValueAtTime` and
28
+ * `exponentialRampToValueAtTime`) but they don't work in Firefox and Meta Quest Chrome.
29
+ *
30
+ * It may be better in the long run to implement our own ramping logic with a WASM audio worklet instead of using
31
+ * `setValueCurveAtTime`. Another alternative is to use `setValueAtTime` wtih a custom shape, but that will
32
+ * probably be a performance hit to maintain quality at audio rates.
33
+ *
34
+ * @internal
35
+ */
36
+ setTargetValue(value: number, options?: Nullable<Partial<IAudioParameterRampOptions>>): void;
37
+ }
@@ -0,0 +1,89 @@
1
+ import { _GetAudioParamCurveValues } from "../../audioUtils.js";
2
+ /**
3
+ * Maximum time in seconds to wait for an active ramp to finish before starting a new ramp.
4
+ *
5
+ * New ramps will throw an error if the active ramp has more than this amount of time remaining.
6
+ *
7
+ * This is needed because short ramps are used to avoid pops and clicks when setting audio parameters, and we
8
+ * don't want to throw an error if a short ramp is active.
9
+ *
10
+ * This constant is set to 11 milliseconds, which is short enough to avoid perceptual differences in most cases, but
11
+ * long enough to allow for short ramps to be completed in a reasonable time frame.
12
+ */
13
+ const MaxWaitTime = 0.011;
14
+ /**
15
+ * Minimum duration in seconds for a ramp to be considered valid.
16
+ *
17
+ * If the duration is less than this value, the value will be set immediately instead of being ramped smoothly since
18
+ * there is no perceptual difference for such short durations, so a ramp is not needed.
19
+ */
20
+ const MinRampDuration = 0.000001;
21
+ /** @internal */
22
+ export class _WebAudioParameterComponent {
23
+ /** @internal */
24
+ constructor(engine, param) {
25
+ this._rampEndTime = 0;
26
+ this._engine = engine;
27
+ this._param = param;
28
+ this._targetValue = param.value;
29
+ }
30
+ /** @internal */
31
+ get targetValue() {
32
+ return this._targetValue;
33
+ }
34
+ set targetValue(value) {
35
+ this.setTargetValue(value);
36
+ }
37
+ /** @internal */
38
+ get value() {
39
+ return this._param.value;
40
+ }
41
+ /** @internal */
42
+ dispose() {
43
+ this._param = null;
44
+ this._engine = null;
45
+ }
46
+ /**
47
+ * Sets the target value of the audio parameter with an optional ramping duration and shape.
48
+ *
49
+ * If a ramp is close to finishing, it will wait for the ramp to finish before setting the new value; otherwise it
50
+ * will throw an error because of a bug in Firefox that prevents active ramps from being cancelled with
51
+ * `cancelScheduledValues`. See https://bugzilla.mozilla.org/show_bug.cgi?id=1752775. Other browsers do not have
52
+ * this issue, but we throw an error in all browsers to ensure consistent behavior.
53
+ *
54
+ * There are other similar WebAudio APIs for ramping parameters, (e.g. `linearRampToValueAtTime` and
55
+ * `exponentialRampToValueAtTime`) but they don't work in Firefox and Meta Quest Chrome.
56
+ *
57
+ * It may be better in the long run to implement our own ramping logic with a WASM audio worklet instead of using
58
+ * `setValueCurveAtTime`. Another alternative is to use `setValueAtTime` wtih a custom shape, but that will
59
+ * probably be a performance hit to maintain quality at audio rates.
60
+ *
61
+ * @internal
62
+ */
63
+ setTargetValue(value, options = null) {
64
+ if (this._targetValue === value) {
65
+ return;
66
+ }
67
+ const shape = typeof options?.shape === "string" ? options.shape : "linear" /* AudioParameterRampShape.Linear */;
68
+ let duration = typeof options?.duration === "number" ? Math.max(options.duration, this._engine.parameterRampDuration) : this._engine.parameterRampDuration;
69
+ let startTime = this._engine.currentTime;
70
+ if (startTime < this._rampEndTime) {
71
+ const timeLeft = this._rampEndTime - startTime;
72
+ if (MaxWaitTime < timeLeft) {
73
+ throw new Error("Audio parameter not set. Wait for current ramp to finish.");
74
+ }
75
+ else {
76
+ duration -= timeLeft;
77
+ startTime = this._rampEndTime;
78
+ }
79
+ }
80
+ if ((duration = Math.max(this._engine.parameterRampDuration, duration)) < MinRampDuration) {
81
+ this._param.setValueAtTime((this._targetValue = value), startTime);
82
+ return;
83
+ }
84
+ this._param.cancelScheduledValues(startTime);
85
+ this._param.setValueCurveAtTime(_GetAudioParamCurveValues(shape, this._targetValue, (this._targetValue = value)), startTime, duration);
86
+ this._rampEndTime = startTime + duration;
87
+ }
88
+ }
89
+ //# sourceMappingURL=webAudioParameterComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webAudioParameterComponent.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/components/webAudioParameterComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAG7D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEjC,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAMpC,gBAAgB;IAChB,YAAY,MAAuB,EAAE,KAAiB;QAN9C,iBAAY,GAAW,CAAC,CAAC;QAO7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,gBAAgB;IAChB,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,IAAW,WAAW,CAAC,KAAa;QAChC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,gBAAgB;IAChB,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED,gBAAgB;IACT,OAAO;QACV,IAAI,CAAC,MAAM,GAAG,IAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,IAAK,CAAC;IACzB,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACI,cAAc,CAAC,KAAa,EAAE,UAAyD,IAAI;QAC9F,IAAI,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE,CAAC;YAC9B,OAAO;QACX,CAAC;QAED,MAAM,K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,CAAC,CAAC;QAEvI,IAAI,CAAC,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC7C,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\nimport type { IAudioParameterRampOptions } from \"../../audioParameter\";\nimport { AudioParameterRampShape } from \"../../audioParameter\";\nimport { _GetAudioParamCurveValues } from \"../../audioUtils\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\n\n/**\n * Maximum time in seconds to wait for an active ramp to finish before starting a new ramp.\n *\n * New ramps will throw an error if the active ramp has more than this amount of time remaining.\n *\n * This is needed because short ramps are used to avoid pops and clicks when setting audio parameters, and we\n * don't want to throw an error if a short ramp is active.\n *\n * This constant is set to 11 milliseconds, which is short enough to avoid perceptual differences in most cases, but\n * long enough to allow for short ramps to be completed in a reasonable time frame.\n */\nconst MaxWaitTime = 0.011;\n\n/**\n * Minimum duration in seconds for a ramp to be considered valid.\n *\n * If the duration is less than this value, the value will be set immediately instead of being ramped smoothly since\n * there is no perceptual difference for such short durations, so a ramp is not needed.\n */\nconst MinRampDuration = 0.000001;\n\n/** @internal */\nexport class _WebAudioParameterComponent {\n private _rampEndTime: number = 0;\n private _engine: _WebAudioEngine;\n private _param: AudioParam;\n private _targetValue: number;\n\n /** @internal */\n constructor(engine: _WebAudioEngine, param: AudioParam) {\n this._engine = engine;\n this._param = param;\n this._targetValue = param.value;\n }\n\n /** @internal */\n public get targetValue(): number {\n return this._targetValue;\n }\n\n public set targetValue(value: number) {\n this.setTargetValue(value);\n }\n\n /** @internal */\n public get value(): number {\n return this._param.value;\n }\n\n /** @internal */\n public dispose(): void {\n this._param = null!;\n this._engine = null!;\n }\n\n /**\n * Sets the target value of the audio parameter with an optional ramping duration and shape.\n *\n * If a ramp is close to finishing, it will wait for the ramp to finish before setting the new value; otherwise it\n * will throw an error because of a bug in Firefox that prevents active ramps from being cancelled with\n * `cancelScheduledValues`. See https://bugzilla.mozilla.org/show_bug.cgi?id=1752775. Other browsers do not have\n * this issue, but we throw an error in all browsers to ensure consistent behavior.\n *\n * There are other similar WebAudio APIs for ramping parameters, (e.g. `linearRampToValueAtTime` and\n * `exponentialRampToValueAtTime`) but they don't work in Firefox and Meta Quest Chrome.\n *\n * It may be better in the long run to implement our own ramping logic with a WASM audio worklet instead of using\n * `setValueCurveAtTime`. Another alternative is to use `setValueAtTime` wtih a custom shape, but that will\n * probably be a performance hit to maintain quality at audio rates.\n *\n * @internal\n */\n public setTargetValue(value: number, options: Nullable<Partial<IAudioParameterRampOptions>> = null): void {\n if (this._targetValue === value) {\n return;\n }\n\n const shape = typeof options?.shape === \"string\" ? options.shape : AudioParameterRampShape.Linear;\n\n let duration = typeof options?.duration === \"number\" ? Math.max(options.duration, this._engine.parameterRampDuration) : this._engine.parameterRampDuration;\n let startTime = this._engine.currentTime;\n\n if (startTime < this._rampEndTime) {\n const timeLeft = this._rampEndTime - startTime;\n\n if (MaxWaitTime < timeLeft) {\n throw new Error(\"Audio parameter not set. Wait for current ramp to finish.\");\n } else {\n duration -= timeLeft;\n startTime = this._rampEndTime;\n }\n }\n\n if ((duration = Math.max(this._engine.parameterRampDuration, duration)) < MinRampDuration) {\n this._param.setValueAtTime((this._targetValue = value), startTime);\n return;\n }\n\n this._param.cancelScheduledValues(startTime);\n this._param.setValueCurveAtTime(_GetAudioParamCurveValues(shape, this._targetValue, (this._targetValue = value)), startTime, duration);\n\n this._rampEndTime = startTime + duration;\n }\n}\n"]}
@@ -9,6 +9,12 @@ export declare class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
9
9
  private _lastPosition;
10
10
  private _lastRotation;
11
11
  private _lastRotationQuaternion;
12
+ private _orientationX;
13
+ private _orientationY;
14
+ private _orientationZ;
15
+ private _positionX;
16
+ private _positionY;
17
+ private _positionZ;
12
18
  /** @internal */
13
19
  readonly engine: _WebAudioEngine;
14
20
  /** @internal */
@@ -22,6 +28,8 @@ export declare class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
22
28
  /** @internal */
23
29
  constructor(engine: _WebAudioEngine);
24
30
  /** @internal */
31
+ dispose(): void;
32
+ /** @internal */
25
33
  get coneInnerAngle(): number;
26
34
  set coneInnerAngle(value: number);
27
35
  /** @internal */
@@ -1,6 +1,7 @@
1
1
  import { Matrix, Quaternion, Vector3 } from "../../../Maths/math.vector.js";
2
2
  import { _SpatialAudioSubNode } from "../../abstractAudio/subNodes/spatialAudioSubNode.js";
3
3
  import { _SpatialAudioDefaults } from "../../abstractAudio/subProperties/abstractSpatialAudio.js";
4
+ import { _WebAudioParameterComponent } from "../components/webAudioParameterComponent.js";
4
5
  const TmpMatrix = Matrix.Zero();
5
6
  const TmpQuaternion = new Quaternion();
6
7
  const TmpVector = Vector3.Zero();
@@ -30,6 +31,23 @@ export class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
30
31
  /** @internal */
31
32
  this.rotationQuaternion = _SpatialAudioDefaults.rotationQuaternion.clone();
32
33
  this.node = new PannerNode(engine._audioContext);
34
+ this._orientationX = new _WebAudioParameterComponent(engine, this.node.orientationX);
35
+ this._orientationY = new _WebAudioParameterComponent(engine, this.node.orientationY);
36
+ this._orientationZ = new _WebAudioParameterComponent(engine, this.node.orientationZ);
37
+ this._positionX = new _WebAudioParameterComponent(engine, this.node.positionX);
38
+ this._positionY = new _WebAudioParameterComponent(engine, this.node.positionY);
39
+ this._positionZ = new _WebAudioParameterComponent(engine, this.node.positionZ);
40
+ }
41
+ /** @internal */
42
+ dispose() {
43
+ super.dispose();
44
+ this._orientationX.dispose();
45
+ this._orientationY.dispose();
46
+ this._orientationZ.dispose();
47
+ this._positionX.dispose();
48
+ this._positionY.dispose();
49
+ this._positionZ.dispose();
50
+ this.node.disconnect();
33
51
  }
34
52
  /** @internal */
35
53
  get coneInnerAngle() {
@@ -104,9 +122,9 @@ export class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
104
122
  if (this._lastPosition.equalsWithEpsilon(this.position)) {
105
123
  return;
106
124
  }
107
- this.engine._setAudioParam(this.node.positionX, this.position.x);
108
- this.engine._setAudioParam(this.node.positionY, this.position.y);
109
- this.engine._setAudioParam(this.node.positionZ, this.position.z);
125
+ this._positionX.targetValue = this.position.x;
126
+ this._positionY.targetValue = this.position.y;
127
+ this._positionZ.targetValue = this.position.z;
110
128
  this._lastPosition.copyFrom(this.position);
111
129
  }
112
130
  /** @internal */
@@ -124,9 +142,9 @@ export class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
124
142
  }
125
143
  Matrix.FromQuaternionToRef(TmpQuaternion, TmpMatrix);
126
144
  Vector3.TransformNormalToRef(Vector3.RightReadOnly, TmpMatrix, TmpVector);
127
- this.engine._setAudioParam(this.node.orientationX, TmpVector.x);
128
- this.engine._setAudioParam(this.node.orientationY, TmpVector.y);
129
- this.engine._setAudioParam(this.node.orientationZ, TmpVector.z);
145
+ this._orientationX.targetValue = TmpVector.x;
146
+ this._orientationY.targetValue = TmpVector.y;
147
+ this._orientationZ.targetValue = TmpVector.z;
130
148
  }
131
149
  _connect(node) {
132
150
  const connected = super._connect(node);
@@ -1 +1 @@
1
- {"version":3,"file":"spatialWebAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAI/F,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;AAChC,MAAM,aAAa,GAAG,IAAI,UAAU,EAAE,CAAC;AACvC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAEjC,SAAS,GAAG,CAAC,OAAe;IACxB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACrC,CAAC;AAED,SAAS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I,CAAC,CAAC;QAE7C,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gBAAgB;IACT,YAAY;QACf,OAAO,yBAAyB,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import { Matrix, Quaternion, Vector3 } from \"../../../Maths/math.vector\";\r\nimport { _SpatialAudioSubNode } from \"../../abstractAudio/subNodes/spatialAudioSubNode\";\r\nimport { _SpatialAudioDefaults } from \"../../abstractAudio/subProperties/abstractSpatialAudio\";\r\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\r\nimport type { IWebAudioInNode } from \"../webAudioNode\";\r\n\r\nconst TmpMatrix = Matrix.Zero();\r\nconst TmpQuaternion = new Quaternion();\r\nconst TmpVector = Vector3.Zero();\r\n\r\nfunction D2r(degrees: number): number {\r\n return (degrees * Math.PI) / 180;\r\n}\r\n\r\nfunction R2d(radians: number): number {\r\n return (radians * 180) / Math.PI;\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/require-await\r\nexport async function _CreateSpatialAudioSubNodeAsync(engine: _WebAudioEngine): Promise<_SpatialAudioSubNode> {\r\n return new _SpatialWebAudioSubNode(engine);\r\n}\r\n\r\n/** @internal */\r\nexport class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {\r\n private _lastPosition: Vector3 = Vector3.Zero();\r\n private _lastRotation: Vector3 = Vector3.Zero();\r\n private _lastRotationQuaternion: Quaternion = new Quaternion();\r\n\r\n /** @internal */\r\n public override readonly engine: _WebAudioEngine;\r\n\r\n /** @internal */\r\n public readonly position = _SpatialAudioDefaults.position.clone();\r\n /** @internal */\r\n public readonly rotation: Vector3 = _SpatialAudioDefaults.rotation.clone();\r\n /** @internal */\r\n public readonly rotationQuaternion: Quaternion = _SpatialAudioDefaults.rotationQuaternion.clone();\r\n\r\n /** @internal */\r\n public readonly node: PannerNode;\r\n\r\n /** @internal */\r\n public constructor(engine: _WebAudioEngine) {\r\n super(engine);\r\n\r\n this.node = new PannerNode(engine._audioContext);\r\n }\r\n\r\n /** @internal */\r\n public get coneInnerAngle(): number {\r\n return D2r(this.node.coneInnerAngle);\r\n }\r\n\r\n public set coneInnerAngle(value: number) {\r\n this.node.coneInnerAngle = R2d(value);\r\n }\r\n\r\n /** @internal */\r\n public get coneOuterAngle(): number {\r\n return D2r(this.node.coneOuterAngle);\r\n }\r\n\r\n public set coneOuterAngle(value: number) {\r\n this.node.coneOuterAngle = R2d(value);\r\n }\r\n\r\n /** @internal */\r\n public get coneOuterVolume(): number {\r\n return this.node.coneOuterGain;\r\n }\r\n\r\n public set coneOuterVolume(value: number) {\r\n this.node.coneOuterGain = value;\r\n }\r\n\r\n /** @internal */\r\n public get distanceModel(): \"linear\" | \"inverse\" | \"exponential\" {\r\n return this.node.distanceModel;\r\n }\r\n\r\n public set distanceModel(value: \"linear\" | \"inverse\" | \"exponential\") {\r\n this.node.distanceModel = value;\r\n\r\n // Wiggle the max distance to make the change take effect.\r\n const maxDistance = this.node.maxDistance;\r\n this.node.maxDistance = maxDistance + 0.001;\r\n this.node.maxDistance = maxDistance;\r\n }\r\n\r\n /** @internal */\r\n public get minDistance(): number {\r\n return this.node.refDistance;\r\n }\r\n\r\n public set minDistance(value: number) {\r\n this.node.refDistance = value;\r\n }\r\n\r\n /** @internal */\r\n public get maxDistance(): number {\r\n return this.node.maxDistance;\r\n }\r\n\r\n public set maxDistance(value: number) {\r\n this.node.maxDistance = value;\r\n }\r\n\r\n /** @internal */\r\n public get panningModel(): \"equalpower\" | \"HRTF\" {\r\n return this.node.panningModel;\r\n }\r\n\r\n public set panningModel(value: \"equalpower\" | \"HRTF\") {\r\n this.node.panningModel = value;\r\n }\r\n\r\n /** @internal */\r\n public get rolloffFactor(): number {\r\n return this.node.rolloffFactor;\r\n }\r\n\r\n public set rolloffFactor(value: number) {\r\n this.node.rolloffFactor = value;\r\n }\r\n\r\n /** @internal */\r\n public get _inNode(): AudioNode {\r\n return this.node;\r\n }\r\n\r\n /** @internal */\r\n public get _outNode(): AudioNode {\r\n return this.node;\r\n }\r\n\r\n /** @internal */\r\n public _updatePosition(): void {\r\n if (this._lastPosition.equalsWithEpsilon(this.position)) {\r\n return;\r\n }\r\n\r\n this.engine._setAudioParam(this.node.positionX, this.position.x);\r\n this.engine._setAudioParam(this.node.positionY, this.position.y);\r\n this.engine._setAudioParam(this.node.positionZ, this.position.z);\r\n\r\n this._lastPosition.copyFrom(this.position);\r\n }\r\n\r\n /** @internal */\r\n public _updateRotation(): void {\r\n if (!this._lastRotationQuaternion.equalsWithEpsilon(this.rotationQuaternion)) {\r\n TmpQuaternion.copyFrom(this.rotationQuaternion);\r\n this._lastRotationQuaternion.copyFrom(this.rotationQuaternion);\r\n } else if (!this._lastRotation.equalsWithEpsilon(this.rotation)) {\r\n Quaternion.FromEulerAnglesToRef(this.rotation.x, this.rotation.y, this.rotation.z, TmpQuaternion);\r\n this._lastRotation.copyFrom(this.rotation);\r\n } else {\r\n return;\r\n }\r\n\r\n Matrix.FromQuaternionToRef(TmpQuaternion, TmpMatrix);\r\n Vector3.TransformNormalToRef(Vector3.RightReadOnly, TmpMatrix, TmpVector);\r\n\r\n this.engine._setAudioParam(this.node.orientationX, TmpVector.x);\r\n this.engine._setAudioParam(this.node.orientationY, TmpVector.y);\r\n this.engine._setAudioParam(this.node.orientationZ, TmpVector.z);\r\n }\r\n\r\n protected override _connect(node: IWebAudioInNode): boolean {\r\n const connected = super._connect(node);\r\n\r\n if (!connected) {\r\n return false;\r\n }\r\n\r\n // If the wrapped node is not available now, it will be connected later by the subgraph.\r\n if (node._inNode) {\r\n this.node.connect(node._inNode);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n protected override _disconnect(node: IWebAudioInNode): boolean {\r\n const disconnected = super._disconnect(node);\r\n\r\n if (!disconnected) {\r\n return false;\r\n }\r\n\r\n if (node._inNode) {\r\n this.node.disconnect(node._inNode);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public getClassName(): string {\r\n return \"_SpatialWebAudioSubNode\";\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"spatialWebAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAIvF,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;AAChC,MAAM,aAAa,GAAG,IAAI,UAAU,EAAE,CAAC;AACvC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAEjC,SAAS,GAAG,CAAC,OAAe;IACxB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACrC,CAAC;AAED,SAAS,GAAG,CAAC,OAAe;IACxB,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AACrC,CAAC;AAED,gBAAgB;AAChB,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,MAAuB;IACzE,OAAO,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,uBAAwB,SAAQ,oBAAoB;IAwB7D,gBAAgB;IAChB,YAAmB,MAAuB;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;QAzBV,kBAA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,QAAQ,CAAC,IAAqB;QAC7C,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEvC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,wFAAwF;QACxF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEkB,WAAW,CAAC,IAAqB;QAChD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gBAAgB;IACT,YAAY;QACf,OAAO,yBAAyB,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import { Matrix, Quaternion, Vector3 } from \"../../../Maths/math.vector\";\r\nimport { _SpatialAudioSubNode } from \"../../abstractAudio/subNodes/spatialAudioSubNode\";\r\nimport { _SpatialAudioDefaults } from \"../../abstractAudio/subProperties/abstractSpatialAudio\";\r\nimport { _WebAudioParameterComponent } from \"../components/webAudioParameterComponent\";\r\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\r\nimport type { IWebAudioInNode } from \"../webAudioNode\";\r\n\r\nconst TmpMatrix = Matrix.Zero();\r\nconst TmpQuaternion = new Quaternion();\r\nconst TmpVector = Vector3.Zero();\r\n\r\nfunction D2r(degrees: number): number {\r\n return (degrees * Math.PI) / 180;\r\n}\r\n\r\nfunction R2d(radians: number): number {\r\n return (radians * 180) / Math.PI;\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/require-await\r\nexport async function _CreateSpatialAudioSubNodeAsync(engine: _WebAudioEngine): Promise<_SpatialAudioSubNode> {\r\n return new _SpatialWebAudioSubNode(engine);\r\n}\r\n\r\n/** @internal */\r\nexport class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {\r\n private _lastPosition: Vector3 = Vector3.Zero();\r\n private _lastRotation: Vector3 = Vector3.Zero();\r\n private _lastRotationQuaternion: Quaternion = new Quaternion();\r\n private _orientationX: _WebAudioParameterComponent;\r\n private _orientationY: _WebAudioParameterComponent;\r\n private _orientationZ: _WebAudioParameterComponent;\r\n private _positionX: _WebAudioParameterComponent;\r\n private _positionY: _WebAudioParameterComponent;\r\n private _positionZ: _WebAudioParameterComponent;\r\n\r\n /** @internal */\r\n public override readonly engine: _WebAudioEngine;\r\n\r\n /** @internal */\r\n public readonly position = _SpatialAudioDefaults.position.clone();\r\n /** @internal */\r\n public readonly rotation: Vector3 = _SpatialAudioDefaults.rotation.clone();\r\n /** @internal */\r\n public readonly rotationQuaternion: Quaternion = _SpatialAudioDefaults.rotationQuaternion.clone();\r\n\r\n /** @internal */\r\n public readonly node: PannerNode;\r\n\r\n /** @internal */\r\n public constructor(engine: _WebAudioEngine) {\r\n super(engine);\r\n\r\n this.node = new PannerNode(engine._audioContext);\r\n\r\n this._orientationX = new _WebAudioParameterComponent(engine, this.node.orientationX);\r\n this._orientationY = new _WebAudioParameterComponent(engine, this.node.orientationY);\r\n this._orientationZ = new _WebAudioParameterComponent(engine, this.node.orientationZ);\r\n\r\n this._positionX = new _WebAudioParameterComponent(engine, this.node.positionX);\r\n this._positionY = new _WebAudioParameterComponent(engine, this.node.positionY);\r\n this._positionZ = new _WebAudioParameterComponent(engine, this.node.positionZ);\r\n }\r\n\r\n /** @internal */\r\n public override dispose(): void {\r\n super.dispose();\r\n\r\n this._orientationX.dispose();\r\n this._orientationY.dispose();\r\n this._orientationZ.dispose();\r\n this._positionX.dispose();\r\n this._positionY.dispose();\r\n this._positionZ.dispose();\r\n\r\n this.node.disconnect();\r\n }\r\n\r\n /** @internal */\r\n public get coneInnerAngle(): number {\r\n return D2r(this.node.coneInnerAngle);\r\n }\r\n\r\n public set coneInnerAngle(value: number) {\r\n this.node.coneInnerAngle = R2d(value);\r\n }\r\n\r\n /** @internal */\r\n public get coneOuterAngle(): number {\r\n return D2r(this.node.coneOuterAngle);\r\n }\r\n\r\n public set coneOuterAngle(value: number) {\r\n this.node.coneOuterAngle = R2d(value);\r\n }\r\n\r\n /** @internal */\r\n public get coneOuterVolume(): number {\r\n return this.node.coneOuterGain;\r\n }\r\n\r\n public set coneOuterVolume(value: number) {\r\n this.node.coneOuterGain = value;\r\n }\r\n\r\n /** @internal */\r\n public get distanceModel(): \"linear\" | \"inverse\" | \"exponential\" {\r\n return this.node.distanceModel;\r\n }\r\n\r\n public set distanceModel(value: \"linear\" | \"inverse\" | \"exponential\") {\r\n this.node.distanceModel = value;\r\n\r\n // Wiggle the max distance to make the change take effect.\r\n const maxDistance = this.node.maxDistance;\r\n this.node.maxDistance = maxDistance + 0.001;\r\n this.node.maxDistance = maxDistance;\r\n }\r\n\r\n /** @internal */\r\n public get minDistance(): number {\r\n return this.node.refDistance;\r\n }\r\n\r\n public set minDistance(value: number) {\r\n this.node.refDistance = value;\r\n }\r\n\r\n /** @internal */\r\n public get maxDistance(): number {\r\n return this.node.maxDistance;\r\n }\r\n\r\n public set maxDistance(value: number) {\r\n this.node.maxDistance = value;\r\n }\r\n\r\n /** @internal */\r\n public get panningModel(): \"equalpower\" | \"HRTF\" {\r\n return this.node.panningModel;\r\n }\r\n\r\n public set panningModel(value: \"equalpower\" | \"HRTF\") {\r\n this.node.panningModel = value;\r\n }\r\n\r\n /** @internal */\r\n public get rolloffFactor(): number {\r\n return this.node.rolloffFactor;\r\n }\r\n\r\n public set rolloffFactor(value: number) {\r\n this.node.rolloffFactor = value;\r\n }\r\n\r\n /** @internal */\r\n public get _inNode(): AudioNode {\r\n return this.node;\r\n }\r\n\r\n /** @internal */\r\n public get _outNode(): AudioNode {\r\n return this.node;\r\n }\r\n\r\n /** @internal */\r\n public _updatePosition(): void {\r\n if (this._lastPosition.equalsWithEpsilon(this.position)) {\r\n return;\r\n }\r\n\r\n this._positionX.targetValue = this.position.x;\r\n this._positionY.targetValue = this.position.y;\r\n this._positionZ.targetValue = this.position.z;\r\n\r\n this._lastPosition.copyFrom(this.position);\r\n }\r\n\r\n /** @internal */\r\n public _updateRotation(): void {\r\n if (!this._lastRotationQuaternion.equalsWithEpsilon(this.rotationQuaternion)) {\r\n TmpQuaternion.copyFrom(this.rotationQuaternion);\r\n this._lastRotationQuaternion.copyFrom(this.rotationQuaternion);\r\n } else if (!this._lastRotation.equalsWithEpsilon(this.rotation)) {\r\n Quaternion.FromEulerAnglesToRef(this.rotation.x, this.rotation.y, this.rotation.z, TmpQuaternion);\r\n this._lastRotation.copyFrom(this.rotation);\r\n } else {\r\n return;\r\n }\r\n\r\n Matrix.FromQuaternionToRef(TmpQuaternion, TmpMatrix);\r\n Vector3.TransformNormalToRef(Vector3.RightReadOnly, TmpMatrix, TmpVector);\r\n\r\n this._orientationX.targetValue = TmpVector.x;\r\n this._orientationY.targetValue = TmpVector.y;\r\n this._orientationZ.targetValue = TmpVector.z;\r\n }\r\n\r\n protected override _connect(node: IWebAudioInNode): boolean {\r\n const connected = super._connect(node);\r\n\r\n if (!connected) {\r\n return false;\r\n }\r\n\r\n // If the wrapped node is not available now, it will be connected later by the subgraph.\r\n if (node._inNode) {\r\n this.node.connect(node._inNode);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n protected override _disconnect(node: IWebAudioInNode): boolean {\r\n const disconnected = super._disconnect(node);\r\n\r\n if (!disconnected) {\r\n return false;\r\n }\r\n\r\n if (node._inNode) {\r\n this.node.disconnect(node._inNode);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public getClassName(): string {\r\n return \"_SpatialWebAudioSubNode\";\r\n }\r\n}\r\n"]}
@@ -13,6 +13,8 @@ export declare class _StereoWebAudioSubNode extends _StereoAudioSubNode {
13
13
  /** @internal */
14
14
  constructor(engine: _WebAudioEngine);
15
15
  /** @internal */
16
+ dispose(): void;
17
+ /** @internal */
16
18
  get pan(): number;
17
19
  /** @internal */
18
20
  set pan(value: number);
@@ -1,4 +1,5 @@
1
1
  import { _StereoAudioSubNode } from "../../abstractAudio/subNodes/stereoAudioSubNode.js";
2
+ import { _WebAudioParameterComponent } from "../components/webAudioParameterComponent.js";
2
3
  /** @internal */
3
4
  // eslint-disable-next-line @typescript-eslint/require-await
4
5
  export async function _CreateStereoAudioSubNodeAsync(engine) {
@@ -9,17 +10,21 @@ export class _StereoWebAudioSubNode extends _StereoAudioSubNode {
9
10
  /** @internal */
10
11
  constructor(engine) {
11
12
  super(engine);
12
- this._pan = 0;
13
13
  this.node = new StereoPannerNode(engine._audioContext);
14
+ this._pan = new _WebAudioParameterComponent(engine, this.node.pan);
15
+ }
16
+ /** @internal */
17
+ dispose() {
18
+ super.dispose();
19
+ this._pan.dispose();
14
20
  }
15
21
  /** @internal */
16
22
  get pan() {
17
- return this._pan;
23
+ return this._pan.targetValue;
18
24
  }
19
25
  /** @internal */
20
26
  set pan(value) {
21
- this._pan = value;
22
- this.engine._setAudioParam(this.node.pan, value);
27
+ this._pan.targetValue = value;
23
28
  }
24
29
  /** @internal */
25
30
  get _inNode() {
@@ -1 +1 @@
1
- {"version":3,"file":"stereoWebAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAItF,gBAAgB;AAChB,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,MAAuB;IACxE,OAAO,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SA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OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import { _StereoAudioSubNode } from \"../../abstractAudio/subNodes/stereoAudioSubNode\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\nimport type { IWebAudioInNode } from \"../webAudioNode\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function _CreateStereoAudioSubNodeAsync(engine: _WebAudioEngine): Promise<_StereoAudioSubNode> {\n return new _StereoWebAudioSubNode(engine);\n}\n\n/** @internal */\nexport class _StereoWebAudioSubNode extends _StereoAudioSubNode {\n private _pan: number = 0;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public readonly node: StereoPannerNode;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n\n this.node = new StereoPannerNode(engine._audioContext);\n }\n\n /** @internal */\n public get pan(): number {\n return this._pan;\n }\n\n /** @internal */\n public set pan(value: number) {\n this._pan = value;\n this.engine._setAudioParam(this.node.pan, value);\n }\n\n /** @internal */\n public get _inNode(): AudioNode {\n return this.node;\n }\n\n /** @internal */\n public get _outNode(): AudioNode {\n return this.node;\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_StereoWebAudioSubNode\";\n }\n\n protected override _connect(node: IWebAudioInNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the subgraph.\n if (node._inNode) {\n this.node.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: IWebAudioInNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node._inNode) {\n this.node.disconnect(node._inNode);\n }\n\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"stereoWebAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/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AAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEvC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,wFAAwF;QACxF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEkB,WAAW,CAAC,IAAqB;QAChD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import { _StereoAudioSubNode } from \"../../abstractAudio/subNodes/stereoAudioSubNode\";\nimport { _WebAudioParameterComponent } from \"../components/webAudioParameterComponent\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\nimport type { IWebAudioInNode } from \"../webAudioNode\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function _CreateStereoAudioSubNodeAsync(engine: _WebAudioEngine): Promise<_StereoAudioSubNode> {\n return new _StereoWebAudioSubNode(engine);\n}\n\n/** @internal */\nexport class _StereoWebAudioSubNode extends _StereoAudioSubNode {\n private _pan: _WebAudioParameterComponent;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public readonly node: StereoPannerNode;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n\n this.node = new StereoPannerNode(engine._audioContext);\n\n this._pan = new _WebAudioParameterComponent(engine, this.node.pan);\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._pan.dispose();\n }\n\n /** @internal */\n public get pan(): number {\n return this._pan.targetValue;\n }\n\n /** @internal */\n public set pan(value: number) {\n this._pan.targetValue = value;\n }\n\n /** @internal */\n public get _inNode(): AudioNode {\n return this.node;\n }\n\n /** @internal */\n public get _outNode(): AudioNode {\n return this.node;\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_StereoWebAudioSubNode\";\n }\n\n protected override _connect(node: IWebAudioInNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the subgraph.\n if (node._inNode) {\n this.node.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: IWebAudioInNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node._inNode) {\n this.node.disconnect(node._inNode);\n }\n\n return true;\n }\n}\n"]}
@@ -1,4 +1,6 @@
1
+ import type { Nullable } from "../../../types.js";
1
2
  import { _VolumeAudioSubNode } from "../../abstractAudio/subNodes/volumeAudioSubNode.js";
3
+ import type { IAudioParameterRampOptions } from "../../audioParameter.js";
2
4
  import type { _WebAudioEngine } from "../webAudioEngine.js";
3
5
  import type { IWebAudioInNode, IWebAudioSubNode } from "../webAudioNode.js";
4
6
  /** @internal */
@@ -9,10 +11,12 @@ export declare class _VolumeWebAudioSubNode extends _VolumeAudioSubNode implemen
9
11
  /** @internal */
10
12
  readonly engine: _WebAudioEngine;
11
13
  /** @internal */
12
- readonly node: GainNode;
14
+ readonly node: AudioNode;
13
15
  /** @internal */
14
16
  constructor(engine: _WebAudioEngine);
15
17
  /** @internal */
18
+ dispose(): void;
19
+ /** @internal */
16
20
  get volume(): number;
17
21
  /** @internal */
18
22
  set volume(value: number);
@@ -20,6 +24,8 @@ export declare class _VolumeWebAudioSubNode extends _VolumeAudioSubNode implemen
20
24
  get _inNode(): AudioNode;
21
25
  /** @internal */
22
26
  get _outNode(): AudioNode;
27
+ /** @internal */
28
+ setVolume(value: number, options?: Nullable<Partial<IAudioParameterRampOptions>>): void;
23
29
  protected _connect(node: IWebAudioInNode): boolean;
24
30
  protected _disconnect(node: IWebAudioInNode): boolean;
25
31
  /** @internal */
@@ -1,4 +1,5 @@
1
1
  import { _VolumeAudioSubNode } from "../../abstractAudio/subNodes/volumeAudioSubNode.js";
2
+ import { _WebAudioParameterComponent } from "../components/webAudioParameterComponent.js";
2
3
  /** @internal */
3
4
  // eslint-disable-next-line @typescript-eslint/require-await
4
5
  export async function _CreateVolumeAudioSubNodeAsync(engine) {
@@ -9,17 +10,21 @@ export class _VolumeWebAudioSubNode extends _VolumeAudioSubNode {
9
10
  /** @internal */
10
11
  constructor(engine) {
11
12
  super(engine);
12
- this._volume = 1;
13
- this.node = new GainNode(engine._audioContext);
13
+ const gainNode = (this.node = new GainNode(engine._audioContext));
14
+ this._volume = new _WebAudioParameterComponent(engine, gainNode.gain);
15
+ }
16
+ /** @internal */
17
+ dispose() {
18
+ super.dispose();
19
+ this._volume.dispose();
14
20
  }
15
21
  /** @internal */
16
22
  get volume() {
17
- return this._volume;
23
+ return this._volume.value;
18
24
  }
19
25
  /** @internal */
20
26
  set volume(value) {
21
- this._volume = value;
22
- this.engine._setAudioParam(this.node.gain, value);
27
+ this.setVolume(value);
23
28
  }
24
29
  /** @internal */
25
30
  get _inNode() {
@@ -29,6 +34,10 @@ export class _VolumeWebAudioSubNode extends _VolumeAudioSubNode {
29
34
  get _outNode() {
30
35
  return this.node;
31
36
  }
37
+ /** @internal */
38
+ setVolume(value, options = null) {
39
+ this._volume.setTargetValue(value, options);
40
+ }
32
41
  _connect(node) {
33
42
  const connected = super._connect(node);
34
43
  if (!connected) {
@@ -1 +1 @@
1
- {"version":3,"file":"volumeWebAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAItF,gBAAgB;AAChB,4DAA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AC;QAE7C,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gBAAgB;IACT,YAAY;QACf,OAAO,wBAAwB,CAAC;IACpC,CAAC;CACJ","sourcesContent":["import { _VolumeAudioSubNode } from \"../../abstractAudio/subNodes/volumeAudioSubNode\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\nimport type { IWebAudioInNode, IWebAudioSubNode } from \"../webAudioNode\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function _CreateVolumeAudioSubNodeAsync(engine: _WebAudioEngine): Promise<_VolumeAudioSubNode> {\n return new _VolumeWebAudioSubNode(engine);\n}\n\n/** @internal */\nexport class _VolumeWebAudioSubNode extends _VolumeAudioSubNode implements IWebAudioSubNode {\n private _volume: number = 1;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public readonly node: GainNode;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n\n this.node = new GainNode(engine._audioContext);\n }\n\n /** @internal */\n public get volume(): number {\n return this._volume;\n }\n\n /** @internal */\n public set volume(value: number) {\n this._volume = value;\n this.engine._setAudioParam(this.node.gain, value);\n }\n\n /** @internal */\n public get _inNode(): AudioNode {\n return this.node;\n }\n\n /** @internal */\n public get _outNode(): AudioNode {\n return this.node;\n }\n\n protected override _connect(node: IWebAudioInNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the subgraph.\n if (node._inNode) {\n this.node.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: IWebAudioInNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node._inNode) {\n this.node.disconnect(node._inNode);\n }\n\n return true;\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_VolumeWebAudioSubNode\";\n }\n}\n"]}
1
+ {"version":3,"file":"volumeWebAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAEtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAIvF,gBAAgB;AAChB,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,MAAuB;IACxE,OAAO,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,mBAAmB;IAS3D,gBAAgB;IAChB,YAAmB,MAAuB;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO,GAAG,IAAI,2BAA2B,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IAED,gBAAgB;IACA,OAAO;QACnB,KAAK,CAAC,OAAO,EAAE,CAAC;QAEhB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,gBAAgB;IAChB,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC9B,CAAC;IAED,gBAAgB;IAChB,IAAW,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,gBAAgB;IAChB,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,gBAAgB;IACT,SAAS,CAAC,KAAa,EAAE,UAAyD,IAAI;QACzF,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAEkB,QAAQ,CAAC,IAAqB;QAC7C,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEvC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,wFAAwF;QACxF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEkB,WAAW,CAAC,IAAqB;QAChD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gBAAgB;IACT,YAAY;QACf,OAAO,wBAAwB,CAAC;IACpC,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\nimport { _VolumeAudioSubNode } from \"../../abstractAudio/subNodes/volumeAudioSubNode\";\nimport type { IAudioParameterRampOptions } from \"../../audioParameter\";\nimport { _WebAudioParameterComponent } from \"../components/webAudioParameterComponent\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\nimport type { IWebAudioInNode, IWebAudioSubNode } from \"../webAudioNode\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function _CreateVolumeAudioSubNodeAsync(engine: _WebAudioEngine): Promise<_VolumeAudioSubNode> {\n return new _VolumeWebAudioSubNode(engine);\n}\n\n/** @internal */\nexport class _VolumeWebAudioSubNode extends _VolumeAudioSubNode implements IWebAudioSubNode {\n private _volume: _WebAudioParameterComponent;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public readonly node: AudioNode;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n\n const gainNode = (this.node = new GainNode(engine._audioContext));\n this._volume = new _WebAudioParameterComponent(engine, gainNode.gain);\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._volume.dispose();\n }\n\n /** @internal */\n public get volume(): number {\n return this._volume.value;\n }\n\n /** @internal */\n public set volume(value: number) {\n this.setVolume(value);\n }\n\n /** @internal */\n public get _inNode(): AudioNode {\n return this.node;\n }\n\n /** @internal */\n public get _outNode(): AudioNode {\n return this.node;\n }\n\n /** @internal */\n public setVolume(value: number, options: Nullable<Partial<IAudioParameterRampOptions>> = null): void {\n this._volume.setTargetValue(value, options);\n }\n\n protected override _connect(node: IWebAudioInNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the subgraph.\n if (node._inNode) {\n this.node.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: IWebAudioInNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node._inNode) {\n this.node.disconnect(node._inNode);\n }\n\n return true;\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_VolumeWebAudioSubNode\";\n }\n}\n"]}