@woosh/meep-engine 3.45.0 → 3.47.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 (435) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/editor/actions/concrete/TransformModifyAction.d.ts.map +1 -1
  3. package/editor/actions/concrete/TransformModifyAction.js +10 -2
  4. package/editor/ecs/component/FieldDescriptor.js +15 -0
  5. package/editor/ecs/component/createObjectEditor.js +41 -12
  6. package/editor/ecs/component/editors/ecs/Transform64Editor.d.ts.map +1 -1
  7. package/editor/ecs/component/editors/ecs/Transform64Editor.js +77 -70
  8. package/editor/tools/TransformToolV2.d.ts.map +1 -1
  9. package/editor/tools/TransformToolV2.js +4 -0
  10. package/editor/tools/v2/TransformControls.d.ts.map +1 -1
  11. package/editor/tools/v2/TransformControls.js +7 -0
  12. package/editor/view/ecs/EntityEditor.d.ts.map +1 -1
  13. package/editor/view/ecs/EntityEditor.js +4 -2
  14. package/package.json +1 -1
  15. package/src/core/assert.d.ts.map +1 -1
  16. package/src/core/assert.js +5 -1
  17. package/src/core/binary/hash/XXH128Hash.d.ts +1 -37
  18. package/src/core/binary/hash/XXH128Hash.d.ts.map +1 -1
  19. package/src/core/binary/hash/XXH128Hash.js +4 -55
  20. package/src/core/binary/hash/XXH3_SECRET.d.ts +1 -12
  21. package/src/core/binary/hash/XXH3_SECRET.d.ts.map +1 -1
  22. package/src/core/binary/hash/XXH3_SECRET.js +4 -25
  23. package/src/core/binary/hash/crc32.d.ts +1 -15
  24. package/src/core/binary/hash/crc32.d.ts.map +1 -1
  25. package/src/core/binary/hash/crc32.js +4 -96
  26. package/src/core/binary/hash/xxh3_128.d.ts +1 -9
  27. package/src/core/binary/hash/xxh3_128.d.ts.map +1 -1
  28. package/src/core/binary/hash/xxh3_128.js +4 -341
  29. package/src/core/binary/hash/xxh3_64.d.ts +1 -8
  30. package/src/core/binary/hash/xxh3_64.d.ts.map +1 -1
  31. package/src/core/binary/hash/xxh3_64.js +4 -241
  32. package/src/core/binary/hash/xxh3_common.d.ts +1 -223
  33. package/src/core/binary/hash/xxh3_common.d.ts.map +1 -1
  34. package/src/core/binary/hash/xxh3_common.js +90 -476
  35. package/src/core/collection/array/array_insert_at.d.ts +16 -0
  36. package/src/core/collection/array/array_insert_at.d.ts.map +1 -0
  37. package/src/core/collection/array/array_insert_at.js +32 -0
  38. package/src/core/collection/array/array_remove_at.d.ts +15 -0
  39. package/src/core/collection/array/array_remove_at.d.ts.map +1 -0
  40. package/src/core/collection/array/array_remove_at.js +30 -0
  41. package/src/core/collection/array/combine_hash.d.ts +6 -0
  42. package/src/core/collection/array/combine_hash.d.ts.map +1 -1
  43. package/src/core/collection/array/combine_hash.js +6 -0
  44. package/src/core/function/FunctionCompiler.js +2 -2
  45. package/src/core/geom/3d/mat4/m4_multiply.d.ts +3 -0
  46. package/src/core/geom/3d/mat4/m4_multiply.d.ts.map +1 -1
  47. package/src/core/geom/3d/mat4/m4_multiply.js +3 -0
  48. package/src/core/geom/3d/mat4/m4_multiply_f64.d.ts +30 -0
  49. package/src/core/geom/3d/mat4/m4_multiply_f64.d.ts.map +1 -0
  50. package/src/core/geom/3d/mat4/m4_multiply_f64.js +106 -0
  51. package/src/core/geom/3d/quaternion/quat3_look_rotation.d.ts +37 -0
  52. package/src/core/geom/3d/quaternion/quat3_look_rotation.d.ts.map +1 -0
  53. package/src/core/geom/3d/quaternion/quat3_look_rotation.js +172 -0
  54. package/src/core/geom/ConicRay.js +2 -2
  55. package/src/core/geom/Quaternion.d.ts +1 -0
  56. package/src/core/geom/Quaternion.d.ts.map +1 -1
  57. package/src/core/geom/Quaternion.js +12 -48
  58. package/src/core/geom/Vector4.d.ts.map +1 -1
  59. package/src/core/geom/Vector4.js +8 -5
  60. package/src/core/math/hash/XXH128Hash.d.ts +38 -0
  61. package/src/core/math/hash/XXH128Hash.d.ts.map +1 -0
  62. package/src/core/math/hash/XXH128Hash.js +55 -0
  63. package/src/core/math/hash/XXH3_SECRET.d.ts +13 -0
  64. package/src/core/math/hash/XXH3_SECRET.d.ts.map +1 -0
  65. package/src/core/math/hash/XXH3_SECRET.js +25 -0
  66. package/src/core/math/hash/crc32.d.ts +16 -0
  67. package/src/core/math/hash/crc32.d.ts.map +1 -0
  68. package/src/core/math/hash/crc32.js +96 -0
  69. package/src/core/math/hash/xxh3_128.d.ts +10 -0
  70. package/src/core/math/hash/xxh3_128.d.ts.map +1 -0
  71. package/src/core/math/hash/xxh3_128.js +341 -0
  72. package/src/core/math/hash/xxh3_64.d.ts +9 -0
  73. package/src/core/math/hash/xxh3_64.d.ts.map +1 -0
  74. package/src/core/math/hash/xxh3_64.js +241 -0
  75. package/src/core/math/hash/xxh3_common.d.ts +224 -0
  76. package/src/core/math/hash/xxh3_common.d.ts.map +1 -0
  77. package/src/core/math/hash/xxh3_common.js +476 -0
  78. package/src/core/math/lookup/ParameterLookupTable.js +2 -2
  79. package/src/core/model/node-graph/node/NodeInstancePortReference.js +2 -2
  80. package/src/core/model/reactive/model/ReactiveBinaryExpression.js +2 -2
  81. package/src/core/model/reactive/model/terminal/ReactiveReference.js +2 -2
  82. package/src/engine/Engine.d.ts.map +1 -1
  83. package/src/engine/Engine.js +9 -4
  84. package/src/engine/asset/AssetDescription.js +2 -2
  85. package/src/engine/ecs/animation/Animation.js +2 -2
  86. package/src/engine/ecs/animation/AnimationClip.d.ts.map +1 -1
  87. package/src/engine/ecs/animation/AnimationClip.js +7 -5
  88. package/src/engine/ecs/gui/GUIElement.d.ts.map +1 -1
  89. package/src/engine/ecs/gui/GUIElement.js +7 -5
  90. package/src/engine/ecs/gui/hud/HeadsUpDisplay.js +2 -2
  91. package/src/engine/ecs/gui/position/ViewportPosition.d.ts.map +1 -1
  92. package/src/engine/ecs/gui/position/ViewportPosition.js +11 -7
  93. package/src/engine/ecs/storage/populateEngineSerializationRegistry.d.ts.map +1 -1
  94. package/src/engine/ecs/storage/populateEngineSerializationRegistry.js +10 -0
  95. package/src/engine/ecs/transform/Transform64.d.ts +1 -1
  96. package/src/engine/ecs/transform/Transform64.d.ts.map +1 -1
  97. package/src/engine/ecs/transform/Transform64.js +5 -4
  98. package/src/engine/ecs/transform/t64_look_rotation.d.ts +4 -4
  99. package/src/engine/ecs/transform/t64_look_rotation.d.ts.map +1 -1
  100. package/src/engine/ecs/transform/t64_look_rotation.js +7 -18
  101. package/src/engine/graphics/ecs/animation/animator/AnimationClip.d.ts.map +1 -1
  102. package/src/engine/graphics/ecs/animation/animator/AnimationClip.js +8 -5
  103. package/src/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -2
  104. package/src/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -2
  105. package/src/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -2
  106. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -2
  107. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +2 -2
  108. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.d.ts.map +1 -1
  109. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +8 -5
  110. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.d.ts.map +1 -1
  111. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +30 -1
  112. package/src/engine/graphics/ecs/decal/v2/Decal.d.ts.map +1 -1
  113. package/src/engine/graphics/ecs/decal/v2/Decal.js +9 -8
  114. package/src/engine/graphics/render/frame_graph/resource/TextureResourceDescriptor.d.ts.map +1 -1
  115. package/src/engine/graphics/render/frame_graph/resource/TextureResourceDescriptor.js +9 -6
  116. package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts +6 -0
  117. package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
  118. package/src/engine/graphics3/GPUParticleEmitterSystem.js +72 -29
  119. package/src/engine/graphics3/ParticipatingMedia.js +204 -204
  120. package/src/engine/graphics3/animation/AnimationClips.d.ts +5 -0
  121. package/src/engine/graphics3/animation/AnimationClips.d.ts.map +1 -1
  122. package/src/engine/graphics3/animation/AnimationClips.js +5 -0
  123. package/src/engine/grid/obstacle/GridObstacle.js +2 -2
  124. package/src/engine/input/devices/KeyboardDevice.d.ts +1 -0
  125. package/src/engine/input/devices/KeyboardDevice.d.ts.map +1 -1
  126. package/src/engine/input/devices/KeyboardDevice.js +7 -6
  127. package/src/engine/intelligence/behavior/selector/WeightedElement.js +2 -2
  128. package/src/engine/interpolation/Interpolated.js +2 -2
  129. package/src/engine/navigation/ecs/path_following/PathFollowingSystem.d.ts.map +1 -1
  130. package/src/engine/navigation/ecs/path_following/PathFollowingSystem.js +15 -2
  131. package/src/engine/network/CONGESTION_CONTROL.md +9 -9
  132. package/src/engine/network/MESSAGE_TRANSPORT.md +364 -0
  133. package/src/engine/network/NetworkSession.d.ts +31 -11
  134. package/src/engine/network/NetworkSession.d.ts.map +1 -1
  135. package/src/engine/network/NetworkSession.js +453 -286
  136. package/src/engine/network/README.md +77 -27
  137. package/src/engine/network/SMOOTHNESS_DESIGN.md +13 -5
  138. package/src/engine/network/diagnostics/BandwidthMeter.d.ts +1 -1
  139. package/src/engine/network/diagnostics/BandwidthMeter.js +1 -1
  140. package/src/engine/network/orchestrator/HostJoin.d.ts +111 -0
  141. package/src/engine/network/orchestrator/HostJoin.d.ts.map +1 -0
  142. package/src/engine/network/orchestrator/HostJoin.js +271 -0
  143. package/src/engine/network/orchestrator/NetworkPeer.d.ts +151 -112
  144. package/src/engine/network/orchestrator/NetworkPeer.d.ts.map +1 -1
  145. package/src/engine/network/orchestrator/NetworkPeer.js +450 -499
  146. package/src/engine/network/orchestrator/PendingSlices.d.ts +30 -0
  147. package/src/engine/network/orchestrator/PendingSlices.d.ts.map +1 -0
  148. package/src/engine/network/orchestrator/PendingSlices.js +83 -0
  149. package/src/engine/network/orchestrator/ReliableFrames.d.ts +34 -0
  150. package/src/engine/network/orchestrator/ReliableFrames.d.ts.map +1 -0
  151. package/src/engine/network/orchestrator/ReliableFrames.js +96 -0
  152. package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts +77 -10
  153. package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts.map +1 -1
  154. package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +236 -61
  155. package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts +20 -6
  156. package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts.map +1 -1
  157. package/src/engine/network/orchestrator/ServerAuthoritativeServer.js +33 -8
  158. package/src/engine/network/replication/Replicator.d.ts.map +1 -1
  159. package/src/engine/network/replication/Replicator.js +7 -1
  160. package/src/engine/network/sim/ActionLog.d.ts +32 -5
  161. package/src/engine/network/sim/ActionLog.d.ts.map +1 -1
  162. package/src/engine/network/sim/ActionLog.js +47 -5
  163. package/src/engine/network/sim/SimActionExecutor.d.ts +42 -2
  164. package/src/engine/network/sim/SimActionExecutor.d.ts.map +1 -1
  165. package/src/engine/network/sim/SimActionExecutor.js +100 -4
  166. package/src/engine/network/sim/Snapshotter.d.ts +12 -0
  167. package/src/engine/network/sim/Snapshotter.d.ts.map +1 -1
  168. package/src/engine/network/sim/Snapshotter.js +43 -0
  169. package/src/engine/network/state/Baseline.d.ts +1 -1
  170. package/src/engine/network/state/Baseline.js +1 -1
  171. package/src/engine/network/state/FrameBufferRing.d.ts +25 -6
  172. package/src/engine/network/state/FrameBufferRing.d.ts.map +1 -1
  173. package/src/engine/network/state/FrameBufferRing.js +51 -6
  174. package/src/engine/network/state/InputRing.d.ts +4 -0
  175. package/src/engine/network/state/InputRing.d.ts.map +1 -1
  176. package/src/engine/network/state/InputRing.js +7 -0
  177. package/src/engine/network/transport/DeferredTransport.d.ts.map +1 -1
  178. package/src/engine/network/transport/DeferredTransport.js +1 -0
  179. package/src/engine/network/transport/LoopbackTransport.d.ts.map +1 -1
  180. package/src/engine/network/transport/LoopbackTransport.js +4 -2
  181. package/src/engine/network/transport/Transport.d.ts +7 -0
  182. package/src/engine/network/transport/Transport.d.ts.map +1 -1
  183. package/src/engine/network/transport/Transport.js +8 -0
  184. package/src/engine/network/transport/adapters/NodeUDPTransport.d.ts.map +1 -1
  185. package/src/engine/network/transport/adapters/NodeUDPTransport.js +20 -5
  186. package/src/engine/network/transport/adapters/WebRTCDataChannelTransport.d.ts.map +1 -1
  187. package/src/engine/network/transport/adapters/WebRTCDataChannelTransport.js +8 -0
  188. package/src/engine/network/transport/adapters/WebTransportTransport.d.ts.map +1 -1
  189. package/src/engine/network/transport/adapters/WebTransportTransport.js +6 -0
  190. package/src/engine/network/transport/connection/Connection.d.ts +191 -0
  191. package/src/engine/network/transport/connection/Connection.d.ts.map +1 -0
  192. package/src/engine/network/transport/connection/Connection.js +1262 -0
  193. package/src/engine/network/transport/connection/RangeSet.d.ts +94 -0
  194. package/src/engine/network/transport/connection/RangeSet.d.ts.map +1 -0
  195. package/src/engine/network/transport/connection/RangeSet.js +260 -0
  196. package/src/engine/network/transport/connection/RxStream.d.ts +48 -0
  197. package/src/engine/network/transport/connection/RxStream.d.ts.map +1 -0
  198. package/src/engine/network/transport/connection/RxStream.js +211 -0
  199. package/src/engine/network/transport/connection/TxStream.d.ts +90 -0
  200. package/src/engine/network/transport/connection/TxStream.d.ts.map +1 -0
  201. package/src/engine/network/transport/connection/TxStream.js +243 -0
  202. package/src/engine/network/transport/connection/bytes_copy.d.ts +17 -0
  203. package/src/engine/network/transport/connection/bytes_copy.d.ts.map +1 -0
  204. package/src/engine/network/transport/connection/bytes_copy.js +34 -0
  205. package/src/engine/network/transport/connection/varint.d.ts +46 -0
  206. package/src/engine/network/transport/connection/varint.d.ts.map +1 -0
  207. package/src/engine/network/transport/connection/varint.js +107 -0
  208. package/src/engine/physics/cloth/ecs/Cloth.d.ts.map +1 -1
  209. package/src/engine/physics/cloth/ecs/Cloth.js +7 -5
  210. package/src/engine/physics/cloth/ecs/ClothCollider.d.ts.map +1 -1
  211. package/src/engine/physics/cloth/ecs/ClothCollider.js +7 -5
  212. package/src/engine/physics/cloth/ecs/ClothDynamics.d.ts.map +1 -1
  213. package/src/engine/physics/cloth/ecs/ClothDynamics.js +20 -11
  214. package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
  215. package/src/engine/physics/fluid/FluidField.js +7 -5
  216. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -1
  217. package/src/engine/physics/fluid/ecs/FluidComponent.js +19 -11
  218. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  219. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +2 -2
  220. package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +2 -2
  221. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
  222. package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +11 -7
  223. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -1
  224. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +11 -7
  225. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
  226. package/src/engine/physics/fluid/effector/WakeFluidEffector.js +16 -9
  227. package/src/engine/sound/ecs/audio/AudioEmitter.d.ts +38 -7
  228. package/src/engine/sound/ecs/audio/AudioEmitter.d.ts.map +1 -1
  229. package/src/engine/sound/ecs/audio/AudioEmitter.js +47 -14
  230. package/src/engine/sound/ecs/audio/AudioEmitterSerializationAdapter.d.ts.map +1 -1
  231. package/src/engine/sound/ecs/audio/AudioEmitterSerializationAdapter.js +5 -1
  232. package/src/engine/sound/ecs/audio/AudioEmitterSerializationUpgrader_0_1.d.ts +18 -0
  233. package/src/engine/sound/ecs/audio/AudioEmitterSerializationUpgrader_0_1.d.ts.map +1 -0
  234. package/src/engine/sound/ecs/audio/AudioEmitterSerializationUpgrader_0_1.js +48 -0
  235. package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts +12 -2
  236. package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts.map +1 -1
  237. package/src/engine/sound/ecs/audio/AudioEmitterSystem.js +173 -9
  238. package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts +9 -3
  239. package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -1
  240. package/src/engine/sound/ecs/audio/LiveEmitterSet.js +28 -8
  241. package/src/engine/sound/ecs/trigger/AudioEventTrigger.d.ts +8 -0
  242. package/src/engine/sound/ecs/trigger/AudioEventTrigger.d.ts.map +1 -1
  243. package/src/engine/sound/ecs/trigger/AudioEventTrigger.js +192 -191
  244. package/src/engine/sound/ecs/trigger/AudioEventTriggerSerializationAdapter.d.ts.map +1 -1
  245. package/src/engine/sound/ecs/trigger/AudioEventTriggerSerializationAdapter.js +5 -1
  246. package/src/engine/sound/ecs/trigger/AudioEventTriggerSerializationUpgrader_0_1.d.ts +18 -0
  247. package/src/engine/sound/ecs/trigger/AudioEventTriggerSerializationUpgrader_0_1.d.ts.map +1 -0
  248. package/src/engine/sound/ecs/trigger/AudioEventTriggerSerializationUpgrader_0_1.js +51 -0
  249. package/src/engine/sound/ecs/trigger/AudioEventTriggerSystem.d.ts.map +1 -1
  250. package/src/engine/sound/ecs/trigger/AudioEventTriggerSystem.js +15 -1
  251. package/src/engine/sound/simulation/core/AcousticMedium.js +2 -2
  252. package/src/engine/sound/simulation/definition/AcousticDirectivity.js +2 -2
  253. package/src/engine/sound/simulation/definition/AcousticMaterial.d.ts.map +1 -1
  254. package/src/engine/sound/simulation/definition/AcousticMaterial.js +11 -7
  255. package/src/engine/sound/sopra/README.md +768 -644
  256. package/src/engine/sound/sopra/SopraEngine.d.ts +104 -8
  257. package/src/engine/sound/sopra/SopraEngine.d.ts.map +1 -1
  258. package/src/engine/sound/sopra/SopraEngine.js +327 -12
  259. package/src/engine/sound/sopra/definition/BusDefinition.d.ts.map +1 -1
  260. package/src/engine/sound/sopra/definition/BusDefinition.js +5 -4
  261. package/src/engine/sound/sopra/definition/DuckingRule.d.ts.map +1 -1
  262. package/src/engine/sound/sopra/definition/DuckingRule.js +7 -5
  263. package/src/engine/sound/sopra/definition/EventDescription.d.ts +28 -2
  264. package/src/engine/sound/sopra/definition/EventDescription.d.ts.map +1 -1
  265. package/src/engine/sound/sopra/definition/EventDescription.js +77 -17
  266. package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.d.ts +10 -0
  267. package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.d.ts.map +1 -1
  268. package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.js +77 -55
  269. package/src/engine/sound/sopra/definition/EventDescriptionSerializationUpgrader_0_1.d.ts +31 -0
  270. package/src/engine/sound/sopra/definition/EventDescriptionSerializationUpgrader_0_1.d.ts.map +1 -0
  271. package/src/engine/sound/sopra/definition/EventDescriptionSerializationUpgrader_0_1.js +75 -0
  272. package/src/engine/sound/sopra/definition/MixerSnapshot.js +2 -2
  273. package/src/engine/sound/sopra/definition/ParameterDefinition.d.ts.map +1 -1
  274. package/src/engine/sound/sopra/definition/ParameterDefinition.js +7 -5
  275. package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.js +2 -2
  276. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts.map +1 -1
  277. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.js +4 -3
  278. package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.js +2 -2
  279. package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.js +3 -3
  280. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts.map +1 -1
  281. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.js +16 -9
  282. package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.js +2 -2
  283. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts +1 -1
  284. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts.map +1 -1
  285. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.js +2 -2
  286. package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.d.ts +38 -9
  287. package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.d.ts.map +1 -1
  288. package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.js +34 -5
  289. package/src/engine/sound/sopra/definition/effect/CompressorEffect.d.ts +7 -2
  290. package/src/engine/sound/sopra/definition/effect/CompressorEffect.d.ts.map +1 -1
  291. package/src/engine/sound/sopra/definition/effect/CompressorEffect.js +137 -120
  292. package/src/engine/sound/sopra/definition/effect/EqEffect.d.ts +3 -1
  293. package/src/engine/sound/sopra/definition/effect/EqEffect.d.ts.map +1 -1
  294. package/src/engine/sound/sopra/definition/effect/EqEffect.js +146 -128
  295. package/src/engine/sound/sopra/definition/effect/ReverbEffect.d.ts +1 -0
  296. package/src/engine/sound/sopra/definition/effect/ReverbEffect.d.ts.map +1 -1
  297. package/src/engine/sound/sopra/definition/effect/ReverbEffect.js +8 -3
  298. package/src/engine/sound/sopra/legacy/SoundEmitter.d.ts.map +1 -1
  299. package/src/engine/sound/sopra/legacy/SoundEmitter.js +357 -352
  300. package/src/engine/sound/sopra/legacy/SoundTrack.d.ts.map +1 -1
  301. package/src/engine/sound/sopra/legacy/SoundTrack.js +281 -278
  302. package/src/engine/sound/sopra/runtime/BusGraph.d.ts +44 -2
  303. package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -1
  304. package/src/engine/sound/sopra/runtime/BusGraph.js +83 -43
  305. package/src/engine/sound/sopra/runtime/EffectChain.d.ts +96 -0
  306. package/src/engine/sound/sopra/runtime/EffectChain.d.ts.map +1 -0
  307. package/src/engine/sound/sopra/runtime/EffectChain.js +286 -0
  308. package/src/engine/sound/sopra/runtime/EffectParamOverrides.d.ts +123 -0
  309. package/src/engine/sound/sopra/runtime/EffectParamOverrides.d.ts.map +1 -0
  310. package/src/engine/sound/sopra/runtime/EffectParamOverrides.js +320 -0
  311. package/src/engine/sound/sopra/runtime/EventInstance.d.ts +55 -5
  312. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  313. package/src/engine/sound/sopra/runtime/EventInstance.js +201 -26
  314. package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.d.ts +2 -1
  315. package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.d.ts.map +1 -1
  316. package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.js +6 -1
  317. package/src/engine/sound/sopra/serialization/sopraSerializationHarness.d.ts +15 -0
  318. package/src/engine/sound/sopra/serialization/sopraSerializationHarness.d.ts.map +1 -1
  319. package/src/engine/sound/sopra/serialization/sopraSerializationHarness.js +32 -0
  320. package/src/engine/sound/sopra/util/MockAudioContext.d.ts.map +1 -1
  321. package/src/engine/sound/sopra/util/MockAudioContext.js +3 -0
  322. package/src/engine/sound/sopra/util/fadeOutAndStop.d.ts +13 -3
  323. package/src/engine/sound/sopra/util/fadeOutAndStop.d.ts.map +1 -1
  324. package/src/engine/sound/sopra/util/fadeOutAndStop.js +25 -13
  325. package/src/format/image/png/PNGReader.js +644 -644
  326. package/src/format/image/png/crc32.d.ts +1 -1
  327. package/src/format/image/png/crc32.js +7 -8
  328. package/src/shade/RENDERER_CONTRACT.md +6 -3
  329. package/src/shade/descriptor/binding/BindGroupLayoutDescriptor.js +2 -2
  330. package/src/shade/descriptor/binding/BindGroupLayoutEntry.d.ts.map +1 -1
  331. package/src/shade/descriptor/binding/BindGroupLayoutEntry.js +12 -8
  332. package/src/shade/descriptor/binding/StorageTextureBindingLayout.js +2 -2
  333. package/src/shade/descriptor/binding/TextureBindingLayout.js +2 -2
  334. package/src/shade/descriptor/blend/BlendComponent.js +2 -2
  335. package/src/shade/descriptor/pipeline/PipelineDescriptorBase.js +2 -2
  336. package/src/shade/descriptor/pipeline/PipelineLayoutDescriptor.js +2 -2
  337. package/src/shade/descriptor/pipeline/ProgrammableStage.js +2 -2
  338. package/src/shade/descriptor/pipeline/compute/ComputePipelineDescriptor.js +2 -2
  339. package/src/shade/descriptor/pipeline/render/ColorTargetState.js +2 -2
  340. package/src/shade/descriptor/pipeline/render/FragmentState.js +2 -2
  341. package/src/shade/descriptor/pipeline/render/PrimitiveState.js +2 -2
  342. package/src/shade/descriptor/pipeline/render/RenderPipelineDescriptor.d.ts.map +1 -1
  343. package/src/shade/descriptor/pipeline/render/RenderPipelineDescriptor.js +8 -5
  344. package/src/shade/descriptor/pipeline/render/VertexAttribute.js +2 -2
  345. package/src/shade/descriptor/texture/SamplerDescriptor.d.ts.map +1 -1
  346. package/src/shade/descriptor/texture/SamplerDescriptor.js +20 -12
  347. package/src/shade/descriptor/texture/TextureDescriptor.d.ts.map +1 -1
  348. package/src/shade/descriptor/texture/TextureDescriptor.js +11 -7
  349. package/src/shade/device/SHADE_DEVICE_FLOOR.d.ts +24 -0
  350. package/src/shade/device/SHADE_DEVICE_FLOOR.d.ts.map +1 -0
  351. package/src/shade/device/SHADE_DEVICE_FLOOR.js +34 -0
  352. package/src/shade/device/ShadeDeviceFailure.d.ts +12 -5
  353. package/src/shade/device/ShadeDeviceFailure.d.ts.map +1 -1
  354. package/src/shade/device/ShadeDeviceFailure.js +17 -8
  355. package/src/shade/device/ShadeDeviceFailureReason.d.ts +1 -1
  356. package/src/shade/device/ShadeDeviceFailureReason.js +2 -2
  357. package/src/shade/device/graph/BufferResourceDescriptor.d.ts.map +1 -1
  358. package/src/shade/device/graph/BufferResourceDescriptor.js +196 -193
  359. package/src/shade/device/graph/TextureResourceDescriptor.d.ts.map +1 -1
  360. package/src/shade/device/graph/TextureResourceDescriptor.js +178 -173
  361. package/src/shade/device/shade_device_floor_unmet.d.ts +13 -0
  362. package/src/shade/device/shade_device_floor_unmet.d.ts.map +1 -0
  363. package/src/shade/device/shade_device_floor_unmet.js +32 -0
  364. package/src/shade/device/timing/profile/sgpt_read_header.js +1 -1
  365. package/src/shade/device/timing/profile/sgpt_read_records.js +1 -1
  366. package/src/shade/device/timing/profile/sgpt_write_header.js +1 -1
  367. package/src/shade/device/timing/profile/sgpt_write_record.js +1 -1
  368. package/src/shade/renderer/Renderer.d.ts +2 -0
  369. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  370. package/src/shade/renderer/Renderer.js +29 -55
  371. package/src/shade/renderer/binding/BufferBinding.js +2 -2
  372. package/src/shade/renderer/buffer/GPUBufferAllocator.d.ts.map +1 -1
  373. package/src/shade/renderer/buffer/GPUBufferAllocator.js +9 -0
  374. package/src/shade/renderer/buffer/buffer_pool_ops.d.ts +21 -12
  375. package/src/shade/renderer/buffer/buffer_pool_ops.d.ts.map +1 -1
  376. package/src/shade/renderer/buffer/buffer_pool_ops.js +18 -19
  377. package/src/shade/renderer/camera/Camera.js +2 -2
  378. package/src/shade/renderer/geometry/Attribute.js +2 -2
  379. package/src/shade/renderer/geometry/Geometry.js +2 -2
  380. package/src/shade/renderer/geometry/geometry_deduplicate_vertices.js +2 -2
  381. package/src/shade/renderer/geometry/meshlet/MeshletBatch.js +2 -2
  382. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_asset_id.js +13 -13
  383. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_directory_block_checksum.js +41 -41
  384. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_frame_checksum.js +41 -41
  385. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_header_checksum.js +25 -25
  386. package/src/shade/renderer/gpu_primitive/test/gpu_test.d.ts.map +1 -1
  387. package/src/shade/renderer/gpu_primitive/test/gpu_test.js +8 -11
  388. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  389. package/src/shade/renderer/material/StandardShadeMaterial.d.ts.map +1 -1
  390. package/src/shade/renderer/material/StandardShadeMaterial.js +13 -8
  391. package/src/shade/renderer/pool/TransientResourcePool.d.ts +24 -0
  392. package/src/shade/renderer/pool/TransientResourcePool.d.ts.map +1 -1
  393. package/src/shade/renderer/pool/TransientResourcePool.js +41 -10
  394. package/src/shade/renderer/scene/optimization/geometry/internal/triangle_fingerprint_stream.d.ts.map +1 -1
  395. package/src/shade/renderer/scene/optimization/geometry/internal/triangle_fingerprint_stream.js +14 -5
  396. package/src/shade/renderer/scene/optimization/sampler2d_from_image_bitmap.js +1 -1
  397. package/src/shade/renderer/shader/ComputeShader.d.ts.map +1 -1
  398. package/src/shade/renderer/shader/ComputeShader.js +18 -2
  399. package/src/shade/renderer/shader/ImageShader.d.ts.map +1 -1
  400. package/src/shade/renderer/shader/ImageShader.js +230 -218
  401. package/src/shade/renderer/shader/type/WGSLStructField.js +2 -2
  402. package/src/shade/renderer/shader/type/WebGPUArray.js +2 -2
  403. package/src/shade/renderer/shader/type/WebGPUStruct.d.ts.map +1 -1
  404. package/src/shade/renderer/shader/type/WebGPUStruct.js +9 -6
  405. package/src/shade/renderer/texture/ShadeTexture.d.ts.map +1 -1
  406. package/src/shade/renderer/texture/ShadeTexture.js +17 -10
  407. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +2 -2
  408. package/src/shade/renderer/water/surface/chunk_water_surface_sample.d.ts +4 -4
  409. package/src/shade/renderer/water/surface/chunk_water_surface_sample.js +6 -6
  410. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  411. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +46 -55
  412. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.d.ts +3 -3
  413. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.d.ts.map +1 -1
  414. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.js +14 -4
  415. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts +10 -1
  416. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts.map +1 -1
  417. package/src/shade/renderer/water/surface/particles/chunk_water_particle.js +82 -40
  418. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts +4 -1
  419. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts.map +1 -1
  420. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.js +8 -4
  421. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts +98 -86
  422. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts.map +1 -1
  423. package/src/shade/renderer/water/surface/particles/shader_water_particles.js +440 -298
  424. package/src/view/common/HTMLElementCacheKey.d.ts.map +1 -1
  425. package/src/view/common/HTMLElementCacheKey.js +4 -3
  426. package/src/view/graphics/GraphicsContextFailureView.d.ts +1 -2
  427. package/src/view/graphics/GraphicsContextFailureView.d.ts.map +1 -1
  428. package/src/view/graphics/GraphicsContextFailureView.js +1 -2
  429. package/src/view/minimap/MinimapMarker.js +2 -2
  430. package/src/engine/network/transport/Channel.js +0 -336
  431. package/src/engine/network/transport/ReliableCommandPipeline.js +0 -335
  432. package/src/engine/network/transport/fragments/FragmentAssembler.js +0 -350
  433. package/src/engine/network/transport/fragments/FragmentRetention.js +0 -191
  434. package/src/engine/network/transport/fragments/fragment_send.js +0 -157
  435. package/src/engine/network/transport/fragments/packet_size.js +0 -107
@@ -1,6 +1,7 @@
1
1
  import { dB2Volume } from "../../dB2Volume.js";
2
2
  import { volume2dB } from "../../volume2dB.js";
3
- import { rampGain } from "../util/fadeOutAndStop.js";
3
+ import { cancelAndHold, rampGain } from "../util/fadeOutAndStop.js";
4
+ import { EffectChain } from "./EffectChain.js";
4
5
 
5
6
  /**
6
7
  * @typedef {import("../definition/BusDefinition.js").BusDefinition} BusDefinition
@@ -18,12 +19,16 @@ export const BUS_ROOT_PARENT = "";
18
19
  *
19
20
  * Each bus is wired `input → effect[0] → … → effect[n] → gain(output)`; the output then connects to
20
21
  * its parent bus's input, or to the engine destination for a root bus (parentId === "").
22
+ *
23
+ * A bus's inserts are an {@link EffectChain}, and their parameters move through {@link setEffectParam} /
24
+ * {@link approachEffectParam} — the same two verbs as the fader's {@link setVolume} / {@link approachVolume}.
25
+ * The graph's nodes stay its own.
21
26
  */
22
27
  export class BusGraph {
23
28
 
24
29
  /**
25
- * id -> { definition, input, output }
26
- * @type {Map<string, {definition: BusDefinition, input: AudioNode, output: GainNode}>}
30
+ * id -> the bus's live record
31
+ * @type {Map<string, {definition: BusDefinition, input: AudioNode, output: GainNode, nominal: number, effects: EffectChain|null, sends: GainNode[]}>}
27
32
  */
28
33
  buses = new Map();
29
34
 
@@ -63,44 +68,21 @@ export class BusGraph {
63
68
  gain.gain.setValueAtTime(nominal, 0);
64
69
 
65
70
  let input = gain;
71
+ let effects = null;
66
72
 
67
- // every node this bus owns, so {@link dispose} can unwire the lot rather than only the
68
- // ends of the chain
69
- const chain = [];
70
-
71
- const effects = def.effects;
72
-
73
- if (effects.length > 0) {
74
- let previousOutput = null;
75
-
76
- for (let e = 0; e < effects.length; e++) {
77
- const built = effects[e].build(ctx);
78
-
79
- chain.push(built.input);
73
+ if (def.effects.length > 0) {
74
+ effects = new EffectChain(ctx, def.effects);
80
75
 
81
- if (built.output !== built.input) {
82
- chain.push(built.output);
83
- }
84
-
85
- if (previousOutput === null) {
86
- // first effect is the chain head
87
- input = built.input;
88
- } else {
89
- previousOutput.connect(built.input);
90
- }
91
-
92
- previousOutput = built.output;
93
- }
94
-
95
- // last effect feeds the bus gain (output)
96
- previousOutput.connect(gain);
76
+ // the inserts' tail feeds the bus gain (output); their head is the bus input
77
+ effects.output.connect(gain);
78
+ input = effects.input;
97
79
  }
98
80
 
99
81
  // `nominal` is the authoritative logical fader gain (linear), tracked separately from the
100
82
  // node's instantaneous `.value` — which WebAudio does NOT update under ramps/setTargetAtTime.
101
83
  // get/setVolume read/write `nominal`; ducking (approachVolume) is a transient modulation that
102
84
  // deliberately does NOT touch it, so the duck can capture + restore the true nominal.
103
- this.buses.set(def.id, { definition: def, input, output: gain, nominal, chain, sends: [] });
85
+ this.buses.set(def.id, { definition: def, input, output: gain, nominal, effects, sends: [] });
104
86
  }
105
87
 
106
88
  // pass 2: route each bus output to its parent's input (or the engine destination)
@@ -163,8 +145,8 @@ export class BusGraph {
163
145
  for (const bus of this.buses.values()) {
164
146
  bus.output.disconnect();
165
147
 
166
- for (let i = 0; i < bus.chain.length; i++) {
167
- bus.chain[i].disconnect();
148
+ if (bus.effects !== null) {
149
+ bus.effects.disconnect();
168
150
  }
169
151
 
170
152
  for (let i = 0; i < bus.sends.length; i++) {
@@ -189,7 +171,7 @@ export class BusGraph {
189
171
  * factored here instead of being repeated verbatim in each accessor — one place owns the message and
190
172
  * the "unknown bus is fatal" policy.
191
173
  * @param {string} id
192
- * @returns {{definition: BusDefinition, input: AudioNode, output: GainNode}}
174
+ * @returns {{definition: BusDefinition, input: AudioNode, output: GainNode, nominal: number, effects: EffectChain|null, sends: GainNode[]}}
193
175
  */
194
176
  #bus(id) {
195
177
  const bus = this.buses.get(id);
@@ -220,6 +202,70 @@ export class BusGraph {
220
202
  return this.#bus(id).output;
221
203
  }
222
204
 
205
+ /**
206
+ * The bus's inserts — throws if it has none, since addressing an effect on a bus that defines no
207
+ * effects is the same programming error as addressing a bus that does not exist.
208
+ * @param {string} id
209
+ * @returns {EffectChain}
210
+ */
211
+ #effects(id) {
212
+ const effects = this.#bus(id).effects;
213
+
214
+ if (effects === null) {
215
+ throw new Error(`sopra: bus '${id}' has no effects`);
216
+ }
217
+
218
+ return effects;
219
+ }
220
+
221
+ /**
222
+ * Move a parameter of one of a bus's insert effects, now. See {@link EffectChain#setParam}.
223
+ * @param {string} id bus
224
+ * @param {number} effectIndex position in the bus definition's `effects`
225
+ * @param {string} name one of that effect class's `parameters` (`'frequency'` on an `EqEffect`)
226
+ * @param {number} value in the parameter's own units
227
+ */
228
+ setEffectParam(id, effectIndex, name, value) {
229
+ this.#effects(id).setParam(effectIndex, name, value);
230
+ }
231
+
232
+ /**
233
+ * Glide a parameter of one of a bus's insert effects toward `value`. See {@link EffectChain#approachParam}.
234
+ * @param {string} id bus
235
+ * @param {number} effectIndex
236
+ * @param {string} name
237
+ * @param {number} value
238
+ * @param {number} timeConstant seconds, above 0
239
+ */
240
+ approachEffectParam(id, effectIndex, name, value, timeConstant) {
241
+ this.#effects(id).approachParam(effectIndex, name, value, timeConstant);
242
+ }
243
+
244
+ /**
245
+ * Where a bus effect's parameter was last sent (a glide's target, not where it has got to).
246
+ * @param {string} id bus
247
+ * @param {number} effectIndex
248
+ * @param {string} name
249
+ * @returns {number}
250
+ */
251
+ getEffectParam(id, effectIndex, name) {
252
+ return this.#effects(id).getParam(effectIndex, name);
253
+ }
254
+
255
+ /**
256
+ * Whether this graph has bus `id`, with an insert at `effectIndex` exposing a parameter `name` — an
257
+ * address {@link setEffectParam} would take. Asks; never throws.
258
+ * @param {string} id bus
259
+ * @param {number} effectIndex
260
+ * @param {string} name
261
+ * @returns {boolean}
262
+ */
263
+ hasEffectParam(id, effectIndex, name) {
264
+ const bus = this.buses.get(id);
265
+
266
+ return bus !== undefined && bus.effects !== null && bus.effects.hasParam(effectIndex, name);
267
+ }
268
+
223
269
  /**
224
270
  * @param {string} id
225
271
  * @returns {number} linear gain
@@ -252,13 +298,7 @@ export class BusGraph {
252
298
  const param = bus.output.gain;
253
299
  const now = this.#ctx.currentTime;
254
300
 
255
- if (typeof param.cancelAndHoldAtTime === "function") {
256
- param.cancelAndHoldAtTime(now);
257
- } else {
258
- // portable fallback (Firefox), as in `rampGain`
259
- param.cancelScheduledValues(now);
260
- }
261
-
301
+ cancelAndHold(param, now);
262
302
  param.setValueAtTime(linear, now);
263
303
  }
264
304
 
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Resolve an effect-parameter address against a list of effect definitions: the position of `name` among
3
+ * the class `parameters` of the effect at `index`, or throw naming what the list does have. The one
4
+ * place an `(effect index, parameter name)` address is checked — a chain resolves through it, and so does
5
+ * anything that holds addresses for a chain not yet built (`EffectParamOverrides`).
6
+ * @param {AbstractAudioEffect[]} effects
7
+ * @param {number} index
8
+ * @param {string} name
9
+ * @returns {number}
10
+ */
11
+ export function effectParamIndex(effects: AbstractAudioEffect[], index: number, name: string): number;
12
+ /**
13
+ * @typedef {import("../definition/effect/AbstractAudioEffect.js").AbstractAudioEffect} AbstractAudioEffect
14
+ */
15
+ /**
16
+ * The live nodes of an ordered list of insert effects, wired `effect[0] → … → effect[n]`, and the one place
17
+ * their parameters are moved at runtime.
18
+ *
19
+ * Shared by a bus's inserts ({@link BusGraph}) and a single play's inserts ({@link EventInstance}), so both
20
+ * address a parameter the same way: by the effect's index in the list it was built from and the parameter's
21
+ * name, one of the effect class's {@link AbstractAudioEffect.parameters} — the name of the definition field
22
+ * it starts from (`EqEffect.frequency` → `'frequency'`).
23
+ *
24
+ * Each parameter's NOMINAL value — where it was last sent — is tracked here rather than read back from the
25
+ * node, because WebAudio does not move `AudioParam.value` under scheduled automation: a glide's target is
26
+ * only visible in the automation list.
27
+ *
28
+ * Built once per bus and once per playing instance, so it is kept small: the parameter names are the
29
+ * effect classes' own static lists (read through the definitions, never copied), and the per-chain state is
30
+ * three flat arrays.
31
+ */
32
+ export class EffectChain {
33
+ /**
34
+ * @param {BaseAudioContext} ctx
35
+ * @param {AbstractAudioEffect[]} effects at least one
36
+ */
37
+ constructor(ctx: BaseAudioContext, effects: AbstractAudioEffect[]);
38
+ /**
39
+ * Head of the chain: what feeds it connects here.
40
+ * @type {AudioNode}
41
+ */
42
+ input: AudioNode;
43
+ /**
44
+ * Tail of the chain: connect this onward.
45
+ * @type {AudioNode}
46
+ */
47
+ output: AudioNode;
48
+ /**
49
+ * @returns {number} how many effects the chain holds
50
+ */
51
+ get length(): number;
52
+ /**
53
+ * Whether the chain has an effect at `index` exposing a parameter called `name` — an address
54
+ * {@link setParam} would take. Asks; never throws.
55
+ * @param {number} index
56
+ * @param {string} name
57
+ * @returns {boolean}
58
+ */
59
+ hasParam(index: number, name: string): boolean;
60
+ /**
61
+ * Move an effect's parameter to `value`, now. Whatever automation was in flight on it is cancelled.
62
+ *
63
+ * @param {number} index effect's position in the list the chain was built from
64
+ * @param {string} name one of the effect class's `parameters`
65
+ * @param {number} value in the parameter's own units (Hz, dB, ...)
66
+ */
67
+ setParam(index: number, name: string, value: number): void;
68
+ /**
69
+ * Glide an effect's parameter toward `value` exponentially, covering ~63% of the way per
70
+ * `timeConstant` — the WebAudio `setTargetAtTime` glide, and the counterpart of
71
+ * {@link BusGraph#approachVolume}. Whatever was in flight is cancelled and held first, so a value sent
72
+ * every frame (a filter tracking a game value) retargets from wherever the last glide had got to, and
73
+ * the automation list never grows.
74
+ *
75
+ * @param {number} index
76
+ * @param {string} name
77
+ * @param {number} value
78
+ * @param {number} timeConstant seconds, above 0
79
+ */
80
+ approachParam(index: number, name: string, value: number, timeConstant: number): void;
81
+ /**
82
+ * Where an effect's parameter was last sent — the target of a glide still in flight, not the value it
83
+ * has reached — or its defined value if it has not been moved.
84
+ * @param {number} index
85
+ * @param {string} name
86
+ * @returns {number}
87
+ */
88
+ getParam(index: number, name: string): number;
89
+ /**
90
+ * Unwire every node the chain owns. Idempotent.
91
+ */
92
+ disconnect(): void;
93
+ #private;
94
+ }
95
+ export type AbstractAudioEffect = import("../definition/effect/AbstractAudioEffect.js").AbstractAudioEffect;
96
+ //# sourceMappingURL=EffectChain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectChain.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra/runtime/EffectChain.js"],"names":[],"mappings":"AAoQA;;;;;;;;;GASG;AACH,0CALW,mBAAmB,EAAE,SACrB,MAAM,QACN,MAAM,GACJ,MAAM,CAiBlB;AA1RD;;GAEG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH;IA4CI;;;OAGG;IACH,iBAHW,gBAAgB,WAChB,mBAAmB,EAAE,EA6D/B;IAzGD;;;OAGG;IACH,OAFU,SAAS,CAEb;IAEN;;;OAGG;IACH,QAFU,SAAS,CAEZ;IAiGP;;OAEG;IACH,qBAEC;IAED;;;;;;OAMG;IACH,gBAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAMnB;IAoBD;;;;;;OAMG;IACH,gBAJW,MAAM,QACN,MAAM,SACN,MAAM,QAchB;IAED;;;;;;;;;;;OAWG;IACH,qBALW,MAAM,QACN,MAAM,SACN,MAAM,gBACN,MAAM,QAehB;IAED;;;;;;OAMG;IACH,gBAJW,MAAM,QACN,MAAM,GACJ,MAAM,CAIlB;IAED;;OAEG;IACH,mBAMC;;CACJ;kCA5OY,OAAO,6CAA6C,EAAE,mBAAmB"}
@@ -0,0 +1,286 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { cancelAndHold } from "../util/fadeOutAndStop.js";
3
+
4
+ /**
5
+ * @typedef {import("../definition/effect/AbstractAudioEffect.js").AbstractAudioEffect} AbstractAudioEffect
6
+ */
7
+
8
+ /**
9
+ * The live nodes of an ordered list of insert effects, wired `effect[0] → … → effect[n]`, and the one place
10
+ * their parameters are moved at runtime.
11
+ *
12
+ * Shared by a bus's inserts ({@link BusGraph}) and a single play's inserts ({@link EventInstance}), so both
13
+ * address a parameter the same way: by the effect's index in the list it was built from and the parameter's
14
+ * name, one of the effect class's {@link AbstractAudioEffect.parameters} — the name of the definition field
15
+ * it starts from (`EqEffect.frequency` → `'frequency'`).
16
+ *
17
+ * Each parameter's NOMINAL value — where it was last sent — is tracked here rather than read back from the
18
+ * node, because WebAudio does not move `AudioParam.value` under scheduled automation: a glide's target is
19
+ * only visible in the automation list.
20
+ *
21
+ * Built once per bus and once per playing instance, so it is kept small: the parameter names are the
22
+ * effect classes' own static lists (read through the definitions, never copied), and the per-chain state is
23
+ * three flat arrays.
24
+ */
25
+ export class EffectChain {
26
+
27
+ /**
28
+ * Head of the chain: what feeds it connects here.
29
+ * @type {AudioNode}
30
+ */
31
+ input;
32
+
33
+ /**
34
+ * Tail of the chain: connect this onward.
35
+ * @type {AudioNode}
36
+ */
37
+ output;
38
+
39
+ /**
40
+ * @type {BaseAudioContext}
41
+ */
42
+ #ctx;
43
+
44
+ /**
45
+ * The definitions the chain was built from — the source of each effect's parameter names. Shared with
46
+ * the owner (a bus or event definition); never written.
47
+ * @type {AbstractAudioEffect[]}
48
+ */
49
+ #effects;
50
+
51
+ /**
52
+ * Each effect's input and output node, in chain order: `[in0, out0, in1, out1, …]`. For {@link disconnect}.
53
+ * @type {AudioNode[]}
54
+ */
55
+ #nodes;
56
+
57
+ /**
58
+ * Every effect's live params, effect by effect, each effect's in its class's `parameters` order.
59
+ * @type {AudioParam[]}
60
+ */
61
+ #params;
62
+
63
+ /**
64
+ * Where each param of {@link #params} was last sent, same layout.
65
+ * @type {Float64Array}
66
+ */
67
+ #nominal;
68
+
69
+ /**
70
+ * @param {BaseAudioContext} ctx
71
+ * @param {AbstractAudioEffect[]} effects at least one
72
+ */
73
+ constructor(ctx, effects) {
74
+ assert.defined(ctx, 'ctx');
75
+ assert.isArray(effects, 'effects');
76
+ assert.greaterThan(effects.length, 0, 'effects.length');
77
+
78
+ this.#ctx = ctx;
79
+ this.#effects = effects;
80
+
81
+ const effectCount = effects.length;
82
+
83
+ let paramCount = 0;
84
+ for (let i = 0; i < effectCount; i++) {
85
+ paramCount += parametersOf(effects[i]).length;
86
+ }
87
+
88
+ const nodes = new Array(effectCount * 2);
89
+ const params = new Array(paramCount);
90
+ const nominal = new Float64Array(paramCount);
91
+
92
+ let slot = 0;
93
+ let previousOutput = null;
94
+
95
+ for (let i = 0; i < effectCount; i++) {
96
+ const effect = effects[i];
97
+ const built = effect.build(ctx);
98
+ const names = parametersOf(effect);
99
+
100
+ nodes[i * 2] = built.input;
101
+ nodes[i * 2 + 1] = built.output;
102
+
103
+ if (previousOutput === null) {
104
+ this.input = built.input;
105
+ } else {
106
+ previousOutput.connect(built.input);
107
+ }
108
+
109
+ previousOutput = built.output;
110
+
111
+ if (names.length > 0) {
112
+ const exposed = built.params;
113
+
114
+ // the class's list is the contract `build` answers to; a mismatch would silently move
115
+ // the wrong param, so it is refused here, where the effect that broke it is known
116
+ if (exposed === undefined || exposed.length !== names.length) {
117
+ throw new Error(`sopra: ${effect.constructor.name}.build returned ${exposed === undefined ? 'no' : exposed.length} params, its class declares ${names.length} (${names.join(', ')})`);
118
+ }
119
+
120
+ for (let p = 0; p < names.length; p++) {
121
+ params[slot] = exposed[p];
122
+ nominal[slot] = exposed[p].value;
123
+ slot++;
124
+ }
125
+ }
126
+ }
127
+
128
+ this.output = previousOutput;
129
+ this.#nodes = nodes;
130
+ this.#params = params;
131
+ this.#nominal = nominal;
132
+ }
133
+
134
+ /**
135
+ * @returns {number} how many effects the chain holds
136
+ */
137
+ get length() {
138
+ return this.#effects.length;
139
+ }
140
+
141
+ /**
142
+ * Whether the chain has an effect at `index` exposing a parameter called `name` — an address
143
+ * {@link setParam} would take. Asks; never throws.
144
+ * @param {number} index
145
+ * @param {string} name
146
+ * @returns {boolean}
147
+ */
148
+ hasParam(index, name) {
149
+ const effect = effectAt(this.#effects, index);
150
+
151
+ return effect !== undefined && parametersOf(effect).indexOf(name) !== -1;
152
+ }
153
+
154
+ /**
155
+ * The flat slot of an effect's parameter, or throw naming what does exist.
156
+ * @param {number} index
157
+ * @param {string} name
158
+ * @returns {number}
159
+ */
160
+ #slot(index, name) {
161
+ const effects = this.#effects;
162
+ const p = effectParamIndex(effects, index, name);
163
+
164
+ let slot = 0;
165
+ for (let i = 0; i < index; i++) {
166
+ slot += parametersOf(effects[i]).length;
167
+ }
168
+
169
+ return slot + p;
170
+ }
171
+
172
+ /**
173
+ * Move an effect's parameter to `value`, now. Whatever automation was in flight on it is cancelled.
174
+ *
175
+ * @param {number} index effect's position in the list the chain was built from
176
+ * @param {string} name one of the effect class's `parameters`
177
+ * @param {number} value in the parameter's own units (Hz, dB, ...)
178
+ */
179
+ setParam(index, name, value) {
180
+ // an AudioParam throws on a non-finite value, so say which call sent it
181
+ assert.isFinite(value, 'value');
182
+
183
+ const slot = this.#slot(index, name);
184
+ const param = this.#params[slot];
185
+ const now = this.#ctx.currentTime;
186
+
187
+ this.#nominal[slot] = value;
188
+
189
+ cancelAndHold(param, now);
190
+ param.setValueAtTime(value, now);
191
+ }
192
+
193
+ /**
194
+ * Glide an effect's parameter toward `value` exponentially, covering ~63% of the way per
195
+ * `timeConstant` — the WebAudio `setTargetAtTime` glide, and the counterpart of
196
+ * {@link BusGraph#approachVolume}. Whatever was in flight is cancelled and held first, so a value sent
197
+ * every frame (a filter tracking a game value) retargets from wherever the last glide had got to, and
198
+ * the automation list never grows.
199
+ *
200
+ * @param {number} index
201
+ * @param {string} name
202
+ * @param {number} value
203
+ * @param {number} timeConstant seconds, above 0
204
+ */
205
+ approachParam(index, name, value, timeConstant) {
206
+ assert.isFinite(value, 'value');
207
+ assert.isFinite(timeConstant, 'timeConstant');
208
+ assert.greaterThan(timeConstant, 0, 'timeConstant');
209
+
210
+ const slot = this.#slot(index, name);
211
+ const param = this.#params[slot];
212
+ const now = this.#ctx.currentTime;
213
+
214
+ this.#nominal[slot] = value;
215
+
216
+ cancelAndHold(param, now);
217
+ param.setTargetAtTime(value, now, timeConstant);
218
+ }
219
+
220
+ /**
221
+ * Where an effect's parameter was last sent — the target of a glide still in flight, not the value it
222
+ * has reached — or its defined value if it has not been moved.
223
+ * @param {number} index
224
+ * @param {string} name
225
+ * @returns {number}
226
+ */
227
+ getParam(index, name) {
228
+ return this.#nominal[this.#slot(index, name)];
229
+ }
230
+
231
+ /**
232
+ * Unwire every node the chain owns. Idempotent.
233
+ */
234
+ disconnect() {
235
+ const nodes = this.#nodes;
236
+
237
+ for (let i = 0; i < nodes.length; i++) {
238
+ nodes[i].disconnect();
239
+ }
240
+ }
241
+ }
242
+
243
+ /**
244
+ * @param {AbstractAudioEffect} effect
245
+ * @returns {string[]}
246
+ */
247
+ function parametersOf(effect) {
248
+ return effect.constructor.parameters;
249
+ }
250
+
251
+ /**
252
+ * @param {AbstractAudioEffect[]} effects
253
+ * @param {number} index
254
+ * @returns {AbstractAudioEffect|undefined} undefined for an index that is no position in the list
255
+ * (negative, fractional, past the end)
256
+ */
257
+ function effectAt(effects, index) {
258
+ return Number.isInteger(index) ? effects[index] : undefined;
259
+ }
260
+
261
+ /**
262
+ * Resolve an effect-parameter address against a list of effect definitions: the position of `name` among
263
+ * the class `parameters` of the effect at `index`, or throw naming what the list does have. The one
264
+ * place an `(effect index, parameter name)` address is checked — a chain resolves through it, and so does
265
+ * anything that holds addresses for a chain not yet built (`EffectParamOverrides`).
266
+ * @param {AbstractAudioEffect[]} effects
267
+ * @param {number} index
268
+ * @param {string} name
269
+ * @returns {number}
270
+ */
271
+ export function effectParamIndex(effects, index, name) {
272
+ const effect = effectAt(effects, index);
273
+
274
+ if (effect === undefined) {
275
+ throw new Error(`sopra: no effect at index ${index} (there are ${effects.length})`);
276
+ }
277
+
278
+ const names = parametersOf(effect);
279
+ const p = names.indexOf(name);
280
+
281
+ if (p === -1) {
282
+ throw new Error(`sopra: effect ${index} has no parameter '${name}' (it exposes: ${names.join(', ') || 'none'})`);
283
+ }
284
+
285
+ return p;
286
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @typedef {import("../definition/EventDescription.js").EventDescription} EventDescription
3
+ * @typedef {import("./EventInstance.js").EventInstance} EventInstance
4
+ */
5
+ /**
6
+ * How an {@link EffectParamOverrides} tells its owner to move the instance it currently plays: to `value`,
7
+ * now when `timeConstant` is 0, as a glide (`approachEffectParam`) above 0. A removed override sends the
8
+ * event's own value.
9
+ * @callback EffectParamChange
10
+ * @param {number} effectIndex
11
+ * @param {string} name
12
+ * @param {number} value
13
+ * @param {number} timeConstant seconds
14
+ * @returns {void}
15
+ */
16
+ /**
17
+ * Live overrides of an event's insert-effect parameters ({@link EventDescription.effects}) that outlive any
18
+ * one {@link EventInstance}. They belong to whatever plays the event over and over — an `AudioEmitter`,
19
+ * whose spatially managed instance is torn down on demotion and built afresh on promotion — and are put
20
+ * onto every instance it gets ({@link applyTo}), so a filter set on the emitter stays set however often
21
+ * the voice underneath is rebuilt.
22
+ *
23
+ * Runtime state, not a definition: never serialized, and no part of its owner's identity.
24
+ *
25
+ * An override is addressed the way an instance addresses the parameter itself: the effect's index in the
26
+ * event's `effects`, and one of that effect class's `parameters`. While {@link attach}ed to the event it
27
+ * addresses, every write is checked against the event's effects and one they do not have throws at the
28
+ * write, storing nothing; overrides written before that are checked when it attaches. Values are checked
29
+ * as an `AudioParam` would check them, in every build (not by `assert`). So an override that is held
30
+ * always fits, and no later rebuild of an instance can trip on one — as long as the event's effects are
31
+ * not edited in place while it is attached.
32
+ *
33
+ * One owner at a time: the attached one is told of every change ({@link EffectParamChange}) and moves the
34
+ * instance it currently plays, if any.
35
+ */
36
+ export class EffectParamOverrides {
37
+ /**
38
+ * @returns {number} how many parameters are overridden
39
+ */
40
+ get size(): number;
41
+ /**
42
+ * @returns {boolean} whether an owner is attached
43
+ */
44
+ get attached(): boolean;
45
+ /**
46
+ * Throw unless {@link attach} would take `event`: when another owner is attached, or when an override
47
+ * already held is one the event's effects do not have (named). Changes nothing — so an owner can ask
48
+ * before it does anything else, and attach once nothing else can fail.
49
+ * @param {EventDescription} event
50
+ */
51
+ checkAttach(event: EventDescription): void;
52
+ /**
53
+ * Become the overrides of whatever plays `event`: from now on every write is checked against its
54
+ * effects, and `onChange` is told of it. Checked first as {@link checkAttach} checks; on a throw nothing
55
+ * changes.
56
+ * @param {EventDescription} event the event the owner's instances are built from
57
+ * @param {EffectParamChange} onChange
58
+ */
59
+ attach(event: EventDescription, onChange: EffectParamChange): void;
60
+ /**
61
+ * Stop telling `onChange` of changes — if it is the attached owner; a later owner is left attached. The
62
+ * overrides themselves are kept, for whatever attaches next.
63
+ * @param {EffectParamChange} onChange
64
+ * @returns {boolean} whether `onChange` was attached
65
+ */
66
+ detach(onChange: EffectParamChange): boolean;
67
+ /**
68
+ * Override a parameter; the current instance moves there now.
69
+ * @param {number} effectIndex position in the event's `effects`
70
+ * @param {string} name one of that effect class's `parameters`
71
+ * @param {number} value in the parameter's own units (Hz, dB, ...)
72
+ */
73
+ set(effectIndex: number, name: string, value: number): void;
74
+ /**
75
+ * Override a parameter; the current instance glides there (see {@link EventInstance#approachEffectParam}).
76
+ * The override itself is the target, so an instance built while the glide is in flight starts AT it.
77
+ * @param {number} effectIndex
78
+ * @param {string} name
79
+ * @param {number} value
80
+ * @param {number} timeConstant seconds, above 0
81
+ */
82
+ approach(effectIndex: number, name: string, value: number, timeConstant: number): void;
83
+ /**
84
+ * @param {number} effectIndex
85
+ * @param {string} name
86
+ * @returns {number|undefined} the override, or undefined if the parameter is not overridden
87
+ */
88
+ get(effectIndex: number, name: string): number | undefined;
89
+ /**
90
+ * @param {number} effectIndex
91
+ * @param {string} name
92
+ * @returns {boolean}
93
+ */
94
+ has(effectIndex: number, name: string): boolean;
95
+ /**
96
+ * Drop an override: the current instance returns to the event's own value now, and later ones are built
97
+ * at it. To glide back instead, {@link approach} the event's value first.
98
+ * @param {number} effectIndex
99
+ * @param {string} name
100
+ * @returns {boolean} false if the parameter was not overridden
101
+ */
102
+ remove(effectIndex: number, name: string): boolean;
103
+ /**
104
+ * Drop every override (see {@link remove}).
105
+ */
106
+ clear(): void;
107
+ /**
108
+ * Put every override onto a freshly built instance, at once: a new instance starts at the overrides, not
109
+ * gliding toward them from the definition.
110
+ * @param {EventInstance} instance
111
+ */
112
+ applyTo(instance: EventInstance): void;
113
+ #private;
114
+ }
115
+ export type EventDescription = import("../definition/EventDescription.js").EventDescription;
116
+ export type EventInstance = import("./EventInstance.js").EventInstance;
117
+ /**
118
+ * How an {@link EffectParamOverrides } tells its owner to move the instance it currently plays: to `value`,
119
+ * now when `timeConstant` is 0, as a glide (`approachEffectParam`) above 0. A removed override sends the
120
+ * event's own value.
121
+ */
122
+ export type EffectParamChange = (effectIndex: number, name: string, value: number, timeConstant: number) => void;
123
+ //# sourceMappingURL=EffectParamOverrides.d.ts.map