@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,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default top-level bus ids, kept identical to the legacy {@link SoundEmitterChannels } for back-compat
|
|
3
|
+
* with the settings UI and `SoundEmitter.channel` strings.
|
|
4
|
+
*/
|
|
5
|
+
export type SopraDefaultBus = string;
|
|
6
|
+
export namespace SopraDefaultBus {
|
|
7
|
+
let Master: string;
|
|
8
|
+
let Effects: string;
|
|
9
|
+
let Music: string;
|
|
10
|
+
let Ambient: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The ECS-AGNOSTIC sopra audio engine. It owns the mixer bus graph, parameter store and the set of
|
|
14
|
+
* active {@link EventInstance}s, and is driven by a single clock (the injected AudioContext's
|
|
15
|
+
* `currentTime`). It never creates an AudioContext — the meep `SoundEngine` owns that. Voices are
|
|
16
|
+
* recycled through the shared {@link VOICE_POOL}.
|
|
17
|
+
*
|
|
18
|
+
* The entire public surface is unit-testable with a mock AudioContext + a stub {@link BufferProvider}.
|
|
19
|
+
*/
|
|
20
|
+
export class SopraEngine {
|
|
21
|
+
/**
|
|
22
|
+
* The default bus tree: a master root with the three legacy channels at the legacy mix.
|
|
23
|
+
* @returns {BusDefinition[]}
|
|
24
|
+
*/
|
|
25
|
+
static defaultBuses(): BusDefinition[];
|
|
26
|
+
/**
|
|
27
|
+
* @param {BaseAudioContext} audioContext
|
|
28
|
+
* @param {AudioNode} destinationNode master destination the bus root routes into
|
|
29
|
+
* @param {BufferProvider} bufferProvider
|
|
30
|
+
*/
|
|
31
|
+
constructor(audioContext: BaseAudioContext, destinationNode: AudioNode, bufferProvider: BufferProvider);
|
|
32
|
+
/**
|
|
33
|
+
* @type {ParameterStore}
|
|
34
|
+
*/
|
|
35
|
+
parameters: ParameterStore;
|
|
36
|
+
/**
|
|
37
|
+
* Shared playback context (seeded RNG + random-container history) used by instances that don't
|
|
38
|
+
* supply their own. In P3 each emitter supplies its own seeded context (entity id + tick).
|
|
39
|
+
* @type {SopraPlaybackContext}
|
|
40
|
+
*/
|
|
41
|
+
defaultPlaybackContext: SopraPlaybackContext;
|
|
42
|
+
/**
|
|
43
|
+
* Per-event instance limits + voice stealing.
|
|
44
|
+
* @type {VoiceManager}
|
|
45
|
+
*/
|
|
46
|
+
voiceManager: VoiceManager;
|
|
47
|
+
/**
|
|
48
|
+
* Listener world position for spatialization/attenuation. Null = no listener set yet (events play
|
|
49
|
+
* unattenuated). In P3 this is driven from the ECS SoundListener.
|
|
50
|
+
* @type {Vector3|null}
|
|
51
|
+
*/
|
|
52
|
+
listenerPosition: Vector3 | null;
|
|
53
|
+
/**
|
|
54
|
+
* @type {BaseAudioContext}
|
|
55
|
+
*/
|
|
56
|
+
audioContext: BaseAudioContext;
|
|
57
|
+
/**
|
|
58
|
+
* @type {AudioNode}
|
|
59
|
+
*/
|
|
60
|
+
destination: AudioNode;
|
|
61
|
+
/**
|
|
62
|
+
* @type {BufferProvider}
|
|
63
|
+
*/
|
|
64
|
+
bufferProvider: BufferProvider;
|
|
65
|
+
/**
|
|
66
|
+
* @type {BusGraph}
|
|
67
|
+
*/
|
|
68
|
+
busGraph: BusGraph;
|
|
69
|
+
/**
|
|
70
|
+
* @returns {number} current context time (the engine's authoritative clock)
|
|
71
|
+
*/
|
|
72
|
+
get currentTime(): number;
|
|
73
|
+
/**
|
|
74
|
+
* Replace the mixer with a new bus tree (rebuilds the WebAudio graph).
|
|
75
|
+
* @param {BusDefinition[]} busDefinitions
|
|
76
|
+
*/
|
|
77
|
+
setBuses(busDefinitions: BusDefinition[]): void;
|
|
78
|
+
/**
|
|
79
|
+
* Create (but do not start) an instance of an event.
|
|
80
|
+
* @param {EventDescription} description
|
|
81
|
+
* @param {{busId?:string, position?:Vector3, oneShot?:boolean, maxLifetime?:number, seed?:number, playbackContext?:SopraPlaybackContext}} [options]
|
|
82
|
+
* @returns {EventInstance}
|
|
83
|
+
*/
|
|
84
|
+
createInstance(description: EventDescription, options?: {
|
|
85
|
+
busId?: string;
|
|
86
|
+
position?: Vector3;
|
|
87
|
+
oneShot?: boolean;
|
|
88
|
+
maxLifetime?: number;
|
|
89
|
+
seed?: number;
|
|
90
|
+
playbackContext?: SopraPlaybackContext;
|
|
91
|
+
}): EventInstance;
|
|
92
|
+
/**
|
|
93
|
+
* Create, start and track an instance.
|
|
94
|
+
* @param {EventDescription} description
|
|
95
|
+
* @param {{busId?:string, position?:Vector3, oneShot?:boolean, maxLifetime?:number, seed?:number, playbackContext?:SopraPlaybackContext}} [options]
|
|
96
|
+
* @returns {EventInstance}
|
|
97
|
+
*/
|
|
98
|
+
playEvent(description: EventDescription, options?: {
|
|
99
|
+
busId?: string;
|
|
100
|
+
position?: Vector3;
|
|
101
|
+
oneShot?: boolean;
|
|
102
|
+
maxLifetime?: number;
|
|
103
|
+
seed?: number;
|
|
104
|
+
playbackContext?: SopraPlaybackContext;
|
|
105
|
+
}): EventInstance;
|
|
106
|
+
/**
|
|
107
|
+
* Fire-and-forget: a one-shot that auto-releases when its content finishes (or on the
|
|
108
|
+
* lifetime/asset-failure fallback).
|
|
109
|
+
* @param {EventDescription} description
|
|
110
|
+
* @param {{busId?:string, position?:Vector3, maxLifetime?:number}} [options]
|
|
111
|
+
* @returns {EventInstance}
|
|
112
|
+
*/
|
|
113
|
+
playOneShot(description: EventDescription, options?: {
|
|
114
|
+
busId?: string;
|
|
115
|
+
position?: Vector3;
|
|
116
|
+
maxLifetime?: number;
|
|
117
|
+
}): EventInstance;
|
|
118
|
+
/**
|
|
119
|
+
* @param {EventInstance} instance
|
|
120
|
+
*/
|
|
121
|
+
stop(instance: EventInstance): void;
|
|
122
|
+
/**
|
|
123
|
+
* Crossfade from a playing instance to a new event: start the new one at silence and fade it up to
|
|
124
|
+
* its nominal gain while fading the old one out and stopping it, over `duration`.
|
|
125
|
+
* @param {EventInstance|null} oldInstance instance to fade out (may be null)
|
|
126
|
+
* @param {EventDescription} description event to fade in
|
|
127
|
+
* @param {{busId?:string, position?:Vector3, duration?:number}} [options]
|
|
128
|
+
* @returns {EventInstance|null} the new instance (or null if the play was denied by limits)
|
|
129
|
+
*/
|
|
130
|
+
crossfade(oldInstance: EventInstance | null, description: EventDescription, options?: {
|
|
131
|
+
busId?: string;
|
|
132
|
+
position?: Vector3;
|
|
133
|
+
duration?: number;
|
|
134
|
+
}): EventInstance | null;
|
|
135
|
+
/**
|
|
136
|
+
* @param {string} name
|
|
137
|
+
* @param {number} value
|
|
138
|
+
*/
|
|
139
|
+
setParameter(name: string, value: number): void;
|
|
140
|
+
/**
|
|
141
|
+
* @param {string} name
|
|
142
|
+
* @returns {number|undefined}
|
|
143
|
+
*/
|
|
144
|
+
getParameter(name: string): number | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Set the listener world position used for 3D attenuation/culling.
|
|
147
|
+
* @param {Vector3} position
|
|
148
|
+
*/
|
|
149
|
+
setListener(position: Vector3): void;
|
|
150
|
+
/**
|
|
151
|
+
* Register a parameter with a default value.
|
|
152
|
+
* @param {string} name
|
|
153
|
+
* @param {number} [defaultValue]
|
|
154
|
+
*/
|
|
155
|
+
defineParameter(name: string, defaultValue?: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* Bind an arbitrary apply callback to a parameter (runs on change, and once now if already set).
|
|
158
|
+
* @param {string} name
|
|
159
|
+
* @param {function(number)} applyFn
|
|
160
|
+
*/
|
|
161
|
+
bindParameter(name: string, applyFn: (arg0: number) => any): void;
|
|
162
|
+
/**
|
|
163
|
+
* Drive a bus's linear volume from a parameter through an {@link AnimationCurve}.
|
|
164
|
+
* @param {string} name
|
|
165
|
+
* @param {string} busId
|
|
166
|
+
* @param {AnimationCurve} curve maps parameter value -> linear bus gain
|
|
167
|
+
*/
|
|
168
|
+
bindParameterToBusVolume(name: string, busId: string, curve: AnimationCurve): void;
|
|
169
|
+
/**
|
|
170
|
+
* @param {string} busId
|
|
171
|
+
* @returns {number} linear gain
|
|
172
|
+
*/
|
|
173
|
+
getBusVolume(busId: string): number;
|
|
174
|
+
/**
|
|
175
|
+
* @param {string} busId
|
|
176
|
+
* @param {number} linear linear gain
|
|
177
|
+
*/
|
|
178
|
+
setBusVolume(busId: string, linear: number): void;
|
|
179
|
+
/**
|
|
180
|
+
* Apply a {@link MixerSnapshot}: move each listed bus to its target gain. `duration` 0 snaps
|
|
181
|
+
* instantly; > 0 click-safely ramps (a mix-state blend).
|
|
182
|
+
* @param {MixerSnapshot} snapshot
|
|
183
|
+
* @param {{duration?:number}} [options]
|
|
184
|
+
*/
|
|
185
|
+
applySnapshot(snapshot: MixerSnapshot, { duration }?: {
|
|
186
|
+
duration?: number;
|
|
187
|
+
}): void;
|
|
188
|
+
/**
|
|
189
|
+
* Capture the current gain of each given bus into a snapshot (e.g. to restore a mix later).
|
|
190
|
+
* @param {string} id
|
|
191
|
+
* @param {string[]} busIds
|
|
192
|
+
* @returns {MixerSnapshot}
|
|
193
|
+
*/
|
|
194
|
+
captureSnapshot(id: string, busIds: string[]): MixerSnapshot;
|
|
195
|
+
/**
|
|
196
|
+
* Advance the engine. Drives per-instance lifetime bookkeeping (and, from P1, the scheduler).
|
|
197
|
+
* @param {number} [now] context time; defaults to the live clock
|
|
198
|
+
*/
|
|
199
|
+
update(now?: number): void;
|
|
200
|
+
/**
|
|
201
|
+
* Register a ducking rule (e.g. duck `music` while anything plays on `dialogue`). Evaluated each
|
|
202
|
+
* {@link update}.
|
|
203
|
+
* @param {DuckingRule} rule
|
|
204
|
+
*/
|
|
205
|
+
addDucker(rule: DuckingRule): void;
|
|
206
|
+
/**
|
|
207
|
+
* Remove all ducking rules (restoring any currently-ducked target to its captured nominal).
|
|
208
|
+
*/
|
|
209
|
+
clearDuckers(): void;
|
|
210
|
+
/**
|
|
211
|
+
* @returns {number} count of live instances (for tests/diagnostics)
|
|
212
|
+
*/
|
|
213
|
+
get activeInstanceCount(): number;
|
|
214
|
+
/**
|
|
215
|
+
* Internal: invoked by an {@link EventInstance} when it finishes. Uses the `__` prefix because it
|
|
216
|
+
* is a cross-class internal call, not part of the public API.
|
|
217
|
+
* @param {EventInstance} instance
|
|
218
|
+
*/
|
|
219
|
+
__onInstanceFinished(instance: EventInstance): void;
|
|
220
|
+
#private;
|
|
221
|
+
}
|
|
222
|
+
import { ParameterStore } from "./runtime/ParameterStore.js";
|
|
223
|
+
import { SopraPlaybackContext } from "./runtime/SopraPlaybackContext.js";
|
|
224
|
+
import { VoiceManager } from "./runtime/VoiceManager.js";
|
|
225
|
+
import { BusGraph } from "./runtime/BusGraph.js";
|
|
226
|
+
import { BusDefinition } from "./definition/BusDefinition.js";
|
|
227
|
+
import { EventInstance } from "./runtime/EventInstance.js";
|
|
228
|
+
import { MixerSnapshot } from "./definition/MixerSnapshot.js";
|
|
229
|
+
//# sourceMappingURL=SopraEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SopraEngine.d.ts","sourceRoot":"","sources":["../../../../../src/engine/sound/sopra/SopraEngine.js"],"names":[],"mappings":";;;;8BAcU,MAAM;;;;;;;AAahB;;;;;;;GAOG;AACH;IA6EI;;;OAGG;IACH,uBAFa,aAAa,EAAE,CAS3B;IAlDD;;;;OAIG;IACH,0BAJW,gBAAgB,mBAChB,SAAS,kCA4BnB;IAlED;;OAEG;IACH,YAFU,cAAc,CAEU;IAElC;;;;OAIG;IACH,wBAFU,oBAAoB,CAEsB;IAEpD;;;OAGG;IACH,cAFU,YAAY,CAEY;IAElC;;;;OAIG;IACH,kBAFU,UAAQ,IAAI,CAEE;IAuBpB;;OAEG;IACH,cAFU,gBAAgB,CAEM;IAEhC;;OAEG;IACH,aAFU,SAAS,CAEe;IAElC;;OAEG;IACH,+BAAoC;IAEpC;;OAEG;IACH,UAFU,QAAQ,CAEyC;IAI/D;;OAEG;IACH,0BAEC;IAeD;;;OAGG;IACH,yBAFW,aAAa,EAAE,QAKzB;IAED;;;;;OAKG;IACH;gBAHmB,MAAM;;kBAA8B,OAAO;sBAAe,MAAM;eAAQ,MAAM;0BAAmB,oBAAoB;QAC3H,aAAa,CAOzB;IAED;;;;;OAKG;IACH,mDAHW;QAAC,KAAK,CAAC,EAAC,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAS;QAAC,OAAO,CAAC,EAAC,OAAO,CAAC;QAAC,WAAW,CAAC,EAAC,MAAM,CAAC;QAAC,IAAI,CAAC,EAAC,MAAM,CAAC;QAAC,eAAe,CAAC,EAAC,oBAAoB,CAAA;KAAC,GAC5H,aAAa,CAuBzB;IAED;;;;;;OAMG;IACH,qDAHW;QAAC,KAAK,CAAC,EAAC,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAS;QAAC,WAAW,CAAC,EAAC,MAAM,CAAA;KAAC,GACrD,aAAa,CAIzB;IAED;;OAEG;IACH,eAFW,aAAa,QAIvB;IAED;;;;;;;OAOG;IACH,uBALW,aAAa,GAAC,IAAI;gBAEV,MAAM;;mBAA+B,MAAM;QACjD,aAAa,GAAC,IAAI,CAmB9B;IAED;;;OAGG;IACH,mBAHW,MAAM,SACN,MAAM,QAIhB;IAED;;;OAGG;IACH,mBAHW,MAAM,GACJ,MAAM,GAAC,SAAS,CAI5B;IAED;;;OAGG;IACH,qCAEC;IAED;;;;OAIG;IACH,sBAHW,MAAM,iBACN,MAAM,QAIhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,kBACG,MAAM,gBAIzB;IAED;;;;;OAKG;IACH,+BAJW,MAAM,SACN,MAAM,+BAKhB;IAED;;;OAGG;IACH,oBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;OAGG;IACH,oBAHW,MAAM,UACN,MAAM,QAIhB;IAED;;;;;OAKG;IACH,wBAHW,aAAa,iBACb;QAAC,QAAQ,CAAC,EAAC,MAAM,CAAA;KAAC,QAe5B;IAED;;;;;OAKG;IACH,oBAJW,MAAM,UACN,MAAM,EAAE,GACN,aAAa,CAUzB;IAED;;;OAGG;IACH,aAFW,MAAM,QAahB;IAED;;;;OAIG;IACH,mCAEC;IAED;;OAEG;IACH,qBAWC;IAwCD;;OAEG;IACH,kCAEC;IAED;;;;OAIG;IACH,+BAFW,aAAa,QAKvB;;CACJ;+BA/Z8B,6BAA6B;qCACvB,mCAAmC;6BAC3C,2BAA2B;yBANd,uBAAuB;8BACnC,+BAA+B;8BAE/B,4BAA4B;8BAD5B,+BAA+B"}
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { assert } from "../../../core/assert.js";
|
|
2
|
+
import { dB2Volume } from "../dB2Volume.js";
|
|
3
|
+
import { volume2dB } from "../volume2dB.js";
|
|
4
|
+
import { BUS_ROOT_PARENT, BusGraph } from "./runtime/BusGraph.js";
|
|
5
|
+
import { BusDefinition } from "./definition/BusDefinition.js";
|
|
6
|
+
import { MixerSnapshot } from "./definition/MixerSnapshot.js";
|
|
7
|
+
import { EventInstance } from "./runtime/EventInstance.js";
|
|
8
|
+
import { ParameterStore } from "./runtime/ParameterStore.js";
|
|
9
|
+
import { SopraPlaybackContext } from "./runtime/SopraPlaybackContext.js";
|
|
10
|
+
import { VoiceManager } from "./runtime/VoiceManager.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default top-level bus ids, kept identical to the legacy {@link SoundEmitterChannels} for back-compat
|
|
14
|
+
* with the settings UI and `SoundEmitter.channel` strings.
|
|
15
|
+
* @enum {string}
|
|
16
|
+
*/
|
|
17
|
+
export const SopraDefaultBus = {
|
|
18
|
+
Master: "master",
|
|
19
|
+
Effects: "effects",
|
|
20
|
+
Music: "music",
|
|
21
|
+
Ambient: "ambient"
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// legacy default mix (verified SoundEmitterSystem constructor): Effects 1.2, Music 0.1, Ambient 1
|
|
25
|
+
const LEGACY_EFFECTS_VOLUME = 1.2;
|
|
26
|
+
const LEGACY_MUSIC_VOLUME = 0.1;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The ECS-AGNOSTIC sopra audio engine. It owns the mixer bus graph, parameter store and the set of
|
|
30
|
+
* active {@link EventInstance}s, and is driven by a single clock (the injected AudioContext's
|
|
31
|
+
* `currentTime`). It never creates an AudioContext — the meep `SoundEngine` owns that. Voices are
|
|
32
|
+
* recycled through the shared {@link VOICE_POOL}.
|
|
33
|
+
*
|
|
34
|
+
* The entire public surface is unit-testable with a mock AudioContext + a stub {@link BufferProvider}.
|
|
35
|
+
*/
|
|
36
|
+
export class SopraEngine {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @type {ParameterStore}
|
|
40
|
+
*/
|
|
41
|
+
parameters = new ParameterStore();
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Shared playback context (seeded RNG + random-container history) used by instances that don't
|
|
45
|
+
* supply their own. In P3 each emitter supplies its own seeded context (entity id + tick).
|
|
46
|
+
* @type {SopraPlaybackContext}
|
|
47
|
+
*/
|
|
48
|
+
defaultPlaybackContext = new SopraPlaybackContext();
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Per-event instance limits + voice stealing.
|
|
52
|
+
* @type {VoiceManager}
|
|
53
|
+
*/
|
|
54
|
+
voiceManager = new VoiceManager();
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Listener world position for spatialization/attenuation. Null = no listener set yet (events play
|
|
58
|
+
* unattenuated). In P3 this is driven from the ECS SoundListener.
|
|
59
|
+
* @type {Vector3|null}
|
|
60
|
+
*/
|
|
61
|
+
listenerPosition = null;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @type {Set<EventInstance>}
|
|
65
|
+
*/
|
|
66
|
+
#activeInstances = new Set();
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Active ducking rules + their runtime state.
|
|
70
|
+
* @type {{rule: DuckingRule, engaged: boolean, nominalDb: number}[]}
|
|
71
|
+
*/
|
|
72
|
+
#duckers = [];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {BaseAudioContext} audioContext
|
|
76
|
+
* @param {AudioNode} destinationNode master destination the bus root routes into
|
|
77
|
+
* @param {BufferProvider} bufferProvider
|
|
78
|
+
*/
|
|
79
|
+
constructor(audioContext, destinationNode, bufferProvider) {
|
|
80
|
+
assert.defined(audioContext, 'audioContext');
|
|
81
|
+
assert.defined(destinationNode, 'destinationNode');
|
|
82
|
+
assert.defined(bufferProvider, 'bufferProvider');
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @type {BaseAudioContext}
|
|
86
|
+
*/
|
|
87
|
+
this.audioContext = audioContext;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @type {AudioNode}
|
|
91
|
+
*/
|
|
92
|
+
this.destination = destinationNode;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @type {BufferProvider}
|
|
96
|
+
*/
|
|
97
|
+
this.bufferProvider = bufferProvider;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @type {BusGraph}
|
|
101
|
+
*/
|
|
102
|
+
this.busGraph = new BusGraph(audioContext, destinationNode);
|
|
103
|
+
this.busGraph.build(SopraEngine.defaultBuses());
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @returns {number} current context time (the engine's authoritative clock)
|
|
108
|
+
*/
|
|
109
|
+
get currentTime() {
|
|
110
|
+
return this.audioContext.currentTime;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The default bus tree: a master root with the three legacy channels at the legacy mix.
|
|
115
|
+
* @returns {BusDefinition[]}
|
|
116
|
+
*/
|
|
117
|
+
static defaultBuses() {
|
|
118
|
+
return [
|
|
119
|
+
BusDefinition.from(SopraDefaultBus.Master, { parentId: BUS_ROOT_PARENT, gainDb: 0 }),
|
|
120
|
+
BusDefinition.from(SopraDefaultBus.Effects, { parentId: SopraDefaultBus.Master, gainDb: volume2dB(LEGACY_EFFECTS_VOLUME) }),
|
|
121
|
+
BusDefinition.from(SopraDefaultBus.Music, { parentId: SopraDefaultBus.Master, gainDb: volume2dB(LEGACY_MUSIC_VOLUME) }),
|
|
122
|
+
BusDefinition.from(SopraDefaultBus.Ambient, { parentId: SopraDefaultBus.Master, gainDb: 0 })
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Replace the mixer with a new bus tree (rebuilds the WebAudio graph).
|
|
128
|
+
* @param {BusDefinition[]} busDefinitions
|
|
129
|
+
*/
|
|
130
|
+
setBuses(busDefinitions) {
|
|
131
|
+
this.busGraph = new BusGraph(this.audioContext, this.destination);
|
|
132
|
+
this.busGraph.build(busDefinitions);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Create (but do not start) an instance of an event.
|
|
137
|
+
* @param {EventDescription} description
|
|
138
|
+
* @param {{busId?:string, position?:Vector3, oneShot?:boolean, maxLifetime?:number, seed?:number, playbackContext?:SopraPlaybackContext}} [options]
|
|
139
|
+
* @returns {EventInstance}
|
|
140
|
+
*/
|
|
141
|
+
createInstance(description, options = {}) {
|
|
142
|
+
const playbackContext = options.playbackContext
|
|
143
|
+
?? (options.seed !== undefined ? new SopraPlaybackContext(options.seed) : this.defaultPlaybackContext);
|
|
144
|
+
|
|
145
|
+
return new EventInstance(this, description, { ...options, playbackContext });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Create, start and track an instance.
|
|
150
|
+
* @param {EventDescription} description
|
|
151
|
+
* @param {{busId?:string, position?:Vector3, oneShot?:boolean, maxLifetime?:number, seed?:number, playbackContext?:SopraPlaybackContext}} [options]
|
|
152
|
+
* @returns {EventInstance}
|
|
153
|
+
*/
|
|
154
|
+
playEvent(description, options = {}) {
|
|
155
|
+
if (!this.voiceManager.makeRoom(description)) {
|
|
156
|
+
// event instance limit reached and steal mode is None — drop this play
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const instance = this.createInstance(description, options);
|
|
161
|
+
|
|
162
|
+
this.voiceManager.register(instance);
|
|
163
|
+
this.#activeInstances.add(instance);
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
instance.start(this.currentTime);
|
|
167
|
+
} catch (e) {
|
|
168
|
+
// clean up registries before propagating (rethrows — not a silent catch)
|
|
169
|
+
this.voiceManager.unregister(instance);
|
|
170
|
+
this.#activeInstances.delete(instance);
|
|
171
|
+
throw e;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return instance;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Fire-and-forget: a one-shot that auto-releases when its content finishes (or on the
|
|
179
|
+
* lifetime/asset-failure fallback).
|
|
180
|
+
* @param {EventDescription} description
|
|
181
|
+
* @param {{busId?:string, position?:Vector3, maxLifetime?:number}} [options]
|
|
182
|
+
* @returns {EventInstance}
|
|
183
|
+
*/
|
|
184
|
+
playOneShot(description, options = {}) {
|
|
185
|
+
return this.playEvent(description, { ...options, oneShot: true });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @param {EventInstance} instance
|
|
190
|
+
*/
|
|
191
|
+
stop(instance) {
|
|
192
|
+
instance.stop();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Crossfade from a playing instance to a new event: start the new one at silence and fade it up to
|
|
197
|
+
* its nominal gain while fading the old one out and stopping it, over `duration`.
|
|
198
|
+
* @param {EventInstance|null} oldInstance instance to fade out (may be null)
|
|
199
|
+
* @param {EventDescription} description event to fade in
|
|
200
|
+
* @param {{busId?:string, position?:Vector3, duration?:number}} [options]
|
|
201
|
+
* @returns {EventInstance|null} the new instance (or null if the play was denied by limits)
|
|
202
|
+
*/
|
|
203
|
+
crossfade(oldInstance, description, options = {}) {
|
|
204
|
+
const duration = options.duration ?? 1;
|
|
205
|
+
|
|
206
|
+
const newInstance = this.playEvent(description, options);
|
|
207
|
+
|
|
208
|
+
if (newInstance !== null) {
|
|
209
|
+
const nominalDb = newInstance.gainDb;
|
|
210
|
+
|
|
211
|
+
newInstance.setGainDb(nominalDb - 60); // start ~silent
|
|
212
|
+
newInstance.fadeToGainDb(nominalDb, duration);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (oldInstance !== null && oldInstance !== newInstance) {
|
|
216
|
+
oldInstance.fadeOutAndStop(duration);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return newInstance;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @param {string} name
|
|
224
|
+
* @param {number} value
|
|
225
|
+
*/
|
|
226
|
+
setParameter(name, value) {
|
|
227
|
+
this.parameters.set(name, value);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @param {string} name
|
|
232
|
+
* @returns {number|undefined}
|
|
233
|
+
*/
|
|
234
|
+
getParameter(name) {
|
|
235
|
+
return this.parameters.get(name);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Set the listener world position used for 3D attenuation/culling.
|
|
240
|
+
* @param {Vector3} position
|
|
241
|
+
*/
|
|
242
|
+
setListener(position) {
|
|
243
|
+
this.listenerPosition = position;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Register a parameter with a default value.
|
|
248
|
+
* @param {string} name
|
|
249
|
+
* @param {number} [defaultValue]
|
|
250
|
+
*/
|
|
251
|
+
defineParameter(name, defaultValue = 0) {
|
|
252
|
+
this.parameters.define(name, defaultValue);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Bind an arbitrary apply callback to a parameter (runs on change, and once now if already set).
|
|
257
|
+
* @param {string} name
|
|
258
|
+
* @param {function(number)} applyFn
|
|
259
|
+
*/
|
|
260
|
+
bindParameter(name, applyFn) {
|
|
261
|
+
this.parameters.bind(name, applyFn);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Drive a bus's linear volume from a parameter through an {@link AnimationCurve}.
|
|
266
|
+
* @param {string} name
|
|
267
|
+
* @param {string} busId
|
|
268
|
+
* @param {AnimationCurve} curve maps parameter value -> linear bus gain
|
|
269
|
+
*/
|
|
270
|
+
bindParameterToBusVolume(name, busId, curve) {
|
|
271
|
+
this.parameters.bind(name, (value) => this.setBusVolume(busId, curve.evaluate(value)));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @param {string} busId
|
|
276
|
+
* @returns {number} linear gain
|
|
277
|
+
*/
|
|
278
|
+
getBusVolume(busId) {
|
|
279
|
+
return this.busGraph.getVolume(busId);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @param {string} busId
|
|
284
|
+
* @param {number} linear linear gain
|
|
285
|
+
*/
|
|
286
|
+
setBusVolume(busId, linear) {
|
|
287
|
+
this.busGraph.setVolume(busId, linear);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Apply a {@link MixerSnapshot}: move each listed bus to its target gain. `duration` 0 snaps
|
|
292
|
+
* instantly; > 0 click-safely ramps (a mix-state blend).
|
|
293
|
+
* @param {MixerSnapshot} snapshot
|
|
294
|
+
* @param {{duration?:number}} [options]
|
|
295
|
+
*/
|
|
296
|
+
applySnapshot(snapshot, { duration = 0 } = {}) {
|
|
297
|
+
const buses = snapshot.buses;
|
|
298
|
+
|
|
299
|
+
for (let i = 0; i < buses.length; i++) {
|
|
300
|
+
const entry = buses[i];
|
|
301
|
+
const linear = dB2Volume(entry.gainDb);
|
|
302
|
+
|
|
303
|
+
if (duration <= 0) {
|
|
304
|
+
this.busGraph.setVolume(entry.busId, linear);
|
|
305
|
+
} else {
|
|
306
|
+
this.busGraph.rampVolume(entry.busId, linear, duration);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Capture the current gain of each given bus into a snapshot (e.g. to restore a mix later).
|
|
313
|
+
* @param {string} id
|
|
314
|
+
* @param {string[]} busIds
|
|
315
|
+
* @returns {MixerSnapshot}
|
|
316
|
+
*/
|
|
317
|
+
captureSnapshot(id, busIds) {
|
|
318
|
+
const buses = [];
|
|
319
|
+
|
|
320
|
+
for (let i = 0; i < busIds.length; i++) {
|
|
321
|
+
buses.push({ busId: busIds[i], gainDb: this.busGraph.getVolumeDb(busIds[i]) });
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return MixerSnapshot.from(id, buses);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Advance the engine. Drives per-instance lifetime bookkeeping (and, from P1, the scheduler).
|
|
329
|
+
* @param {number} [now] context time; defaults to the live clock
|
|
330
|
+
*/
|
|
331
|
+
update(now = this.currentTime) {
|
|
332
|
+
const listenerPosition = this.listenerPosition;
|
|
333
|
+
|
|
334
|
+
// snapshot — an instance may finish (and remove itself) during its own update
|
|
335
|
+
const instances = [...this.#activeInstances];
|
|
336
|
+
|
|
337
|
+
for (let i = 0; i < instances.length; i++) {
|
|
338
|
+
instances[i].update(now, listenerPosition);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
this.#updateDuckers();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Register a ducking rule (e.g. duck `music` while anything plays on `dialogue`). Evaluated each
|
|
346
|
+
* {@link update}.
|
|
347
|
+
* @param {DuckingRule} rule
|
|
348
|
+
*/
|
|
349
|
+
addDucker(rule) {
|
|
350
|
+
this.#duckers.push({ rule, engaged: false, nominalDb: 0 });
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Remove all ducking rules (restoring any currently-ducked target to its captured nominal).
|
|
355
|
+
*/
|
|
356
|
+
clearDuckers() {
|
|
357
|
+
const duckers = this.#duckers;
|
|
358
|
+
|
|
359
|
+
for (let i = 0; i < duckers.length; i++) {
|
|
360
|
+
const d = duckers[i];
|
|
361
|
+
if (d.engaged) {
|
|
362
|
+
this.busGraph.approachVolume(d.rule.targetBusId, dB2Volume(d.nominalDb), d.rule.release);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
this.#duckers = [];
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Edge-triggered duck engage/release: a target ducks while its trigger bus has any live instance,
|
|
371
|
+
* and restores to the gain captured at engage time when the trigger goes quiet.
|
|
372
|
+
*/
|
|
373
|
+
#updateDuckers() {
|
|
374
|
+
const duckers = this.#duckers;
|
|
375
|
+
|
|
376
|
+
for (let i = 0; i < duckers.length; i++) {
|
|
377
|
+
const d = duckers[i];
|
|
378
|
+
const active = this.#busActiveCount(d.rule.triggerBusId) > 0;
|
|
379
|
+
|
|
380
|
+
if (active && !d.engaged) {
|
|
381
|
+
d.engaged = true;
|
|
382
|
+
d.nominalDb = this.busGraph.getVolumeDb(d.rule.targetBusId);
|
|
383
|
+
this.busGraph.approachVolume(d.rule.targetBusId, dB2Volume(d.nominalDb + d.rule.duckDb), d.rule.attack);
|
|
384
|
+
} else if (!active && d.engaged) {
|
|
385
|
+
d.engaged = false;
|
|
386
|
+
this.busGraph.approachVolume(d.rule.targetBusId, dB2Volume(d.nominalDb), d.rule.release);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* @param {string} busId
|
|
393
|
+
* @returns {number} count of live instances routed to that bus
|
|
394
|
+
*/
|
|
395
|
+
#busActiveCount(busId) {
|
|
396
|
+
let n = 0;
|
|
397
|
+
|
|
398
|
+
this.#activeInstances.forEach(instance => {
|
|
399
|
+
if (instance.busId === busId) {
|
|
400
|
+
n++;
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
return n;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* @returns {number} count of live instances (for tests/diagnostics)
|
|
409
|
+
*/
|
|
410
|
+
get activeInstanceCount() {
|
|
411
|
+
return this.#activeInstances.size;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Internal: invoked by an {@link EventInstance} when it finishes. Uses the `__` prefix because it
|
|
416
|
+
* is a cross-class internal call, not part of the public API.
|
|
417
|
+
* @param {EventInstance} instance
|
|
418
|
+
*/
|
|
419
|
+
__onInstanceFinished(instance) {
|
|
420
|
+
this.#activeInstances.delete(instance);
|
|
421
|
+
this.voiceManager.unregister(instance);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production {@link BufferProvider} that draws decoded {@link AudioBuffer}s from the meep
|
|
3
|
+
* {@link AssetManager}. Reuses the shared decode cache (one immutable AudioBuffer backs many voices)
|
|
4
|
+
* and the existing alias system.
|
|
5
|
+
*/
|
|
6
|
+
export class AssetManagerBufferProvider extends BufferProvider {
|
|
7
|
+
/**
|
|
8
|
+
* @param {AssetManager} assetManager
|
|
9
|
+
*/
|
|
10
|
+
constructor(assetManager: AssetManager);
|
|
11
|
+
/**
|
|
12
|
+
* @type {AssetManager}
|
|
13
|
+
*/
|
|
14
|
+
assetManager: AssetManager;
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
* @param {string} url
|
|
18
|
+
* @param {boolean} usingAlias
|
|
19
|
+
* @returns {string|null} resolved path, or null if an alias could not be resolved
|
|
20
|
+
*/
|
|
21
|
+
private __resolvePath;
|
|
22
|
+
tryGet(url: any, usingAlias: any): any;
|
|
23
|
+
get(url: any, usingAlias: any): any;
|
|
24
|
+
}
|
|
25
|
+
import { BufferProvider } from "./BufferProvider.js";
|
|
26
|
+
//# sourceMappingURL=AssetManagerBufferProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetManagerBufferProvider.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra/asset/AssetManagerBufferProvider.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH;IACI;;OAEG;IACH,wCAOC;IAJG;;OAEG;IACH,2BAAgC;IAGpC;;;;;OAKG;IACH,sBAYC;IAED,uCAcC;IAED,oCAYC;CACJ;+BArE8B,qBAAqB"}
|