@woosh/meep-engine 2.154.0 → 2.156.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.
- package/README.md +1 -1
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/editor/view/ecs/ComponentControlView.d.ts +0 -9
- package/editor/view/ecs/ComponentControlView.js +2 -98
- package/package.json +1 -1
- package/src/core/binary/32BitEncoder.js +1 -1
- package/src/core/binary/to_half_float_uint16.js +3 -3
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy_radix.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy_radix.js +275 -253
- package/src/core/cache/Cache.d.ts.map +1 -1
- package/src/core/cache/Cache.js +7 -0
- package/src/core/cache/FrequencySketch.d.ts.map +1 -1
- package/src/core/cache/FrequencySketch.js +8 -4
- package/src/core/clipboard/obtainClipBoard.d.ts +6 -0
- package/src/core/clipboard/obtainClipBoard.d.ts.map +1 -0
- package/src/core/clipboard/obtainClipBoard.js +29 -0
- package/src/core/clipboard/safeClipboardReadText.d.ts +6 -0
- package/src/core/clipboard/safeClipboardReadText.d.ts.map +1 -0
- package/src/core/clipboard/safeClipboardReadText.js +55 -0
- package/src/core/clipboard/safeClipboardWriteText.d.ts +8 -0
- package/src/core/clipboard/safeClipboardWriteText.d.ts.map +1 -0
- package/src/core/clipboard/safeClipboardWriteText.js +23 -0
- package/src/core/collection/array/array_quick_sort_by_lookup_map.js +1 -1
- package/src/core/collection/array/array_set_diff_sorting.d.ts.map +1 -1
- package/src/core/collection/array/array_set_diff_sorting.js +4 -1
- package/src/core/collection/array/array_shuffle.d.ts.map +1 -1
- package/src/core/collection/array/array_shuffle.js +30 -27
- package/src/core/collection/array/binarySearchLowIndex.d.ts.map +1 -1
- package/src/core/collection/array/binarySearchLowIndex.js +4 -3
- package/src/core/collection/array/typed/array_buffer_hash.js +1 -1
- package/src/core/collection/array/typed/is_typed_array_equals.d.ts.map +1 -1
- package/src/core/collection/array/typed/is_typed_array_equals.js +12 -2
- package/src/core/collection/heap/BinaryHeap.d.ts.map +1 -1
- package/src/core/collection/heap/BinaryHeap.js +12 -2
- package/src/core/collection/queue/Deque.d.ts.map +1 -1
- package/src/core/collection/queue/Deque.js +10 -8
- package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
- package/src/core/collection/table/RowFirstTable.js +4 -2
- package/src/core/collection/table/RowFirstTableSpec.js +2 -2
- package/src/core/color/operations/color_lerp.d.ts.map +1 -1
- package/src/core/color/operations/color_lerp.js +10 -3
- package/src/core/color/rgb2uint32.js +1 -1
- package/src/core/color/rgbe9995_to_rgb.js +1 -1
- package/src/core/function/objectsEqual.d.ts.map +1 -1
- package/src/core/function/objectsEqual.js +2 -1
- package/src/core/geom/2d/aabb/AABB2.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/AABB2.js +12 -11
- package/src/core/geom/2d/convex-hull/convex_hull_jarvis_2d.d.ts.map +1 -1
- package/src/core/geom/2d/convex-hull/convex_hull_jarvis_2d.js +30 -4
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.d.ts.map +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +6 -2
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.d.ts.map +1 -1
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.js +388 -386
- package/src/core/geom/2d/hash-grid/shg_query_elements_line.d.ts.map +1 -1
- package/src/core/geom/2d/hash-grid/shg_query_elements_line.js +8 -3
- package/src/core/geom/2d/quad-tree/QuadTreeDatum.d.ts.map +1 -1
- package/src/core/geom/2d/quad-tree/QuadTreeDatum.js +9 -1
- package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.d.ts +3 -1
- package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.d.ts.map +1 -1
- package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +3 -1
- package/src/core/geom/2d/quad-tree-binary/QuadTree.js +714 -714
- package/src/core/geom/2d/r-tree/StaticR2Tree.d.ts.map +1 -1
- package/src/core/geom/2d/r-tree/StaticR2Tree.js +5 -4
- package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +33 -29
- package/src/core/geom/3d/aabb/aabb3_near_distance_to_intersection_ray_segment.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_near_distance_to_intersection_ray_segment.js +3 -1
- package/src/core/geom/3d/aabb/aabb3_signed_distance_to_aabb3.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_signed_distance_to_aabb3.js +10 -7
- package/src/core/geom/3d/aabb/aabb3_transformed_compute_plane_side.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_transformed_compute_plane_side.js +30 -9
- package/src/core/geom/3d/aabb/compute_aabb_from_points.js +3 -3
- package/src/core/geom/3d/box/box3_raycast.d.ts +37 -0
- package/src/core/geom/3d/box/box3_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/box/box3_raycast.js +81 -0
- package/src/core/geom/3d/capsule/capsule_raycast.d.ts +35 -0
- package/src/core/geom/3d/capsule/capsule_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/capsule/capsule_raycast.js +93 -0
- package/src/core/geom/3d/cone/compute_bounding_cone_of_2_cones.d.ts.map +1 -1
- package/src/core/geom/3d/cone/compute_bounding_cone_of_2_cones.js +4 -0
- package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- package/src/core/geom/3d/line/line3_compute_segment_point_distance_eikonal.d.ts.map +1 -1
- package/src/core/geom/3d/line/line3_compute_segment_point_distance_eikonal.js +3 -2
- package/src/core/geom/3d/mat4/decompose_matrix_4_array.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/decompose_matrix_4_array.js +12 -2
- package/src/core/geom/3d/mat4/eulerAnglesFromMatrix.js +2 -2
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.d.ts +1 -1
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.js +19 -13
- package/src/core/geom/3d/octahedra/octahedral_direction_to_uv.d.ts.map +1 -1
- package/src/core/geom/3d/octahedra/octahedral_direction_to_uv.js +3 -2
- package/src/core/geom/3d/plane/plane3_compute_plane_intersection.js +3 -2
- package/src/core/geom/3d/shape/MeshShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/MeshShape3D.js +7 -0
- package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnionShape3D.js +3 -2
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts.map +1 -1
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js +153 -148
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +7 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.js +13 -10
- package/src/core/geom/3d/sphere/sphere_projected_sphere_radius_sqr.d.ts +1 -1
- package/src/core/geom/3d/sphere/sphere_projected_sphere_radius_sqr.js +2 -2
- package/src/core/geom/3d/sphere/sphere_raycast.d.ts +33 -0
- package/src/core/geom/3d/sphere/sphere_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/sphere_raycast.js +47 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_tet_get_neighbours.d.ts +24 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_tet_get_neighbours.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_tet_get_neighbours.js +39 -0
- package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js +4 -2
- package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +3 -3
- package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js +1 -1
- package/src/core/geom/3d/topology/tm_vertex_compute_normal.d.ts.map +1 -1
- package/src/core/geom/3d/topology/tm_vertex_compute_normal.js +4 -2
- package/src/core/geom/3d/util/make_justified_point_grid.d.ts.map +1 -1
- package/src/core/geom/3d/util/make_justified_point_grid.js +18 -10
- package/src/core/geom/ConicRay.d.ts.map +1 -1
- package/src/core/geom/ConicRay.js +11 -13
- package/src/core/geom/packing/max-rect/removeRedundantBoxes.d.ts.map +1 -1
- package/src/core/geom/packing/max-rect/removeRedundantBoxes.js +19 -4
- package/src/core/geom/vec3/v3_array_copy.d.ts +3 -3
- package/src/core/geom/vec3/v3_array_copy.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_array_copy.js +2 -2
- package/src/core/geom/vec3/v3_cross.d.ts +17 -0
- package/src/core/geom/vec3/v3_cross.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_cross.js +20 -0
- package/src/core/geom/vec3/v3_orthonormal_matrix_from_normal.d.ts.map +1 -0
- package/src/{engine/graphics/sh3/path_tracer/sampling → core/geom/vec3}/v3_orthonormal_matrix_from_normal.js +1 -1
- package/src/core/geom/vec3/v3_subtract.d.ts +16 -0
- package/src/core/geom/vec3/v3_subtract.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_subtract.js +19 -0
- package/src/core/graph/coloring/colorizeGraph.js +2 -2
- package/src/core/graph/csr/CSRGraph.d.ts.map +1 -1
- package/src/core/graph/csr/CSRGraph.js +325 -319
- package/src/core/graph/layout/CircleLayout.d.ts.map +1 -1
- package/src/core/graph/layout/CircleLayout.js +8 -6
- package/src/core/graph/metis/native/refine/compute_kway_params.d.ts.map +1 -1
- package/src/core/graph/metis/native/refine/compute_kway_params.js +139 -138
- package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -1
- package/src/core/graph/mn_graph_coarsen.js +4 -2
- package/src/core/graph/v2/NodeContainer.js +7 -7
- package/src/core/localization/LocalizationEngine.js +1 -1
- package/src/core/math/bell_membership_function.d.ts.map +1 -1
- package/src/core/math/bell_membership_function.js +3 -1
- package/src/core/math/complex/complex_add.d.ts +4 -4
- package/src/core/math/complex/complex_add.d.ts.map +1 -1
- package/src/core/math/complex/complex_add.js +3 -3
- package/src/core/math/complex/complex_div.d.ts +4 -4
- package/src/core/math/complex/complex_div.d.ts.map +1 -1
- package/src/core/math/complex/complex_div.js +3 -3
- package/src/core/math/complex/complex_mul.d.ts +4 -4
- package/src/core/math/complex/complex_mul.d.ts.map +1 -1
- package/src/core/math/complex/complex_mul.js +3 -3
- package/src/core/math/complex/complex_sub.d.ts +4 -4
- package/src/core/math/complex/complex_sub.d.ts.map +1 -1
- package/src/core/math/complex/complex_sub.js +3 -3
- package/src/core/math/idct_1d.d.ts +4 -4
- package/src/core/math/idct_1d.d.ts.map +1 -1
- package/src/core/math/idct_1d.js +3 -3
- package/src/core/math/noise/create_simplex_noise_2d.d.ts.map +1 -1
- package/src/core/math/noise/create_simplex_noise_2d.js +4 -2
- package/src/core/math/noise/sdnoise.d.ts.map +1 -1
- package/src/core/math/noise/sdnoise.js +12 -9
- package/src/core/math/physics/mie/compute_bhmie_optical_properties.d.ts.map +1 -1
- package/src/core/math/physics/mie/compute_bhmie_optical_properties.js +94 -50
- package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts +3 -6
- package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts.map +1 -1
- package/src/core/math/physics/mie/lorenz_mie_coefs.js +180 -157
- package/src/core/math/physics/mie/mie_ab_to_optical_properties.d.ts +3 -4
- package/src/core/math/physics/mie/mie_ab_to_optical_properties.d.ts.map +1 -1
- package/src/core/math/physics/mie/mie_ab_to_optical_properties.js +47 -21
- package/src/core/math/random/randomIntegerBetween.d.ts.map +1 -1
- package/src/core/math/random/randomIntegerBetween.js +4 -1
- package/src/core/math/solveCubic.d.ts.map +1 -1
- package/src/core/math/solveCubic.js +95 -82
- package/src/core/math/spline/computeCatmullRomSplineUniformDistance.d.ts.map +1 -1
- package/src/core/math/spline/computeCatmullRomSplineUniformDistance.js +13 -0
- package/src/core/math/statistics/softmax.js +1 -1
- package/src/core/model/node-graph/visual/NodeGraphVisualData.d.ts +1 -0
- package/src/core/model/node-graph/visual/NodeGraphVisualData.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/NodeGraphVisualData.js +2 -1
- package/src/core/model/node-graph/visual/NodeVisualData.js +1 -1
- package/src/core/model/object/ImmutableObjectPool.d.ts +7 -0
- package/src/core/model/object/ImmutableObjectPool.d.ts.map +1 -1
- package/src/core/model/object/ImmutableObjectPool.js +20 -10
- package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.d.ts.map +1 -1
- package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +39 -2
- package/src/core/model/reactive/model/terminal/ReactiveReference.d.ts.map +1 -1
- package/src/core/model/reactive/model/terminal/ReactiveReference.js +2 -0
- package/src/core/parser/simple/readHexToken.d.ts.map +1 -1
- package/src/core/parser/simple/readHexToken.js +6 -0
- package/src/core/primitives/numbers/number_pretty_print.d.ts.map +1 -1
- package/src/core/primitives/numbers/number_pretty_print.js +4 -1
- package/src/core/primitives/strings/string_jaro_winkler.js +1 -1
- package/src/core/process/CompositeProcess.js +1 -1
- package/src/core/process/action/AsynchronousDelayAction.d.ts.map +1 -1
- package/src/core/process/action/AsynchronousDelayAction.js +3 -0
- package/src/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
- package/src/core/process/executor/ConcurrentExecutor.js +3 -2
- package/src/core/process/task/util/randomCountTask.d.ts.map +1 -1
- package/src/core/process/task/util/randomCountTask.js +3 -1
- package/src/core/process/undo/ActionProcessor.d.ts.map +1 -1
- package/src/core/process/undo/ActionProcessor.js +5 -3
- package/src/core/process/worker/WorkerBuilder.js +3 -3
- package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
- package/src/engine/animation/curve/AnimationCurve.js +4 -2
- package/src/engine/control/first-person/DESIGN.md +1 -1
- package/src/engine/control/first-person/FirstPersonMotionPhase.d.ts +55 -0
- package/src/engine/control/first-person/FirstPersonMotionPhase.d.ts.map +1 -0
- package/src/engine/control/first-person/FirstPersonMotionPhase.js +134 -0
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +23 -2
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerController.js +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +168 -0
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +115 -0
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +71 -0
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +255 -55
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts +82 -43
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts.map +1 -1
- package/src/engine/control/first-person/abilities/LedgeGrab.js +405 -213
- package/src/engine/control/first-person/abilities/Mantle.d.ts +6 -0
- package/src/engine/control/first-person/abilities/Mantle.d.ts.map +1 -1
- package/src/engine/control/first-person/abilities/Mantle.js +104 -45
- package/src/engine/control/first-person/abilities/ScrambleUp.d.ts +61 -0
- package/src/engine/control/first-person/abilities/ScrambleUp.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/ScrambleUp.js +182 -0
- package/src/engine/control/first-person/math/jumpDynamics.d.ts +84 -0
- package/src/engine/control/first-person/math/jumpDynamics.d.ts.map +1 -0
- package/src/engine/control/first-person/math/jumpDynamics.js +108 -0
- package/src/engine/control/first-person/prototype_first_person_controller.js +45 -1
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +1 -1
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +8 -0
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +1 -1
- package/src/engine/graphics/shadows/testShadowMapRendering.js +1 -1
- package/src/engine/physics/CONSTRAINT_SOLVER_BENCH_LOG.md +208 -0
- package/src/engine/physics/CONSTRAINT_SOLVER_IMPROVEMENTS_PLAN.md +364 -0
- package/src/engine/physics/PLAN.md +6 -5
- package/src/engine/physics/constraint/solve_constraints.d.ts +4 -1
- package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
- package/src/engine/physics/constraint/solve_constraints.js +147 -33
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +1750 -1747
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +3 -3
- package/src/engine/physics/gjk/gjk_epa_penetration.d.ts +12 -8
- package/src/engine/physics/gjk/gjk_epa_penetration.d.ts.map +1 -1
- package/src/engine/physics/gjk/gjk_epa_penetration.js +447 -158
- package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/convex_convex_manifold.js +22 -25
- package/src/engine/physics/narrowphase/convex_decomposition.d.ts +32 -13
- package/src/engine/physics/narrowphase/convex_decomposition.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/convex_decomposition.js +61 -65
- package/src/engine/physics/narrowphase/mesh_convex_hull.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/mesh_convex_hull.js +13 -8
- package/src/engine/physics/narrowphase/refine_ray_concave.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/refine_ray_concave.js +5 -3
- package/src/engine/physics/narrowphase/refine_ray_hit.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/refine_ray_hit.js +81 -78
- package/src/engine/sound/SoundEngine.d.ts.map +1 -1
- package/src/engine/sound/SoundEngine.js +28 -0
- package/src/engine/sound/dB2Volume.d.ts +1 -1
- package/src/engine/sound/dB2Volume.d.ts.map +1 -1
- package/src/engine/sound/dB2Volume.js +1 -1
- package/src/engine/sound/ecs/SoundController.d.ts +4 -0
- package/src/engine/sound/ecs/SoundController.d.ts.map +1 -1
- package/src/engine/sound/ecs/SoundController.js +4 -0
- package/src/engine/sound/ecs/SoundControllerSystem.d.ts +5 -0
- package/src/engine/sound/ecs/SoundControllerSystem.d.ts.map +1 -1
- package/src/engine/sound/ecs/SoundControllerSystem.js +5 -0
- package/src/engine/sound/ecs/audio/AudioEmitter.d.ts +69 -0
- package/src/engine/sound/ecs/audio/AudioEmitter.d.ts.map +1 -0
- package/src/engine/sound/ecs/audio/AudioEmitter.js +83 -0
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts +97 -0
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts.map +1 -0
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.js +238 -0
- package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts +90 -0
- package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -0
- package/src/engine/sound/ecs/audio/LiveEmitterSet.js +324 -0
- package/src/engine/sound/ecs/audio/SpatialAudioIndex.d.ts +59 -0
- package/src/engine/sound/ecs/audio/SpatialAudioIndex.d.ts.map +1 -0
- package/src/engine/sound/ecs/audio/SpatialAudioIndex.js +140 -0
- package/src/engine/sound/ecs/emitter/SoundEmitter.d.ts +16 -65
- package/src/engine/sound/ecs/emitter/SoundEmitter.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundEmitter.js +19 -224
- package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.d.ts +26 -29
- package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.js +168 -135
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts +36 -59
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +154 -390
- package/src/engine/sound/ecs/emitter/SoundTrack.d.ts +20 -23
- package/src/engine/sound/ecs/emitter/SoundTrack.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundTrack.js +34 -152
- package/src/engine/sound/sopra/IMPLEMENTATION_PLAN.md +993 -0
- package/src/engine/sound/sopra/README.md +643 -7
- package/src/engine/sound/sopra/SopraEngine.d.ts +229 -0
- package/src/engine/sound/sopra/SopraEngine.d.ts.map +1 -0
- package/src/engine/sound/sopra/SopraEngine.js +423 -0
- package/src/engine/sound/sopra/asset/AssetManagerBufferProvider.d.ts +26 -0
- package/src/engine/sound/sopra/asset/AssetManagerBufferProvider.d.ts.map +1 -0
- package/src/engine/sound/sopra/asset/AssetManagerBufferProvider.js +71 -0
- package/src/engine/sound/sopra/asset/BufferProvider.d.ts +24 -0
- package/src/engine/sound/sopra/asset/BufferProvider.d.ts.map +1 -0
- package/src/engine/sound/sopra/asset/BufferProvider.js +29 -0
- package/src/engine/sound/sopra/asset/StubBufferProvider.d.ts +31 -0
- package/src/engine/sound/sopra/asset/StubBufferProvider.d.ts.map +1 -0
- package/src/engine/sound/sopra/asset/StubBufferProvider.js +58 -0
- package/src/engine/sound/sopra/definition/BusDefinition.d.ts +83 -0
- package/src/engine/sound/sopra/definition/BusDefinition.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/BusDefinition.js +142 -0
- package/src/engine/sound/sopra/definition/BusDefinitionSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/BusDefinitionSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/BusDefinitionSerializationAdapter.js +54 -0
- package/src/engine/sound/sopra/definition/DuckingRule.d.ts +71 -0
- package/src/engine/sound/sopra/definition/DuckingRule.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/DuckingRule.js +106 -0
- package/src/engine/sound/sopra/definition/DuckingRuleSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/DuckingRuleSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/DuckingRuleSerializationAdapter.js +31 -0
- package/src/engine/sound/sopra/definition/EventDescription.d.ts +132 -0
- package/src/engine/sound/sopra/definition/EventDescription.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/EventDescription.js +259 -0
- package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.js +71 -0
- package/src/engine/sound/sopra/definition/MixerSnapshot.d.ts +51 -0
- package/src/engine/sound/sopra/definition/MixerSnapshot.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/MixerSnapshot.js +83 -0
- package/src/engine/sound/sopra/definition/MixerSnapshotSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/MixerSnapshotSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/MixerSnapshotSerializationAdapter.js +39 -0
- package/src/engine/sound/sopra/definition/ParameterDefinition.d.ts +72 -0
- package/src/engine/sound/sopra/definition/ParameterDefinition.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/ParameterDefinition.js +117 -0
- package/src/engine/sound/sopra/definition/ParameterDefinitionSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/ParameterDefinitionSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/ParameterDefinitionSerializationAdapter.js +31 -0
- package/src/engine/sound/sopra/definition/SopraPanningModel.d.ts +14 -0
- package/src/engine/sound/sopra/definition/SopraPanningModel.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/SopraPanningModel.js +20 -0
- package/src/engine/sound/sopra/definition/VoiceStealMode.d.ts +10 -0
- package/src/engine/sound/sopra/definition/VoiceStealMode.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/VoiceStealMode.js +18 -0
- package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.d.ts +93 -0
- package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.js +109 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts +80 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.js +181 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClipSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClipSerializationAdapter.js +74 -0
- package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.d.ts +34 -0
- package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.js +100 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.d.ts +101 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.js +230 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClipSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClipSerializationAdapter.js +54 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts +103 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClip.js +191 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClipSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClipSerializationAdapter.js +39 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.d.ts +40 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.js +91 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClipSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClipSerializationAdapter.js +42 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.d.ts +44 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.js +77 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClipSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClipSerializationAdapter.js +27 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts +65 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.js +131 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClipSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClipSerializationAdapter.js +41 -0
- package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.d.ts +24 -0
- package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.js +24 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffect.d.ts +70 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffect.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffect.js +120 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffectSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffectSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffectSerializationAdapter.js +31 -0
- package/src/engine/sound/sopra/definition/effect/EqEffect.d.ts +74 -0
- package/src/engine/sound/sopra/definition/effect/EqEffect.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/EqEffect.js +128 -0
- package/src/engine/sound/sopra/definition/effect/EqEffectSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/effect/EqEffectSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/EqEffectSerializationAdapter.js +29 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffect.d.ts +49 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffect.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffect.js +101 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffectSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffectSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffectSerializationAdapter.js +25 -0
- package/src/engine/sound/sopra/legacy/soundEmitterToEventDescription.d.ts +31 -0
- package/src/engine/sound/sopra/legacy/soundEmitterToEventDescription.d.ts.map +1 -0
- package/src/engine/sound/sopra/legacy/soundEmitterToEventDescription.js +106 -0
- package/src/engine/sound/sopra/runtime/BusGraph.d.ts +79 -0
- package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/BusGraph.js +227 -0
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts +144 -0
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/EventInstance.js +579 -0
- package/src/engine/sound/sopra/runtime/ParameterStore.d.ts +42 -0
- package/src/engine/sound/sopra/runtime/ParameterStore.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/ParameterStore.js +98 -0
- package/src/engine/sound/sopra/runtime/SopraPlaybackContext.d.ts +42 -0
- package/src/engine/sound/sopra/runtime/SopraPlaybackContext.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/SopraPlaybackContext.js +68 -0
- package/src/engine/sound/sopra/runtime/Voice.d.ts +67 -0
- package/src/engine/sound/sopra/runtime/Voice.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/Voice.js +145 -0
- package/src/engine/sound/sopra/runtime/VoiceManager.d.ts +38 -0
- package/src/engine/sound/sopra/runtime/VoiceManager.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/VoiceManager.js +136 -0
- package/src/engine/sound/sopra/runtime/VoicePool.d.ts +12 -0
- package/src/engine/sound/sopra/runtime/VoicePool.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/VoicePool.js +17 -0
- package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.d.ts +11 -0
- package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.d.ts.map +1 -0
- package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.js +42 -0
- package/src/engine/sound/sopra/serialization/sopraJSON.d.ts +33 -0
- package/src/engine/sound/sopra/serialization/sopraJSON.d.ts.map +1 -0
- package/src/engine/sound/sopra/serialization/sopraJSON.js +99 -0
- package/src/engine/sound/sopra/serialization/sopraSerializationHarness.d.ts +27 -0
- package/src/engine/sound/sopra/serialization/sopraSerializationHarness.d.ts.map +1 -0
- package/src/engine/sound/sopra/serialization/sopraSerializationHarness.js +49 -0
- package/src/engine/sound/sopra/util/MockAudioContext.d.ts +74 -0
- package/src/engine/sound/sopra/util/MockAudioContext.d.ts.map +1 -0
- package/src/engine/sound/sopra/util/MockAudioContext.js +215 -0
- package/src/engine/sound/sopra/util/buildAttenuationCurve.d.ts +15 -0
- package/src/engine/sound/sopra/util/buildAttenuationCurve.d.ts.map +1 -0
- package/src/engine/sound/sopra/util/buildAttenuationCurve.js +40 -0
- package/src/engine/sound/sopra/util/fadeOutAndStop.d.ts +34 -0
- package/src/engine/sound/sopra/util/fadeOutAndStop.d.ts.map +1 -0
- package/src/engine/sound/sopra/util/fadeOutAndStop.js +60 -0
- package/src/engine/sound/volume2dB.d.ts +1 -1
- package/src/engine/sound/volume2dB.d.ts.map +1 -1
- package/src/engine/sound/volume2dB.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.d.ts.map +0 -1
- package/src/engine/physics/narrowphase/ray_shapes.d.ts +0 -66
- package/src/engine/physics/narrowphase/ray_shapes.d.ts.map +0 -1
- package/src/engine/physics/narrowphase/ray_shapes.js +0 -187
- package/src/engine/sound/ecs/emitter/SoundEmitterChannel.d.ts +0 -23
- package/src/engine/sound/ecs/emitter/SoundEmitterChannel.d.ts.map +0 -1
- package/src/engine/sound/ecs/emitter/SoundEmitterChannel.js +0 -32
- package/src/engine/sound/ecs/emitter/SoundTrackNodes.d.ts +0 -18
- package/src/engine/sound/ecs/emitter/SoundTrackNodes.d.ts.map +0 -1
- package/src/engine/sound/ecs/emitter/SoundTrackNodes.js +0 -18
- package/src/engine/sound/sopra/AbstractAudioClip.d.ts +0 -26
- package/src/engine/sound/sopra/AbstractAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/AbstractAudioClip.js +0 -29
- package/src/engine/sound/sopra/ContainerAudioClip.d.ts +0 -12
- package/src/engine/sound/sopra/ContainerAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/ContainerAudioClip.js +0 -13
- package/src/engine/sound/sopra/RandomContainerAudioClip.d.ts +0 -12
- package/src/engine/sound/sopra/RandomContainerAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/RandomContainerAudioClip.js +0 -15
- package/src/engine/sound/sopra/SequenceContainerAudioClip.d.ts +0 -7
- package/src/engine/sound/sopra/SequenceContainerAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/SequenceContainerAudioClip.js +0 -8
- package/src/engine/sound/sopra/SilenceAudioClip.d.ts +0 -13
- package/src/engine/sound/sopra/SilenceAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/SilenceAudioClip.js +0 -15
- /package/src/{engine/graphics/sh3/path_tracer/sampling → core/geom/vec3}/v3_orthonormal_matrix_from_normal.d.ts +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import Signal from "../../../../core/events/signal/Signal.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Holds live values for named parameters (RTPC). P0 is the minimal store (define/get/set + a change
|
|
5
|
+
* signal); automation curves binding parameter values to gains/pitch/sends are layered on in P1.
|
|
6
|
+
*/
|
|
7
|
+
export class ParameterStore {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {Map<string, number>}
|
|
11
|
+
*/
|
|
12
|
+
#values = new Map();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* name -> apply callbacks, invoked with the new value whenever the parameter changes.
|
|
16
|
+
* @type {Map<string, function(number)[]>}
|
|
17
|
+
*/
|
|
18
|
+
#bindings = new Map();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Fires (name, value) whenever a parameter changes.
|
|
22
|
+
* @type {Signal<string, number>}
|
|
23
|
+
*/
|
|
24
|
+
onChanged = new Signal();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Register a parameter with its default value (no-op if already defined).
|
|
28
|
+
* @param {string} name
|
|
29
|
+
* @param {number} defaultValue
|
|
30
|
+
*/
|
|
31
|
+
define(name, defaultValue) {
|
|
32
|
+
if (!this.#values.has(name)) {
|
|
33
|
+
this.#values.set(name, defaultValue);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {string} name
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
has(name) {
|
|
42
|
+
return this.#values.has(name);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {string} name
|
|
47
|
+
* @returns {number|undefined}
|
|
48
|
+
*/
|
|
49
|
+
get(name) {
|
|
50
|
+
return this.#values.get(name);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {string} name
|
|
55
|
+
* @param {number} value
|
|
56
|
+
*/
|
|
57
|
+
set(name, value) {
|
|
58
|
+
const previous = this.#values.get(name);
|
|
59
|
+
|
|
60
|
+
if (previous === value) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.#values.set(name, value);
|
|
65
|
+
|
|
66
|
+
const bindings = this.#bindings.get(name);
|
|
67
|
+
if (bindings !== undefined) {
|
|
68
|
+
for (let i = 0; i < bindings.length; i++) {
|
|
69
|
+
bindings[i](value);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (this.onChanged.hasHandlers()) {
|
|
74
|
+
this.onChanged.send2(name, value);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Bind a callback to a parameter; it runs on every change (and once now if the parameter already
|
|
80
|
+
* has a value). Used to drive bus gains / voice params from an automation curve.
|
|
81
|
+
* @param {string} name
|
|
82
|
+
* @param {function(number)} applyFn
|
|
83
|
+
*/
|
|
84
|
+
bind(name, applyFn) {
|
|
85
|
+
let list = this.#bindings.get(name);
|
|
86
|
+
|
|
87
|
+
if (list === undefined) {
|
|
88
|
+
list = [];
|
|
89
|
+
this.#bindings.set(name, list);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
list.push(applyFn);
|
|
93
|
+
|
|
94
|
+
if (this.#values.has(name)) {
|
|
95
|
+
applyFn(this.#values.get(name));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-source playback state for deterministic clip resolution: a seeded RNG plus an opaque,
|
|
3
|
+
* per-source scratch store that stateful clips hang their runtime state on (e.g.
|
|
4
|
+
* {@link RandomContainerAudioClip}'s "avoid repeating last N" history).
|
|
5
|
+
*
|
|
6
|
+
* Determinism (D5): seed from a replicated source (entity id + fixedStepTick) so random selection
|
|
7
|
+
* matches across networked clients. Scratch state persists across re-triggers of the same source
|
|
8
|
+
* (e.g. footsteps), so reuse one context per emitter rather than per trigger.
|
|
9
|
+
*
|
|
10
|
+
* The context deliberately knows nothing about any specific clip type — each clip owns its own
|
|
11
|
+
* selection algorithm and merely borrows a per-source state slot here, so the shared, immutable clip
|
|
12
|
+
* *definitions* never hold mutable runtime state.
|
|
13
|
+
*/
|
|
14
|
+
export class SopraPlaybackContext {
|
|
15
|
+
/**
|
|
16
|
+
* @param {number} [seed]
|
|
17
|
+
*/
|
|
18
|
+
constructor(seed?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Seeded RNG — a function returning [0, 1) with `setCurrentSeed`/`getCurrentSeed`.
|
|
21
|
+
* @type {function():number}
|
|
22
|
+
*/
|
|
23
|
+
random: () => number;
|
|
24
|
+
/**
|
|
25
|
+
* Reseed the RNG (e.g. per trigger, from entity id + tick).
|
|
26
|
+
* @param {number} seed
|
|
27
|
+
*/
|
|
28
|
+
setSeed(seed: number): void;
|
|
29
|
+
/**
|
|
30
|
+
* Per-source scratch state for `owner`, created on first access via `createDefault`. Subsequent
|
|
31
|
+
* calls with the same `owner` return the same (mutable) value, so an owner can accumulate state
|
|
32
|
+
* across triggers. State is private to this context — another context built from the same owner
|
|
33
|
+
* starts fresh.
|
|
34
|
+
* @template T
|
|
35
|
+
* @param {object} owner
|
|
36
|
+
* @param {function():T} createDefault
|
|
37
|
+
* @returns {T}
|
|
38
|
+
*/
|
|
39
|
+
getState<T>(owner: object, createDefault: () => T): T;
|
|
40
|
+
#private;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=SopraPlaybackContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SopraPlaybackContext.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra/runtime/SopraPlaybackContext.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH;IAgBI;;OAEG;IACH,mBAFW,MAAM,EAIhB;IAnBD;;;OAGG;IACH,cAFqB,MAAM,CAEpB;IAiBP;;;OAGG;IACH,cAFW,MAAM,QAIhB;IAED;;;;;;;;;OASG;IACH,mBAJW,MAAM,6BAchB;;CACJ"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Per-source playback state for deterministic clip resolution: a seeded RNG plus an opaque,
|
|
5
|
+
* per-source scratch store that stateful clips hang their runtime state on (e.g.
|
|
6
|
+
* {@link RandomContainerAudioClip}'s "avoid repeating last N" history).
|
|
7
|
+
*
|
|
8
|
+
* Determinism (D5): seed from a replicated source (entity id + fixedStepTick) so random selection
|
|
9
|
+
* matches across networked clients. Scratch state persists across re-triggers of the same source
|
|
10
|
+
* (e.g. footsteps), so reuse one context per emitter rather than per trigger.
|
|
11
|
+
*
|
|
12
|
+
* The context deliberately knows nothing about any specific clip type — each clip owns its own
|
|
13
|
+
* selection algorithm and merely borrows a per-source state slot here, so the shared, immutable clip
|
|
14
|
+
* *definitions* never hold mutable runtime state.
|
|
15
|
+
*/
|
|
16
|
+
export class SopraPlaybackContext {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Seeded RNG — a function returning [0, 1) with `setCurrentSeed`/`getCurrentSeed`.
|
|
20
|
+
* @type {function():number}
|
|
21
|
+
*/
|
|
22
|
+
random;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* owner -> that owner's per-source scratch state, created lazily via {@link getState}. Keyed by
|
|
26
|
+
* the owning object (typically a clip definition), so distinct owners — and distinct contexts —
|
|
27
|
+
* keep independent state.
|
|
28
|
+
* @type {Map<object, *>}
|
|
29
|
+
*/
|
|
30
|
+
#state = new Map();
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} [seed]
|
|
34
|
+
*/
|
|
35
|
+
constructor(seed = 0) {
|
|
36
|
+
this.random = seededRandom(seed);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Reseed the RNG (e.g. per trigger, from entity id + tick).
|
|
41
|
+
* @param {number} seed
|
|
42
|
+
*/
|
|
43
|
+
setSeed(seed) {
|
|
44
|
+
this.random.setCurrentSeed(seed);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Per-source scratch state for `owner`, created on first access via `createDefault`. Subsequent
|
|
49
|
+
* calls with the same `owner` return the same (mutable) value, so an owner can accumulate state
|
|
50
|
+
* across triggers. State is private to this context — another context built from the same owner
|
|
51
|
+
* starts fresh.
|
|
52
|
+
* @template T
|
|
53
|
+
* @param {object} owner
|
|
54
|
+
* @param {function():T} createDefault
|
|
55
|
+
* @returns {T}
|
|
56
|
+
*/
|
|
57
|
+
getState(owner, createDefault) {
|
|
58
|
+
const existing = this.#state.get(owner);
|
|
59
|
+
|
|
60
|
+
if (existing !== undefined) {
|
|
61
|
+
return existing;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const created = createDefault();
|
|
65
|
+
this.#state.set(owner, created);
|
|
66
|
+
return created;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single playing sound — one throwaway {@link AudioBufferSourceNode} plus a pooled trim
|
|
3
|
+
* {@link GainNode}. The source is the only unavoidable per-play allocation (it is single-use); the
|
|
4
|
+
* trim gain persists across pool reuse.
|
|
5
|
+
*
|
|
6
|
+
* Voices are transient runtime objects — never serialized.
|
|
7
|
+
*/
|
|
8
|
+
export class Voice {
|
|
9
|
+
/**
|
|
10
|
+
* Per-voice gain (clip + event gain, pre-bus). Reused across plays; created lazily because it
|
|
11
|
+
* needs an AudioContext.
|
|
12
|
+
* @type {GainNode|null}
|
|
13
|
+
*/
|
|
14
|
+
trimGain: GainNode | null;
|
|
15
|
+
/**
|
|
16
|
+
* @type {AudioBufferSourceNode|null}
|
|
17
|
+
*/
|
|
18
|
+
source: AudioBufferSourceNode | null;
|
|
19
|
+
/**
|
|
20
|
+
* Context time at which this voice was (scheduled to be) started.
|
|
21
|
+
* @type {number}
|
|
22
|
+
*/
|
|
23
|
+
startedAt: number;
|
|
24
|
+
/**
|
|
25
|
+
* Resolved linear gain of this voice (used as a stealing-priority hint by the VoiceManager).
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
28
|
+
gainLinear: number;
|
|
29
|
+
/**
|
|
30
|
+
* Invoked with `this` when the source ends naturally (non-looping). A plain function slot (not a
|
|
31
|
+
* Signal) to stay pool-friendly; defaults to {@link noop}. Set by the owning {@link EventInstance}.
|
|
32
|
+
* @type {function(Voice)}
|
|
33
|
+
*/
|
|
34
|
+
onEnded: (arg0: Voice) => any;
|
|
35
|
+
/**
|
|
36
|
+
* @returns {boolean}
|
|
37
|
+
*/
|
|
38
|
+
get active(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Build (lazily) and start the source, routed into `busInput` via the trim gain.
|
|
41
|
+
*
|
|
42
|
+
* @param {BaseAudioContext} ctx
|
|
43
|
+
* @param {AudioNode} busInput node this voice routes into (a bus chain head)
|
|
44
|
+
* @param {AudioBuffer} buffer
|
|
45
|
+
* @param {{gainLinear:number, detuneCents:number, loop:boolean, loopStart:number, loopEnd:number, when:number, offset:number}} params
|
|
46
|
+
*/
|
|
47
|
+
play(ctx: BaseAudioContext, busInput: AudioNode, buffer: AudioBuffer, params: {
|
|
48
|
+
gainLinear: number;
|
|
49
|
+
detuneCents: number;
|
|
50
|
+
loop: boolean;
|
|
51
|
+
loopStart: number;
|
|
52
|
+
loopEnd: number;
|
|
53
|
+
when: number;
|
|
54
|
+
offset: number;
|
|
55
|
+
}): void;
|
|
56
|
+
/**
|
|
57
|
+
* Stop and disconnect the source. Safe to call once per started voice.
|
|
58
|
+
* @param {number} [when=0] context time to stop at
|
|
59
|
+
*/
|
|
60
|
+
stop(when?: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* Return the voice to a clean state for pooled reuse. Keeps the trim gain (disconnected).
|
|
63
|
+
*/
|
|
64
|
+
reset(): void;
|
|
65
|
+
#private;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=Voice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Voice.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra/runtime/Voice.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH;IAEI;;;;OAIG;IACH,UAFU,QAAQ,GAAC,IAAI,CAEP;IAEhB;;OAEG;IACH,QAFU,qBAAqB,GAAC,IAAI,CAEtB;IAEd;;;OAGG;IACH,WAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,YAFU,MAAM,CAED;IAEf;;;;OAIG;IACH,gBAFmB,KAAK,SAET;IAYf;;OAEG;IACH,sBAEC;IAED;;;;;;;OAOG;IACH,UALW,gBAAgB,YAChB,SAAS,UACT,WAAW,UACX;QAAC,UAAU,EAAC,MAAM,CAAC;QAAC,WAAW,EAAC,MAAM,CAAC;QAAC,IAAI,EAAC,OAAO,CAAC;QAAC,SAAS,EAAC,MAAM,CAAC;QAAC,OAAO,EAAC,MAAM,CAAC;QAAC,IAAI,EAAC,MAAM,CAAC;QAAC,MAAM,EAAC,MAAM,CAAA;KAAC,QAiC7H;IAaD;;;OAGG;IACH,YAFW,MAAM,QAchB;IAED;;OAEG;IACH,cAWC;;CACJ"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { noop } from "../../../../core/function/noop.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A single playing sound — one throwaway {@link AudioBufferSourceNode} plus a pooled trim
|
|
5
|
+
* {@link GainNode}. The source is the only unavoidable per-play allocation (it is single-use); the
|
|
6
|
+
* trim gain persists across pool reuse.
|
|
7
|
+
*
|
|
8
|
+
* Voices are transient runtime objects — never serialized.
|
|
9
|
+
*/
|
|
10
|
+
export class Voice {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Per-voice gain (clip + event gain, pre-bus). Reused across plays; created lazily because it
|
|
14
|
+
* needs an AudioContext.
|
|
15
|
+
* @type {GainNode|null}
|
|
16
|
+
*/
|
|
17
|
+
trimGain = null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @type {AudioBufferSourceNode|null}
|
|
21
|
+
*/
|
|
22
|
+
source = null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Context time at which this voice was (scheduled to be) started.
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
28
|
+
startedAt = 0;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Resolved linear gain of this voice (used as a stealing-priority hint by the VoiceManager).
|
|
32
|
+
* @type {number}
|
|
33
|
+
*/
|
|
34
|
+
gainLinear = 1;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Invoked with `this` when the source ends naturally (non-looping). A plain function slot (not a
|
|
38
|
+
* Signal) to stay pool-friendly; defaults to {@link noop}. Set by the owning {@link EventInstance}.
|
|
39
|
+
* @type {function(Voice)}
|
|
40
|
+
*/
|
|
41
|
+
onEnded = noop;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
*/
|
|
46
|
+
#looping = false;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @type {boolean}
|
|
50
|
+
*/
|
|
51
|
+
#active = false;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @returns {boolean}
|
|
55
|
+
*/
|
|
56
|
+
get active() {
|
|
57
|
+
return this.#active;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Build (lazily) and start the source, routed into `busInput` via the trim gain.
|
|
62
|
+
*
|
|
63
|
+
* @param {BaseAudioContext} ctx
|
|
64
|
+
* @param {AudioNode} busInput node this voice routes into (a bus chain head)
|
|
65
|
+
* @param {AudioBuffer} buffer
|
|
66
|
+
* @param {{gainLinear:number, detuneCents:number, loop:boolean, loopStart:number, loopEnd:number, when:number, offset:number}} params
|
|
67
|
+
*/
|
|
68
|
+
play(ctx, busInput, buffer, params) {
|
|
69
|
+
// recreate the trim gain only when missing or bound to a different context (the latter only
|
|
70
|
+
// happens across pooled reuse between AudioContexts, e.g. in tests)
|
|
71
|
+
if (this.trimGain === null || this.trimGain.context !== ctx) {
|
|
72
|
+
this.trimGain = ctx.createGain();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.gainLinear = params.gainLinear;
|
|
76
|
+
this.trimGain.gain.setValueAtTime(params.gainLinear, 0);
|
|
77
|
+
this.trimGain.connect(busInput);
|
|
78
|
+
|
|
79
|
+
const source = ctx.createBufferSource();
|
|
80
|
+
|
|
81
|
+
source.buffer = buffer;
|
|
82
|
+
source.loop = params.loop;
|
|
83
|
+
source.loopStart = params.loopStart;
|
|
84
|
+
source.loopEnd = params.loopEnd;
|
|
85
|
+
source.detune.value = params.detuneCents;
|
|
86
|
+
|
|
87
|
+
source.connect(this.trimGain);
|
|
88
|
+
|
|
89
|
+
source.onended = () => {
|
|
90
|
+
this.#handleSourceEnded();
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
source.start(params.when, params.offset);
|
|
94
|
+
|
|
95
|
+
this.source = source;
|
|
96
|
+
this.startedAt = params.when;
|
|
97
|
+
this.#looping = params.loop;
|
|
98
|
+
this.#active = true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#handleSourceEnded() {
|
|
102
|
+
if (this.#looping) {
|
|
103
|
+
// looping sources only fire 'ended' on explicit stop, which we drive ourselves
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.#active = false;
|
|
108
|
+
|
|
109
|
+
this.onEnded(this);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Stop and disconnect the source. Safe to call once per started voice.
|
|
114
|
+
* @param {number} [when=0] context time to stop at
|
|
115
|
+
*/
|
|
116
|
+
stop(when = 0) {
|
|
117
|
+
const source = this.source;
|
|
118
|
+
|
|
119
|
+
if (source !== null) {
|
|
120
|
+
source.onended = null;
|
|
121
|
+
source.stop(when);
|
|
122
|
+
source.disconnect();
|
|
123
|
+
|
|
124
|
+
this.source = null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.#active = false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Return the voice to a clean state for pooled reuse. Keeps the trim gain (disconnected).
|
|
132
|
+
*/
|
|
133
|
+
reset() {
|
|
134
|
+
this.source = null;
|
|
135
|
+
this.onEnded = noop;
|
|
136
|
+
this.startedAt = 0;
|
|
137
|
+
this.gainLinear = 1;
|
|
138
|
+
this.#active = false;
|
|
139
|
+
this.#looping = false;
|
|
140
|
+
|
|
141
|
+
if (this.trimGain !== null) {
|
|
142
|
+
this.trimGain.disconnect();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enforces per-event instance limits and voice stealing — the layer that keeps mass entity counts
|
|
3
|
+
* viable (the engine's stated target). Groups active {@link EventInstance}s by their
|
|
4
|
+
* {@link EventDescription}; on a new play it makes room within `EventDescription.maxInstances` by
|
|
5
|
+
* stopping victims per the event's {@link VoiceStealMode}.
|
|
6
|
+
*
|
|
7
|
+
* Grouping is keyed by the description's CONTENT (its `hash()`/`equals()`), not by the `id` string —
|
|
8
|
+
* so two descriptions are "the same event" iff they are equal, and the id need not be unique. (Since
|
|
9
|
+
* `maxInstances` is part of equality, every instance in a bucket shares the same cap.)
|
|
10
|
+
*
|
|
11
|
+
* Defaults are a no-op: maxInstances defaults high, so the limit (and therefore stealing) only kicks
|
|
12
|
+
* in when content opts into a low limit.
|
|
13
|
+
*/
|
|
14
|
+
export class VoiceManager {
|
|
15
|
+
/**
|
|
16
|
+
* @param {EventInstance} instance
|
|
17
|
+
*/
|
|
18
|
+
register(instance: EventInstance): void;
|
|
19
|
+
/**
|
|
20
|
+
* @param {EventInstance} instance
|
|
21
|
+
*/
|
|
22
|
+
unregister(instance: EventInstance): void;
|
|
23
|
+
/**
|
|
24
|
+
* @param {EventDescription} description
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
countForEvent(description: EventDescription): number;
|
|
28
|
+
/**
|
|
29
|
+
* Ensure there is room to start one more instance of `description`, stealing existing instances
|
|
30
|
+
* if necessary.
|
|
31
|
+
* @param {EventDescription} description
|
|
32
|
+
* @returns {boolean} true if a new instance may start (possibly after stealing); false if the
|
|
33
|
+
* limit is reached and the steal mode is None (the new play should be dropped)
|
|
34
|
+
*/
|
|
35
|
+
makeRoom(description: EventDescription): boolean;
|
|
36
|
+
#private;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=VoiceManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoiceManager.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra/runtime/VoiceManager.js"],"names":[],"mappings":"AA2CA;;;;;;;;;;;;GAYG;AACH;IAQI;;OAEG;IACH,wCAIC;IAED;;OAEG;IACH,0CAaC;IAED;;;OAGG;IACH,8CAFa,MAAM,CAMlB;IAED;;;;;;OAMG;IACH,yCAHa,OAAO,CA4BnB;;CAEJ"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { HashMap } from "../../../../core/collection/map/HashMap.js";
|
|
2
|
+
import { VoiceStealMode } from "../definition/VoiceStealMode.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {EventInstance} a
|
|
7
|
+
* @param {EventInstance} b
|
|
8
|
+
* @returns {number}
|
|
9
|
+
*/
|
|
10
|
+
function by_age(a, b) {
|
|
11
|
+
return a.startedAt - b.startedAt;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {EventInstance} a
|
|
17
|
+
* @param {EventInstance} b
|
|
18
|
+
* @returns {number}
|
|
19
|
+
*/
|
|
20
|
+
function by_gain(a, b) {
|
|
21
|
+
return a.currentGain - b.currentGain;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {Set<EventInstance>} set
|
|
26
|
+
* @param {VoiceStealMode|number} mode
|
|
27
|
+
* @param {number} n
|
|
28
|
+
* @returns {EventInstance[]}
|
|
29
|
+
*/
|
|
30
|
+
function pickVictims(set, mode, n) {
|
|
31
|
+
const instances = [...set];
|
|
32
|
+
|
|
33
|
+
if (mode === VoiceStealMode.Quietest) {
|
|
34
|
+
// lowest current (post-attenuation) gain first
|
|
35
|
+
instances.sort(by_gain);
|
|
36
|
+
} else {
|
|
37
|
+
// VoiceStealMode.Oldest (default): earliest-started first
|
|
38
|
+
instances.sort(by_age);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return instances.slice(0, n);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Enforces per-event instance limits and voice stealing — the layer that keeps mass entity counts
|
|
46
|
+
* viable (the engine's stated target). Groups active {@link EventInstance}s by their
|
|
47
|
+
* {@link EventDescription}; on a new play it makes room within `EventDescription.maxInstances` by
|
|
48
|
+
* stopping victims per the event's {@link VoiceStealMode}.
|
|
49
|
+
*
|
|
50
|
+
* Grouping is keyed by the description's CONTENT (its `hash()`/`equals()`), not by the `id` string —
|
|
51
|
+
* so two descriptions are "the same event" iff they are equal, and the id need not be unique. (Since
|
|
52
|
+
* `maxInstances` is part of equality, every instance in a bucket shares the same cap.)
|
|
53
|
+
*
|
|
54
|
+
* Defaults are a no-op: maxInstances defaults high, so the limit (and therefore stealing) only kicks
|
|
55
|
+
* in when content opts into a low limit.
|
|
56
|
+
*/
|
|
57
|
+
export class VoiceManager {
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* event description -> its live instances, keyed by content (hash + equals).
|
|
61
|
+
* @type {HashMap<EventDescription, Set<EventInstance>>}
|
|
62
|
+
*/
|
|
63
|
+
#byEvent = new HashMap();
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param {EventInstance} instance
|
|
67
|
+
*/
|
|
68
|
+
register(instance) {
|
|
69
|
+
const set = this.#byEvent.getOrCompute(instance.description, () => new Set());
|
|
70
|
+
|
|
71
|
+
set.add(instance);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {EventInstance} instance
|
|
76
|
+
*/
|
|
77
|
+
unregister(instance) {
|
|
78
|
+
const description = instance.description;
|
|
79
|
+
const set = this.#byEvent.get(description);
|
|
80
|
+
|
|
81
|
+
if (set === undefined) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
set.delete(instance);
|
|
86
|
+
|
|
87
|
+
if (set.size === 0) {
|
|
88
|
+
this.#byEvent.delete(description);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {EventDescription} description
|
|
94
|
+
* @returns {number}
|
|
95
|
+
*/
|
|
96
|
+
countForEvent(description) {
|
|
97
|
+
const set = this.#byEvent.get(description);
|
|
98
|
+
|
|
99
|
+
return set === undefined ? 0 : set.size;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Ensure there is room to start one more instance of `description`, stealing existing instances
|
|
104
|
+
* if necessary.
|
|
105
|
+
* @param {EventDescription} description
|
|
106
|
+
* @returns {boolean} true if a new instance may start (possibly after stealing); false if the
|
|
107
|
+
* limit is reached and the steal mode is None (the new play should be dropped)
|
|
108
|
+
*/
|
|
109
|
+
makeRoom(description) {
|
|
110
|
+
const max = description.maxInstances;
|
|
111
|
+
const set = this.#byEvent.get(description);
|
|
112
|
+
const count = set === undefined ? 0 : set.size;
|
|
113
|
+
|
|
114
|
+
if (count < max) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (description.stealMode === VoiceStealMode.None) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// free enough slots so that, after adding one, we are within the limit. NB: maxInstances is part
|
|
123
|
+
// of EventDescription equality, so every instance in a bucket shares the same cap — count is
|
|
124
|
+
// therefore always exactly `max` here and this steals exactly one. The formula stays general
|
|
125
|
+
// (don't "simplify" it to a single victim: it's the correct expression of the intent).
|
|
126
|
+
const victims = pickVictims(set, description.stealMode, count - max + 1);
|
|
127
|
+
|
|
128
|
+
for (let i = 0; i < victims.length; i++) {
|
|
129
|
+
// stop() unregisters the victim via the engine's instance-finished hook
|
|
130
|
+
victims[i].stop();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-wide shared pool of reusable {@link Voice} objects, built on the generic
|
|
3
|
+
* {@link ObjectPoolFactory}. There is a single AudioContext in production, so one shared pool is
|
|
4
|
+
* sufficient; recycling voices (and their long-lived trim {@link GainNode}s) keeps GC churn down at
|
|
5
|
+
* high voice counts. Only the single-use source node is allocated per play.
|
|
6
|
+
*
|
|
7
|
+
* @type {ObjectPoolFactory<Voice>}
|
|
8
|
+
*/
|
|
9
|
+
export const VOICE_POOL: ObjectPoolFactory<Voice>;
|
|
10
|
+
import { ObjectPoolFactory } from "../../../../core/model/object/ObjectPoolFactory.js";
|
|
11
|
+
import { Voice } from "./Voice.js";
|
|
12
|
+
//# sourceMappingURL=VoicePool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoicePool.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra/runtime/VoicePool.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,yBAFU,kBAAkB,KAAK,CAAC,CAMhC;kCAfgC,oDAAoD;sBAChE,YAAY"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { noop } from "../../../../core/function/noop.js";
|
|
2
|
+
import { ObjectPoolFactory } from "../../../../core/model/object/ObjectPoolFactory.js";
|
|
3
|
+
import { Voice } from "./Voice.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Process-wide shared pool of reusable {@link Voice} objects, built on the generic
|
|
7
|
+
* {@link ObjectPoolFactory}. There is a single AudioContext in production, so one shared pool is
|
|
8
|
+
* sufficient; recycling voices (and their long-lived trim {@link GainNode}s) keeps GC churn down at
|
|
9
|
+
* high voice counts. Only the single-use source node is allocated per play.
|
|
10
|
+
*
|
|
11
|
+
* @type {ObjectPoolFactory<Voice>}
|
|
12
|
+
*/
|
|
13
|
+
export const VOICE_POOL = new ObjectPoolFactory(
|
|
14
|
+
() => new Voice(),
|
|
15
|
+
noop,
|
|
16
|
+
voice => voice.reset()
|
|
17
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register every sopra definition adapter on a {@link BinarySerializationRegistry}.
|
|
3
|
+
*
|
|
4
|
+
* In production this is called from `GameBinarySerializationRegistry.initializeGameBinarySerializationRegistry`
|
|
5
|
+
* (integration lands in P3); in P0 it backs the round-trip specs. Keeping the list here mirrors the
|
|
6
|
+
* behavior-tree `populateNodeRegistry` convention.
|
|
7
|
+
*
|
|
8
|
+
* @param {BinarySerializationRegistry} registry
|
|
9
|
+
*/
|
|
10
|
+
export function populateSopraSerializationRegistry(registry: BinarySerializationRegistry): void;
|
|
11
|
+
//# sourceMappingURL=populateSopraSerializationRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"populateSopraSerializationRegistry.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.js"],"names":[],"mappings":"AAeA;;;;;;;;GAQG;AACH,gGAiBC"}
|