@woosh/meep-engine 3.74.0 → 3.75.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 (161) hide show
  1. package/CHANGELOG.md +20 -19
  2. package/package.json +1 -1
  3. package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts +11 -0
  4. package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts.map +1 -0
  5. package/src/core/geom/2d/hilbert/v2_hilbert_encode.js +46 -0
  6. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +6 -0
  7. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
  8. package/src/engine/graphics/render/frame_graph/FrameGraph.js +9 -0
  9. package/src/engine/graphics3/GPUAcousticSystem.d.ts +29 -32
  10. package/src/engine/graphics3/GPUAcousticSystem.d.ts.map +1 -1
  11. package/src/engine/graphics3/GPUAcousticSystem.js +87 -162
  12. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  13. package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts.map +1 -1
  14. package/src/engine/sound/ecs/audio/AudioEmitterSystem.js +35 -17
  15. package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -1
  16. package/src/engine/sound/ecs/audio/LiveEmitterSet.js +2 -3
  17. package/src/engine/sound/simulation/AcousticSimulator.d.ts +7 -0
  18. package/src/engine/sound/simulation/AcousticSimulator.d.ts.map +1 -1
  19. package/src/engine/sound/simulation/AcousticSimulator.js +27 -0
  20. package/src/engine/sound/simulation/README.md +121 -107
  21. package/src/engine/sound/sopra/README.md +8 -3
  22. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts +2 -2
  23. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts.map +1 -1
  24. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.js +4 -3
  25. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts +118 -0
  26. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts.map +1 -0
  27. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.js +472 -0
  28. package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts +166 -0
  29. package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts.map +1 -0
  30. package/src/engine/sound/sopra/runtime/AcousticReverbLines.js +447 -0
  31. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts +69 -113
  32. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts.map +1 -1
  33. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.js +143 -491
  34. package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts +102 -0
  35. package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts.map +1 -0
  36. package/src/engine/sound/sopra/runtime/AcousticSpeakers.js +232 -0
  37. package/src/engine/sound/sopra/runtime/BusGraph.d.ts +17 -3
  38. package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -1
  39. package/src/engine/sound/sopra/runtime/BusGraph.js +55 -5
  40. package/src/engine/sound/sopra/runtime/EventInstance.d.ts +8 -6
  41. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  42. package/src/engine/sound/sopra/runtime/EventInstance.js +113 -105
  43. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts +13 -0
  44. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts.map +1 -0
  45. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.js +15 -0
  46. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
  47. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +4 -6
  48. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.d.ts.map +1 -1
  49. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.js +4 -5
  50. package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
  51. package/src/shade/playground/skinned_blas_refit/main.js +6 -12
  52. package/src/shade/playground/skinned_mesh_soup/main.d.ts.map +1 -1
  53. package/src/shade/playground/skinned_mesh_soup/main.js +1 -2
  54. package/src/shade/playground/vgeo_scene/README.md +12 -2
  55. package/src/shade/playground/vgeo_scene/main.js +1 -1
  56. package/src/shade/playground/volumetrics_froxel/README.md +191 -191
  57. package/src/shade/playground/volumetrics_froxel/measure.d.ts +3 -3
  58. package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -1
  59. package/src/shade/playground/volumetrics_froxel/measure.js +11 -13
  60. package/src/shade/playground/vsm/main.d.ts.map +1 -1
  61. package/src/shade/playground/vsm/main.js +5 -6
  62. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  63. package/src/shade/renderer/Renderer.js +31 -8
  64. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts +28 -0
  65. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts.map +1 -0
  66. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.js +42 -0
  67. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts +58 -0
  68. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts.map +1 -0
  69. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.js +108 -0
  70. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  71. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +161 -0
  72. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts.map +1 -0
  73. package/src/shade/renderer/acoustics/GPUAcousticProbes.js +760 -0
  74. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  75. package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts +12 -0
  76. package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts.map +1 -0
  77. package/src/shade/renderer/acoustics/acoustic_listener_order.js +56 -0
  78. package/src/shade/renderer/acoustics/chunk_acoustic_direct.d.ts.map +1 -1
  79. package/src/shade/renderer/acoustics/chunk_acoustic_direct.js +5 -0
  80. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts +57 -0
  81. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts.map +1 -0
  82. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.js +314 -0
  83. package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts +15 -0
  84. package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts.map +1 -0
  85. package/src/shade/renderer/acoustics/chunk_acoustic_finite.js +21 -0
  86. package/src/shade/renderer/acoustics/chunk_acoustic_gather.js +1 -1
  87. package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts +27 -0
  88. package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts.map +1 -0
  89. package/src/shade/renderer/acoustics/chunk_acoustic_lean.js +42 -0
  90. package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts +80 -0
  91. package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts.map +1 -0
  92. package/src/shade/renderer/acoustics/chunk_acoustic_listener.js +274 -0
  93. package/src/shade/renderer/acoustics/chunk_acoustic_partials.d.ts +2 -2
  94. package/src/shade/renderer/acoustics/chunk_acoustic_partials.js +2 -2
  95. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts +7 -0
  96. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts.map +1 -1
  97. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.js +24 -1
  98. package/src/shade/renderer/acoustics/chunk_acoustic_resample.js +1 -1
  99. package/src/shade/renderer/acoustics/chunk_acoustic_reservoir.js +1 -1
  100. package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts +43 -0
  101. package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts.map +1 -0
  102. package/src/shade/renderer/acoustics/chunk_acoustic_through.js +153 -0
  103. package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts +3 -1
  104. package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts.map +1 -1
  105. package/src/shade/renderer/acoustics/chunk_acoustic_trace.js +10 -1
  106. package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts +7 -3
  107. package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts.map +1 -1
  108. package/src/shade/renderer/acoustics/shader_acoustic_combine.js +22 -6
  109. package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts +14 -0
  110. package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts.map +1 -0
  111. package/src/shade/renderer/acoustics/shader_acoustic_coupling.js +102 -0
  112. package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts +12 -0
  113. package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts.map +1 -0
  114. package/src/shade/renderer/acoustics/shader_acoustic_listener.js +80 -0
  115. package/src/shade/renderer/acoustics/shader_acoustic_receive.d.ts.map +1 -1
  116. package/src/shade/renderer/acoustics/shader_acoustic_receive.js +27 -6
  117. package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts +11 -0
  118. package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts.map +1 -0
  119. package/src/shade/renderer/acoustics/shader_acoustic_room.js +111 -0
  120. package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts +18 -0
  121. package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts.map +1 -0
  122. package/src/shade/renderer/acoustics/shader_acoustic_source.js +130 -0
  123. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  124. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  125. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
  126. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  127. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  128. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.d.ts +2 -2
  129. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.js +2 -2
  130. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts +5 -2
  131. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts.map +1 -1
  132. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.js +5 -2
  133. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts +9 -2
  134. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts.map +1 -1
  135. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +48 -12
  136. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts +0 -22
  137. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts.map +1 -1
  138. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.js +0 -42
  139. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts +2 -18
  140. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts.map +1 -1
  141. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.js +2 -19
  142. package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.d.ts.map +1 -1
  143. package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.js +0 -1
  144. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts +5 -4
  145. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts.map +1 -1
  146. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.js +3 -1
  147. package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.d.ts.map +1 -1
  148. package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.js +3 -1
  149. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.d.ts.map +1 -1
  150. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.js +0 -1
  151. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts +60 -14
  152. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts.map +1 -1
  153. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.js +75 -39
  154. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts +0 -9
  155. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts.map +1 -1
  156. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js +45 -17
  157. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +7 -3
  158. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  159. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +43 -7
  160. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  161. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
@@ -309,6 +309,33 @@ export class AcousticSimulator {
309
309
  return instance.directivity.gain(FORWARD.x * dx + FORWARD.y * dy + FORWARD.z * dz);
310
310
  }
311
311
 
312
+ /**
313
+ * A frame with no listener: nothing is solved, and every source asked about that is not in `live_instances` is let
314
+ * go, as {@link apply} lets go of the ones that left. The ones still live keep what was solved for them, for the
315
+ * listener's return.
316
+ * @param {EventInstance[]} live_instances
317
+ */
318
+ retain(live_instances) {
319
+ const frame = ++this.#frame;
320
+
321
+ // the live sources that were asked about: one started since the listener went never was, and does not stand
322
+ // for one that was
323
+ let kept = 0;
324
+
325
+ for (let i = 0; i < live_instances.length; i++) {
326
+ const instance = live_instances[i];
327
+
328
+ if (this.#asked.has(instance)) {
329
+ this.#asked.set(instance, frame);
330
+ kept++;
331
+ }
332
+ }
333
+
334
+ if (this.#asked.size > kept) {
335
+ this.#asked.forEach(this.#prune_one);
336
+ }
337
+ }
338
+
312
339
  /**
313
340
  * Have the propagation forget a live instance (call when the instance ends).
314
341
  * @param {EventInstance} instance
@@ -1,9 +1,9 @@
1
1
  # Acoustic Simulation
2
2
 
3
- Real-time acoustics for meep: what a wall lets through, the early reflections and where they come from, the
4
- reverberation and how long it rings, the air's absorption. Sound is traced on the GPU through the same world the
5
- renderer's global illumination traces, every frame, with nothing baked, and the result **feeds the
6
- [sopra](../sopra/README.md) sound engine**, which renders it through WebAudio.
3
+ Real-time acoustics for meep: what a wall lets through, the reverberation, how long it rings and where it leans, the
4
+ air's absorption. Sound is traced on the GPU through the same world the renderer's global illumination traces, with
5
+ nothing baked, and the result **feeds the [sopra](../sopra/README.md) sound engine**, which renders it through
6
+ WebAudio.
7
7
 
8
8
  > One rule above all: **this layer computes, sopra renders.** `simulation/` imports no WebAudio. It turns each live
9
9
  > acoustic source into an `AcousticSolution`, a few numbers per band, and the `EventInstance.setAcoustic` seam and
@@ -17,11 +17,11 @@ renderer's global illumination traces, every frame, with nothing baked, and the
17
17
  WORLD GPU (shade/renderer/acoustics) CPU (simulation/) SOPRA (WebAudio)
18
18
  ───── ────────────────────────────── ───────────────── ────────────────
19
19
  render meshes ─► brick clipmap ─┐
20
- AcousticBody (material) ────────┼─► phonons the listener emits ─► a receiver ─► AcousticSolution ─► EventInstance.setAcoustic
21
- │ (one cohort a frame) a source {direct, early, direct taps, early taps
22
- └─► the direct path's rays ──────► earlyDirection, panned, reverb send
23
- AcousticVolume (air) ─────────────────────────────────────────────────────────► wet, wetCentreTime, ─► AcousticReverbEffect
24
- airLoss, ...} (one network a bus)
20
+ AcousticBody (material) ────────┼─► the listener's rays, ──────► the room ────► AcousticSolution ─► EventInstance.setAcoustic
21
+ │ first hits only decay, lean {direct, wet, direct taps, reverb send
22
+ └─► each source: its direct ────► its row wetCentreTime,
23
+ rays, a trace a hit a source wetDirection, ─► AcousticReverbEffect
24
+ AcousticVolume (air) ─────────────────────────────────────────────────────────► airLoss, ...} (a convolution a bus)
25
25
  ```
26
26
 
27
27
  Sound shares one geometry with light: the scene's **brick clipmap**, the signed-distance world the probe clipmap GI
@@ -29,7 +29,7 @@ traces. A wall blocks sound because its mesh is in that world; `AcousticBody` sa
29
29
  second representation of the scene for audio, no collider pairing and no bake.
30
30
 
31
31
  The GPU side is a **propagation** (`core/AcousticPropagation.js`): the simulator asks it for each live source's
32
- direct, early and reverberant energies and knows nothing else of it. `GPUAcousticSystem` (`engine/graphics3/`) is the
32
+ direct and reverberant energies and knows nothing else of it. `GPUAcousticSystem` (`engine/graphics3/`) is the
33
33
  one that ships. Without a propagation — no device, a headless run — every source has the **neutral solution**: its
34
34
  direct sound whole, nothing early, nothing reverberant. The air and the source's directivity are the simulator's own
35
35
  either way.
@@ -68,12 +68,20 @@ simulation/
68
68
  serialization/ binary save/load adapters (populateAcousticSerializationRegistry)
69
69
 
70
70
  shade/renderer/acoustics/ the GPU half
71
- GPUAcoustics.js the phonon ring, the receivers, their results read back
72
- GPUAcousticLattice.js receivers about the listener: a newborn sound's first answer
71
+ GPUAcousticProbes.js the probe at the listener, the sources' rows, read back
72
+ shader_acoustic_listener.js the listener's rays, each to its first hit
73
+ acoustic_listener_order.js the order they are traced in, a subgroup's rays to one patch of the sphere
74
+ shader_acoustic_room.js the room they add up to
75
+ shader_acoustic_coupling.js each source's first-order reflections off the hits
76
+ shader_acoustic_source.js each source's direct cone, and its reverberant energy
77
+ chunk_acoustic_direct_cone.js the direct cone: the share of the source each occluder leaves open
78
+ chunk_acoustic_through.js a path through walls, read from both ends
79
+ chunk_acoustic_listener.js a listener ray, its sums, a hit's reflection, the room
73
80
  GPUBrickAcoustics.js each brick's acoustic record, from the scene's acoustic_materials
74
- shader_*.js, chunk_*.js the kernels
81
+ GPUAcoustics.js, GPUAcousticLattice.js, the phonon and gather kernels
82
+ the path-traced acoustics, kept unwired (PATH_TRACED_RESEARCH.md)
75
83
 
76
- engine/graphics3/GPUAcousticSystem.js the ECS system: bodies to materials, sources to receivers, the propagation
84
+ engine/graphics3/GPUAcousticSystem.js the ECS system: bodies to materials, sources to rows, the propagation
77
85
  ```
78
86
 
79
87
  The render seam (`EventInstance.setAcoustic`, the `AudioEmitter.acoustic` flag, the `AudioEmitterSystem` driving)
@@ -128,7 +136,7 @@ emitter.directivity.dipolePower = 1; // > 1 narrows the lobe
128
136
 
129
137
  Add an `AcousticReverbEffect` to a bus's `effects`. An acoustic instance sends its reverberant energy to the nearest
130
138
  bus above its own that has one, so the reverb passes that bus's fader, ducking and snapshots. With none, sources
131
- still get their direct and early sound.
139
+ still get their direct sound.
132
140
 
133
141
  ---
134
142
 
@@ -138,87 +146,80 @@ still get their direct and early sound.
138
146
  voxel 12.5 cm. Each brick carries an acoustic record, the area-weighted mean of the materials of the surfaces it
139
147
  holds. Transparent meshes are not in the world, so glass does not block sound.
140
148
 
141
- **The direct path.** Sixteen lanes of a source's workgroup trace from the listener to 32 points of a fixed
142
- pattern on the source's disk as the listener sees it, two a lane (`acoustic_direct_target`). A ray that meets a wall
143
- marches through it and on, up to four crossings, taking each wall's transmission per band. The direct energy is the
144
- mean over the points: a source half behind an edge keeps its open half whole and the hidden half through the wall.
145
- The pattern is the same every frame, so a still scene's direct energy does not move, and an edge sweeping across it
146
- steps the level by one point at a time, 0.26 dB at half visibility. A lattice point aims at 16, one a lane.
147
-
148
- **Reflections.** The listener emits phonons, one cohort of 128 a frame into a ring of 128, so a cohort is as many
149
- bounces old as it is frames old. A phonon keeps `1 − α` of its energy at each surface and the air's loss over each
150
- segment, and leaves by the surface's lobe (`acoustic_lobe`): one cosine lobe tilted from the normal toward the mirror
151
- direction by the surface's scattering, Christensen and Rindel's "oblique Lambert", which sends on all the surface
152
- holds. By reciprocity, the energy a source would bring the listener along a path is what the listener's phonon
153
- carries to the path's last vertex: 48 lanes of each source's workgroup connect stored vertices to the source by the
154
- same lobe, eight strata by reflection order. A lane weighs 64 phonons of its stratum by what each would bring with
155
- nothing in the way, draws one in proportion and traces only that one (resampled importance sampling, `acoustic_pick`),
156
- answering its energy over its share of the weight, so its rays go where the energy is; a lattice point weighs one.
157
- What arrives within 80 ms of the direct sound is **early** energy, with the direction it comes from and the share ψ
158
- that comes from that one direction; what arrives later is **late** energy, with its centre time and its lean.
159
-
160
- **Paths re-checked every frame.** A phonon keeps its first bounce, and its cohort keeps where the listener stood when
161
- it was emitted. Each frame a gather lane joins the path to the listener where it is now (`acoustic_reconnect`): it
162
- traces the new first leg and scales the path by how much likelier the new place is to reach that bounce, and to leave
163
- it as the path did. A path whose first bounce the listener cannot see now counts nothing; one the listener emitted
164
- from where it stands is used as it flew, with no trace. Both ends of every path are the frame's, so an old cohort is
165
- as current as a new one where the new place sees what the old one did: stepping 3 m out of a corridor, the early
166
- energy is the new place's in the first frames after the step and 0.2 to 0.3 dB under it from 0.3 to 1 s, and the late
167
- energy reads 0.5 to 1 dB under it for about 0.6 s: the paths only the new place could have started are missing until
168
- the ring has emitted them.
169
-
170
- **Kept paths, not averages.** A source's gather lane keeps one path from frame to frame (`acoustic_reservoir_lane`):
171
- each frame it traces its fresh pick and the path it kept, both where the listener and the source are now, and keeps
172
- one in proportion to what it brings, weighted by the generalized balance heuristic between the fresh pick and the
173
- up to 20 frames of draws behind the kept path. Those frames are weighed at one of them drawn at random, in that
174
- frame's configuration, which each row keeps a ring of: a path that has just come into hearing, which no frame behind
175
- the kept path could have drawn, is the fresh pick's alone in its first frame. History decides how many draws stand
176
- behind an answer, never where the listener or the source is taken to be; nothing of the answers is averaged, and a
177
- stratum no lane of which answered adds nothing that frame. Lattice points keep nothing.
178
-
179
- **A frame's rays, rationed.** A receiver can take several workgroups a frame, its parts, each a full set of lanes with
180
- draws and reservoirs of its own; `shader_acoustic_combine` sums them into the result. Every live source has one
181
- part, and a fixed budget of 16 more (`ACOUSTIC_PARTS_BUDGET`) is shared among them in proportion to how loud each is
182
- heard with nothing in the way, its `EventInstance#currentGain` squared, times the spread its parts' estimates last
183
- showed (`acoustic_allocate_parts`): the rays go where they take the most error out of what is heard. Only sample
184
- counts follow from it, never an answer. A lone source on the listening page takes 16 parts, and its reflected levels
185
- move by 0.1 to 0.35 dB rms frame to frame (0.05 dB for the hall's late energy), against the 0.25 dB a steady sound
186
- needs.
187
-
188
- **Delivery.** The receivers are recorded at the start of the frame into the graph the renderer submits ahead of
189
- the rest (`FrameContext#early_graph`), their readback maps from that submit, and results are applied the moment the
190
- mapping lands, between frames, where the simulator answers its sources with them (`AcousticSimulator#refresh`). From
191
- the frame's listener pose to the Web Audio write takes about 5 ms on both a discrete and an integrated GPU.
192
-
193
- **A sound's first frame.** A new source has no result of its own until its first readback lands. A listener-centred
194
- lattice of receivers (4 cascades of 8³ points, 64 solved a frame) is mirrored on the CPU; a new source hears the
195
- trilinear blend of the solved points about it until then.
149
+ **The direct path.** One cone from the listener over the source's disk as the listener sees it, marched through the
150
+ field (`acoustic_direct_cone_cell`). Its cross-section is kept as 32 cells, a lane each, each the rays of the cone
151
+ through a cell of the disk: a ray to the cell's centre, softened over the cell's own width, where a surface's plane
152
+ cuts the cell `d / sin θ` off its centre, so the share moves smoothly as an edge crosses the disk and a face square to
153
+ the ray hides the cell whole. A cell keeps the least any sample of an occluder left it, so what different slices hide adds
154
+ up, as at the corner of two walls; it lets `v + (1 − v)·T` through, `v` that least share and `T` the wall's
155
+ transmission per band, and the source's direct energy is the mean over all the cells, one that did not resolve
156
+ passing nothing. A cell is read from both ends: a leg from
157
+ the listener passes every occluder it can see past and stops wholly inside a wall, a leg from the disk does the same
158
+ from the other side (from where the ray leaves the coarsest window, if the disk lies past it), and the interval between the two walls is read at eight points jittered by the cell
159
+ (`acoustic_through_interval`), each solid run past an open one another wall. So a cell's cost does not grow with the
160
+ walls between, and every wall multiplies. The field's own distance decides, not the ray tracer's half-voxel hit, so an edge
161
+ stands where the geometry has it: across a wall edge the open share follows the exact geometry within 0.05 for sources
162
+ of 5 to 50 cm radius, where a ray by the tracer's half-voxel hit reads edges 6 cm thick. A cell's ray marches the
163
+ cascade whose voxel holds its width, and where that is not the finest, the finest field is read too: a coarse cascade
164
+ cannot hold the depth of a wall a couple of its voxels thick. A source out of hearing (`EventInstance#currentGain` 0)
165
+ is not traced and keeps its last answer.
166
+
167
+ **One probe at the listener.** Every frame the listener sends 2,048 rays along a fixed Fibonacci sphere, each to its
168
+ first hit and no further (`acoustic_listener_ray`), in an order sorted along a Hilbert curve over the sphere's
169
+ octahedral map (`acoustic_listener_order`), so a subgroup's rays look into one patch of it and its hits, and their
170
+ traces to a source, keep together. Each hit stands for the piece of surface its solid angle covers
171
+ there, `r²·(4π/N)/cos θ` (`cos θ` held to the ray's own spread), and for the cone of room before it, `r³·(4π/N)/3`.
172
+ Summed, they are the room's surface `S` and volume `V`, its mean free path `4V/S` (Kosten), and its absorption, the
173
+ hits' area-weighted mean, with the rays that left counted as absorbed by their share of directions (`acoustic_room`):
174
+ those into open air, and those into space not built yet, whose energy is lost rather than assumed back. Then Eyring:
175
+ the reverb's decay per band, `τ = mfp / (c (−ln(1 − α) + m·mfp))` with the air's `m`, and the diffuse level over the
176
+ same loss; and where the room's reflecting surface lies, its lean. In a closed room the volume and surface read the
177
+ room's, the decay within 1% of Eyring's and the diffuse level within 0.5 dB; open on one side, its absorption takes
178
+ the opening's solid angle as the share it loses.
179
+
180
+ **A source's reverberant energy.** Each heard source traces one ray from every one of the listener's hits to itself
181
+ (`acoustic_listener_reflection`): what the listener hears of it off that piece of surface, its first-order
182
+ reflection, `4(1 − α)cos θ_s/(N r_s²)` as a ratio to its direct energy at 1 m (the listener's distance and angle cancel
183
+ against the hit's solid angle), times what the walls between the surface and the source let through, per band
184
+ (`acoustic_through`: a trace from each end, and the interval between read at eight points jittered by the hit). The
185
+ orders after lose `α` a reflection as the room does and the air its share over a free path, so all of them are the
186
+ first over `1 − (1 − α)·e^(−m·mfp)` (`acoustic_reverb_orders`); against the source's own
187
+ direct sound `d` away, times `d²`: its `wet` term. A source in the room lights the walls about the listener and brings
188
+ the reverberant energy diffuse-field theory gives at its distance (within 1.5 dB in a closed room); one through a
189
+ doorway lights what the opening shows it, as far off as it is; one behind a wall lights the listener's room through
190
+ the wall, darkened as the wall's transmission is per band. Every ray is the same every frame: a still scene reads the same, and walking moves the send by
191
+ 0.004 to 0.03 dB rms a frame on the listening page.
192
+
193
+ **Delivery.** The frame's pass is recorded at its start into the graph the renderer submits ahead of the rest
194
+ (`FrameContext#early_graph`), its readback maps from that submit, and results are applied the moment the mapping lands,
195
+ between frames, where the simulator answers its sources with them (`AcousticSimulator#refresh`). What the frame traced
196
+ is read back: the room and the heard sources' rows.
196
197
 
197
198
  **Air.** `AcousticVolume` regions carry an `AcousticMedium` whose `airAbsorption` is in **dB per metre**, per band.
198
199
  `VolumeField.integrateAbsorption` line-integrates it along the source→listener path into `AcousticSolution.airLoss`.
199
200
  It is heard as a **low-anchored tilt**: only the high-versus-low excess darkens, so a uniform loss — which the
200
201
  authored attenuation curve already owns as loudness — changes nothing. The curve owns how loud, the air how bright.
201
202
 
202
- **Rendering.** `EventInstance.setAcoustic` sets three tap sets on the instance's three-band split: the direct taps,
203
- the early taps panned along the early direction by ψ, and the reverberant send, `wet + (1 − ψ)·early`, to the bus's
204
- `AcousticReverbNetwork`: one feedback delay network whose decay per band follows the senders' centre times, so the
205
- reverberation changes with the room every frame without rebuilding anything. Its output passes a correction from a
206
- gain model of what its tail holds, so a send that drops because the listener left the room is heard at the new level
207
- at once rather than after the tail has decayed to it. Every write is a straight ramp over the interval between
208
- updates, `acoustic_ramp`, and only when the value moved past what the ear can tell.
203
+ **Rendering.** `EventInstance.setAcoustic` sets the instance's direct taps and its reverberant send, `wet`, to the bus's
204
+ `AcousticReverbNetwork`: a convolution with a decaying noise whose decay per band follows the senders' centre times
205
+ (`AcousticReverbConvolution`, a new decay warmed in a second convolver before it is heard), its lean played through six
206
+ speakers that stand still about the listener. Each source has the say in it that it has in what is heard. Its output
207
+ passes a correction from each source's own model of what it put in the tail, so a send that drops because the listener
208
+ left the room is heard at the new level at once rather than after the tail has decayed to it, while a source turned
209
+ down, fading or stopping rings out. Every write is a straight ramp over the interval between updates, `acoustic_ramp`,
210
+ and only when the value moved past what the ear can tell. There are no early taps: a reflection is the reverb's.
209
211
 
210
212
  ---
211
213
 
212
214
  ## Cost
213
215
 
214
- The GPU work a frame is the ring's step (16,384 phonons, one trace each) and a 64-lane workgroup a live receiver:
215
- the live acoustic sources, bounded by the voice budget, and 64 lattice points. A gather lane traces one ray more
216
- while the listener stands away from where its phonon's cohort was emitted, and a source's lanes weigh 64 candidates
217
- each, a phonon read and arithmetic apiece, and trace their kept path again, and both paths once more in a past
218
- frame's configuration when the listener or the source has moved since. A part costs an integrated GPU about 24 µs
219
- standing and 42 µs walking, so the budget's 16 are 0.4 to 0.7 ms however many sources share them. No thread loops over sources,
220
- receivers or phonons; each trace has a 64-step budget. The CPU work is a write when a source starts, moves or turns,
221
- and a copy of the results that landed.
216
+ The GPU work a frame is the listener's 2,048 rays, one trace each (32 workgroups), a one-workgroup sum of them, and per
217
+ heard source 2,048 paths from the hits to it (32 workgroups) and a workgroup whose 32 lanes read its cone's cells.
218
+ Every path and every cell is two traces and eight point reads between, however many walls stand between: no thread
219
+ loops over bounces, sources, hits or walls. On the listening page's AMD iGPU one source takes 0.31 ms in all (the
220
+ listener's rays 0.09 ms, its coupling 0.17 ms, its cone 0.03 ms); 1,024 sources spread over the scene, most of them
221
+ behind walls, 64 ms, nearly all of it the coupling. The CPU work is a write when a source starts or moves, and a copy
222
+ of what landed.
222
223
 
223
224
  ---
224
225
 
@@ -226,37 +227,50 @@ and a copy of the results that landed.
226
227
 
227
228
  - `simulation/` is WebAudio-free and tested on real components; the render seam and the reverb use sopra's
228
229
  `MockAudioContext`.
229
- - The kernels run in `ComputeShaderEmulator` (`shade/renderer/acoustics/*.spec.js`): the direct path against walls,
230
- a closed room's late energy against Eyring's decay and the diffuse-field level, a corridor's early energy against
231
- its opening.
230
+ - The kernels run in `ComputeShaderEmulator` (`shade/renderer/acoustics/*.spec.js`): the direct cone against walls
231
+ and against the exact share of the disk a wall edge or a floor hides, traced against the boxes themselves;
232
+ the listener's rays in a closed room against its volume and surface, Eyring's decay and the diffuse-field level, open
233
+ air against nothing; a source's reverberant energy against diffuse-field theory at its distance, and behind a wall
234
+ against the wall's transmission, per band.
232
235
  - `GPUAcousticSystem.spec.js` runs the system on a software device, which records dispatches and runs copies and
233
236
  mappings.
234
237
  - The listening page, `shade/playground/acoustics/`, is the place to hear it and to measure it on a device: a hall, a
235
238
  corridor, a soft room and the open ground outside, one source, keys to move the listener and the source, and the
236
- frame's direct, early and late levels on screen. It exposes itself as `globalThis.acoustics_page` for a driver.
239
+ frame's direct and reverberant levels on screen. It exposes itself as `globalThis.acoustics_page` for a driver.
237
240
 
238
241
  ---
239
242
 
240
243
  ## Limits
241
244
 
242
- - Sound does not bend round an edge: a source behind a corner is heard through its reflections only.
245
+ - A gross approximation by design: one probe, first hits only, statistical room acoustics over them. The room is what
246
+ the listener sees: a corridor that opens into a hall reads the hall's volume in its own, and decays longer than its
247
+ walls would alone (2.6 s on the listening page where the path tracer read about 0.9 s).
248
+ - Sound does not bend round an edge: a source behind a corner is heard through what it lights of the listener's room.
249
+ - No early reflections or echoes of their own: every reflection is the reverb's, a decay from the first sample.
250
+ - The orders past the first lose the room's mean absorption each: a source lighting one hard wall of a soft room rings
251
+ as the soft room does.
243
252
  - Glass and other transparent meshes do not block sound.
244
- - No discrete echoes: the late energy is a decay, not a set of arrivals.
245
- - The brick world covers the clipmap's cascades about the camera; a path that leaves them is lost.
246
- - A path's middle is not re-checked: a door that closes silences at once the paths whose ends it blocks, and those
247
- whose middle runs through it only as the ring refreshes, up to 2 s for the highest orders.
248
- - Reconnection has only the paths the listener's earlier places emitted: after a jump it lacks those whose first
249
- bounce the new place sees and the old did not, and off smooth surfaces those the new arrival's lobe sends where the
250
- old one sent nothing, until the ring refreshes.
251
- - Every reflection is one cosine lobe, so a sharp mirror reflection is spread: the early sound's directional share ψ
252
- reads lower than a mirror would give.
253
+ - The brick world covers the clipmap's cascades about the camera; past them nothing is known to stand, and a path that
254
+ leaves them is taken as clear from there.
255
+ - Every surface reflects as Lambert's for the coupling, whatever its scattering.
253
256
  - A ray that starts or ends within half a voxel of a surface steps through that shell by the field's own value
254
257
  (`acoustic_trace`), eight steps at most: one that skims the surface for longer is lost.
255
- - Space the brick clipmap has not built yet reads as open air: for the first frames of a scene, or after the
256
- clipmap is rebuilt, sources are heard unoccluded.
257
- - A lane whose march runs out of steps is left out of its stratum, which is scaled by the lanes that answered; and
258
- a source none of whose direct points resolved keeps its last direct energy.
259
- - The reverb's diffuse and directional shares are the same line signals, so at a lean between none and all the tail
260
- plays up to 2 dB louder than sent. The network's lines are tuned at 48 kHz and take no account of the render
261
- quantum a Web Audio delay loop adds: decays run 5 to 10% long, more at other sample rates.
262
- - A source's say in the reverb's decay and lean follows its distance gain and what it sends, not its fader.
258
+ - A wall thinner than a voxel of its cascade (12.5 cm about the camera) stands in the field as a dip that never reads
259
+ below zero, which the field cannot tell from a surface passed that near. The direct cone goes by the distance and
260
+ passes part of the sound through it (a 10 cm wall square to the line, of a 5 cm source, passes about 70%); the
261
+ reflections' paths go by the tracer's half-voxel hit and do not.
262
+ - The direct cone's cells are softened over their own width, and a cell's ray steps half a voxel at least near a
263
+ surface: an occluder thinner than a cell, a pole in front of a wide source, hides less than its geometry (a 3 cm pole
264
+ in front of a 25 cm source hides 15% of it; the cone reads 3%). Walls, edges, corners and floors read as the geometry
265
+ has them.
266
+ - Between the first wall and the last a path or a cell reads eight jittered points, so a wall thinner than their
267
+ spacing between them is caught only by the share of rays whose points land in it; the energies are averaged, so the
268
+ rays that miss it carry the mean, and it reads louder than the geometry. It stays under what the first and last
269
+ walls pass: on the listening page, three walls between the listener and the source read −58 dB where they pass
270
+ −81 dB, and the coupling through several walls 2 to 8 dB louder than a march through every wall.
271
+ - Sound through a wall lights the listener's room by its first-order reflections only; the source's own room, heard
272
+ through the wall, is not there: one probe stands at the listener, none at the source.
273
+ - Space the brick clipmap has not built yet is not known: a ray through it ends there. A cone cell that ends so passes
274
+ nothing; a source none of whose cells resolves keeps its last direct energy, or is heard whole if it never had one
275
+ (the neutral solution); the room counts a ray into it as one that left.
276
+ - The path-traced acoustics, kept unwired, and why they were set aside: `PATH_TRACED_RESEARCH.md`.
@@ -75,7 +75,10 @@ sopra/
75
75
  ParameterStore.js live RTPC values + change bindings
76
76
  EffectParamOverrides.js an owner's effect parameters, put onto each instance it gets
77
77
  SopraPlaybackContext.js per-source seeded RNG + random-container history (determinism)
78
- AcousticReverbNetwork.js the built acoustic reverb: a feedback delay network, 8 lines
78
+ AcousticReverbNetwork.js the acoustic reverb: what its senders add up to, over a tank
79
+ AcousticReverbConvolution.js the tank AcousticReverbEffect builds: a decaying noise per band, two warm pairs
80
+ AcousticReverbLines.js a feedback delay network tank, 8 lines (kept; not built by default)
81
+ AcousticSpeakers.js six panners that stand still around the listener, fed by gains
79
82
  acoustic_writes.js when an acoustic instance's or the reverb's values are written, and how
80
83
  asset/ how the engine gets decoded buffers
81
84
  BufferProvider.js the interface (tryGet sync / get async)
@@ -368,8 +371,10 @@ share one reverb across many sources. `ReverbEffect` generates its impulse respo
368
371
  `AcousticReverbEffect` in a bus's `effects` is where acoustic instances' reverberation rings. Each acoustic
369
372
  instance sends its reverberant energy, per band, to the nearest bus above its own bus that has one, so the
370
373
  reverberation passes that bus's fader, ducking and snapshots like anything else on it. Nothing about it is authored:
371
- built, it is a feedback delay network whose decay per band follows the senders' reverberation, energy-weighted, and
372
- is retuned every frame without clicks or rebuilding; the level and the lean come from the simulation too. Without
374
+ built, it convolves with a decaying noise whose decay per band follows the senders' reverberation, energy-weighted:
375
+ a smooth, diffuse tail from the first sample. A new decay is warmed in a second convolver, fed the live signal and
376
+ silent until its tail has built, then crossed over to, so the change is not heard as a dip; the level and the lean
377
+ come from the simulation too. Without
373
378
  one, acoustic instances keep their direct and early sound and lose only the reverberation.
374
379
 
375
380
  ```js
@@ -5,8 +5,8 @@
5
5
  * The acoustic reverb, as a bus insert: the bus's signal passes through, and the reverberation of every acoustic
6
6
  * source that sends to it is added (GPU acoustics design, "Where it sits, and what drives it").
7
7
  *
8
- * Built, it is one {@link AcousticReverbNetwork}: a feedback delay network whose decay per band follows the
9
- * simulation every frame. Acoustic instances reach its side input through the nearest bus above them that has one
8
+ * Built, it is one {@link AcousticReverbNetwork} over an {@link AcousticReverbConvolution}: a decaying noise whose
9
+ * decay per band follows the simulation. Acoustic instances reach its side input through the nearest bus above them that has one
10
10
  * (`BusGraph#getAcousticReverb`), so the reverberation passes that bus's fader, ducking and snapshots like anything
11
11
  * else on it, and a reverb with the effects bus at zero is silent.
12
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AcousticReverbEffect.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/sound/sopra/definition/effect/AcousticReverbEffect.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;;;;;GAWG;AACH;IAWI;;;OAGG;IACH,cAHW,oBAAoB,GAClB,OAAO,CAInB;IAED,eAEC;IAED,8BAEC;IAED,aAEC;IAED,0BACC;IAKL;;;OAGG;IACH,iCAFU,OAAO,CAEoC;CARpD;;;;+BAhDY,OAAO,0BAA0B,EAAE,gBAAgB;oCAH5B,0BAA0B"}
1
+ {"version":3,"file":"AcousticReverbEffect.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/sound/sopra/definition/effect/AcousticReverbEffect.js"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;;;;;;;;GAWG;AACH;IAWI;;;OAGG;IACH,cAHW,oBAAoB,GAClB,OAAO,CAInB;IAED,eAEC;IAED,8BAEC;IAED,aAEC;IAED,0BACC;IAKL;;;OAGG;IACH,iCAFU,OAAO,CAEoC;CARpD;;;;+BAhDY,OAAO,0BAA0B,EAAE,gBAAgB;oCAH5B,0BAA0B"}
@@ -1,3 +1,4 @@
1
+ import { AcousticReverbConvolution } from "../../runtime/AcousticReverbConvolution.js";
1
2
  import { AcousticReverbNetwork } from "../../runtime/AcousticReverbNetwork.js";
2
3
  import { AbstractAudioEffect } from "./AbstractAudioEffect.js";
3
4
 
@@ -9,8 +10,8 @@ import { AbstractAudioEffect } from "./AbstractAudioEffect.js";
9
10
  * The acoustic reverb, as a bus insert: the bus's signal passes through, and the reverberation of every acoustic
10
11
  * source that sends to it is added (GPU acoustics design, "Where it sits, and what drives it").
11
12
  *
12
- * Built, it is one {@link AcousticReverbNetwork}: a feedback delay network whose decay per band follows the
13
- * simulation every frame. Acoustic instances reach its side input through the nearest bus above them that has one
13
+ * Built, it is one {@link AcousticReverbNetwork} over an {@link AcousticReverbConvolution}: a decaying noise whose
14
+ * decay per band follows the simulation. Acoustic instances reach its side input through the nearest bus above them that has one
14
15
  * (`BusGraph#getAcousticReverb`), so the reverberation passes that bus's fader, ducking and snapshots like anything
15
16
  * else on it, and a reverb with the effects bus at zero is silent.
16
17
  *
@@ -23,7 +24,7 @@ export class AcousticReverbEffect extends AbstractAudioEffect {
23
24
  * @returns {BuiltAudioEffect} its network as `acoustic`; no params, since what moves it is the simulation
24
25
  */
25
26
  build(ctx) {
26
- const network = new AcousticReverbNetwork(ctx);
27
+ const network = new AcousticReverbNetwork(ctx, new AcousticReverbConvolution(ctx));
27
28
 
28
29
  return { input: network.output, output: network.output, acoustic: network };
29
30
  }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Centre times a new impulse response is fed the live signal for before it is heard: `ln(1 / (1 − 10^(−d/10)))` for
3
+ * `d` the write rule's half decibel. A convolver's state is emptied when it takes a response, and an exponential tail
4
+ * builds to `1 − e^(−t/τ)` of its steady energy in `t`; after this long it holds all but half a decibel of it, so the
5
+ * switch to it is not heard as a dip. Derived.
6
+ * @type {number}
7
+ */
8
+ export const ACOUSTIC_CONVOLUTION_WARMUP: number;
9
+ /**
10
+ * # A tank of the acoustic reverb: convolution with a decaying noise
11
+ *
12
+ * What `AcousticReverbEffect` builds. Each band's tail is white noise under an exponential of the band's centre time,
13
+ * the three bands split at the edges every band split in the engine has ({@link LOW_MID_HZ}, {@link MID_HIGH_HZ}),
14
+ * by fourth-order Linkwitz–Riley crossovers (`split_noise`): a Gaussian
15
+ * tail from the first sample, so an impulse comes out as a smooth decay, with no echoes a line long and nothing that
16
+ * circulates (a loop of Web Audio nodes is not played exactly as wired: `simulation/PATH_TRACED_RESEARCH.md`).
17
+ *
18
+ * **Outputs.** {@link stereo}, the diffuse pair, two independent noises at half the energy each; {@link mono}, the
19
+ * directional share, a third. All three are uncorrelated, so the diffuse and directional shares' energies add.
20
+ *
21
+ * **Level.** A band of a send of energy `E` comes out with energy `E` over the pair, and `E` from the mono sum
22
+ * (`write_response`), whatever the decay: the send enters as it is ({@link send_gain} is 1).
23
+ *
24
+ * **A new decay.** A convolver empties its state when it takes a response, so a response swapped in under the signal
25
+ * would start from silence, and a tail cut there would be heard. The tank has two convolver pairs, each always fed:
26
+ * the one heard, and one a new response is put in. The new one is fed the live signal, silent, for
27
+ * {@link ACOUSTIC_CONVOLUTION_WARMUP} of its longest band's centre time, by when its tail has built to within half a
28
+ * decibel of steady; then the two cross over within one update interval. A decay asked for while one is warming waits
29
+ * for it, and is put in next. The first decay is heard at once.
30
+ *
31
+ * A response is at least as long as its longest band takes to fall 60 dB. A pair's buffers are made at its first decay
32
+ * and made again only when a longer one is needed; a shorter decay fills the buffer it has, falling on past 60 dB.
33
+ */
34
+ export class AcousticReverbConvolution {
35
+ /**
36
+ * @param {BaseAudioContext} ctx
37
+ */
38
+ constructor(ctx: BaseAudioContext);
39
+ /**
40
+ * Where the send enters: it feeds both pairs.
41
+ * @type {GainNode}
42
+ */
43
+ input: GainNode;
44
+ /**
45
+ * The diffuse pair.
46
+ * @type {GainNode}
47
+ */
48
+ stereo: GainNode;
49
+ /**
50
+ * The directional sum.
51
+ * @type {GainNode}
52
+ */
53
+ mono: GainNode;
54
+ /**
55
+ * The shortest centre time the tank plays, seconds: a period of the lowest band edge, the shortest tail that can
56
+ * carry its low band.
57
+ * @type {number}
58
+ */
59
+ shortest: number;
60
+ /**
61
+ * The two convolver pairs. For inspection.
62
+ * @type {ConvolutionSlot[]}
63
+ */
64
+ slots: ConvolutionSlot[];
65
+ /**
66
+ * The amplitude a band's send enters at: as it is, since the response carries the level.
67
+ *
68
+ * @param {number} centre_time seconds
69
+ * @returns {number}
70
+ */
71
+ send_gain(centre_time: number): number;
72
+ /**
73
+ * Ask for a decay: heard at once the first time, else warmed in the other pair and crossed over to when warm.
74
+ *
75
+ * @param {ArrayLike<number>} centre centre times, seconds, per band
76
+ * @param {ArrayLike<number>} sent the centre times last asked for; unread
77
+ * @param {number} now context time
78
+ * @param {number} interval seconds a crossover takes; 0 is the first decay, heard at once
79
+ * @param {boolean} resting unread: the tank's gains are its own
80
+ */
81
+ set_decay(centre: ArrayLike<number>, sent: ArrayLike<number>, now: number, interval: number, resting: boolean): void;
82
+ /**
83
+ * Each frame: a warm pair crosses over, and a decay that waited is put in.
84
+ *
85
+ * @param {number} now context time
86
+ * @param {number} interval seconds a crossover takes
87
+ */
88
+ update(now: number, interval: number): void;
89
+ /**
90
+ * Unwire the tank.
91
+ */
92
+ disconnect(): void;
93
+ #private;
94
+ }
95
+ /**
96
+ * One of the tank's two convolver pairs: its send, its stereo and its mono convolver, their output gains, and the
97
+ * buffers it last took (grown, never shrunk).
98
+ */
99
+ declare class ConvolutionSlot {
100
+ /** @type {GainNode} */
101
+ send: GainNode;
102
+ /** @type {ConvolverNode} */
103
+ stereo: ConvolverNode;
104
+ /** @type {ConvolverNode} */
105
+ mono: ConvolverNode;
106
+ /** What its stereo convolver is heard through: 1 for the pair heard. @type {GainNode} */
107
+ heard: GainNode;
108
+ /** What its mono convolver is heard through, alike. @type {GainNode} */
109
+ heard_mono: GainNode;
110
+ /** @type {AudioBuffer|null} */
111
+ stereo_buffer: AudioBuffer | null;
112
+ /** @type {AudioBuffer|null} */
113
+ mono_buffer: AudioBuffer | null;
114
+ /** The centre times its response decays by, per band; NaN before it took one. */
115
+ centre: Float64Array;
116
+ }
117
+ export {};
118
+ //# sourceMappingURL=AcousticReverbConvolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcousticReverbConvolution.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra/runtime/AcousticReverbConvolution.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,0CAFU,MAAM,CAEqG;AAiKrH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;IAoDI;;OAEG;IACH,iBAFW,gBAAgB,EA2C1B;IA/FD;;;OAGG;IACH,OAFU,QAAQ,CAEZ;IAEN;;;OAGG;IACH,QAFU,QAAQ,CAEX;IAEP;;;OAGG;IACH,MAFU,QAAQ,CAEb;IAEL;;;;OAIG;IACH,UAFU,MAAM,CAEU;IAE1B;;;OAGG;IACH,OAFU,eAAe,EAAE,CAE4B;IAoEvD;;;;;OAKG;IACH,uBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;;OAQG;IACH,kBANW,UAAU,MAAM,CAAC,QACjB,UAAU,MAAM,CAAC,OACjB,MAAM,YACN,MAAM,WACN,OAAO,QAsBjB;IAED;;;;;OAKG;IACH,YAHW,MAAM,YACN,MAAM,QA8BhB;IAmFD;;OAEG;IACH,mBAaC;;CACJ;AAhcD;;;GAGG;AACH;IACI,uBAAuB;IACvB,MADW,QAAQ,CACd;IAEL,4BAA4B;IAC5B,QADW,aAAa,CACjB;IAEP,4BAA4B;IAC5B,MADW,aAAa,CACnB;IAEL,yFAAyF;IACzF,OAD6E,QAAQ,CAC/E;IAEN,wEAAwE;IACxE,YAD4D,QAAQ,CACzD;IAEX,+BAA+B;IAC/B,eADW,WAAW,GAAC,IAAI,CACN;IAErB,+BAA+B;IAC/B,aADW,WAAW,GAAC,IAAI,CACR;IAEnB,iFAAiF;IACjF,qBAA2C;CAC9C"}