Skip to content

jengine-audio

Audio package for jEngine — kira-based sound effects and music.

KindBuilt-in: linked into the stock runtime and editor viewport
Sourcepackages/jengine-audio
Version0.1.0
Entry pointjengine_audio::AudioPackage

The stock runtime, web build and editor viewport are compiled with this package, so there is nothing to link. A project that has a settings.enabled_packages list must name it there, since that list is an allow-list once it exists; a project without the key gets every built-in.

{ "settings": { "enabled_packages": ["jengine-audio"] } }

Its components are also core components, so v1 and v2 scenes both carry them.

Scene keyRust type
audio_sourceAudioSourcealso registered by core
  • projects/engine-test-lab/assets/scenes/162-positional-audio.scene
  • projects/engine-test-lab/assets/scenes/165-audio-effects.scene
  • projects/engine-test-lab/assets/scenes/243-wall-occlusion.scene
  • projects/engine-test-lab/assets/scenes/47-motion-components.scene
  • projects/visual-showcase/assets/scenes/116-muffled-halls.scene
  • projects/visual-showcase/assets/scenes/43-night-market.scene
  • projects/visual-showcase/assets/scenes/46-sea-cove.scene
  • projects/visual-showcase/assets/scenes/48-the-forge.scene
  • projects/visual-showcase/assets/scenes/49-stage-night.scene
  • projects/visual-showcase/assets/scenes/78-echo-canyon.scene

From packages/jengine-audio/README.md.

Sound effects and music on kira, for the native runtime.

This is a built-in package of the native runtime. It is native only: kira does not build for wasm32, so a web build refuses a project that lists it by name rather than silently leaving it out. The editor and web builds play the same sounds through their own Web Audio backend, so leave it out of a project’s "packages" array and let settings.enabled_packages name it.

ComponentIs
audio_sourceA clip on an entity: clip_id, volume, pitch, looping, auto_play, its mixer bus_id, and spatial (with min_distance / max_distance) to be heard from where the entity is.

audio_source is also a core component, so it works in v1 and v2 scenes.

It re-exports core’s AudioBackend, KiraAudioBackend and friends for Rust code that wants them. Its audio_update system ticks a backend only if a host shares one as a resource; the shipped runtimes drive their backend themselves.

Scripts use core’s Audio namespace in every runtime: Audio.play_sound, Audio.play_sound_at, Audio.play_music, Audio.get_music_position, the mixer buses (Audio.create_bus, Audio.set_bus_volume, Audio.set_bus_effect) and more - see the Audio guide and the Scripting API.

The package’s own audio_* script descriptors are metadata only; no runtime installs them as globals.

  • A clip must be preloaded: list it in the scene’s top-level "audio_refs" array. clip_id is the path under assets/ ("sounds/hit.wav").
  • Time things to the music with Audio.get_music_position(), not by adding up dt.