bevy-audio-systems

Installation
SKILL.md

Bevy audio systems

When to use

Load this when a clip should start, loop, pause, or change volume. bevy::audio on docs.rs latest (0.20.0) and the audio_control example there are the sources.

ECS shape

  • Play: spawn AudioPlayer::new(asset_server.load(...)). AudioPlayer<Source> holds Handle<Source> where Source: Asset + Decodable. If the asset is not ready, playback starts when it is. AudioPlayer requires PlaybackSettings.
  • Settings: PlaybackSettings configures the start. PlaybackSettings::LOOP and .with_spatial(true) appear in the spatial examples. Changes to PlaybackSettings do not affect audio that is already playing. PlaybackMode is Once, Loop, Despawn, or Remove.
  • Control: when playback begins, Bevy inserts AudioSink. The control example queries AudioSink and calls pause, toggle_mute, set_volume, set_speed, and position. SpatialAudioSink is the spatial counterpart named on the playback page.
  • Replay: after a non-looping sound finishes and the sink is drained, that AudioPlayer cannot be reused. Remove the audio components and add them again.
  • Schedule: spawn on Startup or from a system that has Res<AssetServer> and Commands. Control systems in the example run where they read ButtonInput<KeyCode> and Res<Time>.

Coming from Godot

Installs
4
GitHub Stars
850
First Seen
3 days ago