bevy-audio
Skill29 starsChanged 11 days agoMITView on GitHub
Use when implementing audio in Bevy 0.20 with `AudioPlayer`, `PlaybackSettings`, `AudioSink` or `SpatialAudioSink`, spatial listeners, application mix groups, ambience/music transitions, asset lifetime, browser gesture restrictions, or choosing built-in audio versus `bevy_seedling 0.8`.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- bevy-a11ySkill
- bevy-animationSkill
- bevy-assetsSkill
- bevy-camerasSkill
- bevy-captureSkill
- bevy-cargo-featuresSkill
- bevy-core-conceptsSkill
- bevy-custom-assetsSkill
- bevy-diagnostics-profilingSkill
- bevy-ecs-componentsSkill
- bevy-ecs-queriesSkill
- bevy-ecs-systemsSkill
- bevy-fluentSkill
- bevy-input-actionsSkill
- bevy-migration-0-17-to-0-18Skill
- bevy-migration-0-18-to-0-19Skill
- bevy-migration-0-19-to-0-20Skill
- bevy-pbr-materialsSkill
- bevy-physicsSkill
- bevy-portingSkill
- bevy-renderingSkill
- bevy-save-loadSkill
- bevySkill
- bevy-testingSkill
- bevy-uiSkill
- bevy-vfxSkill
- bevy-voxel-dataSkill
- bevy-voxel-pipelineSkill
- bevy-voxel-runtimeSkill
- bevy-wasm-webgpuSkill
- similarity-rsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Add spatial sources/listeners or define the built-in HRTF/effects boundary.
- Distinctive: line 21
Use Bevy's built-in entity-based audio for straightforward clips, loops, playback control, and simple spatial stereo.
- Very specific: line 101
Keep exactly one SpatialListener.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bevy 0.20 — audio
When to use this skill
- Spawn or control clips/loops through
AudioPlayerand sink components. - Build music/ambience transitions, mix categories, ducking, or pause policy.
- Add spatial sources/listeners or define the built-in HRTF/effects boundary.
- Ship audio on browsers or evaluate
bevy_seedling 0.8(Bevy 0.19 only, see Gotchas).
Use Bevy's built-in entity-based audio for straightforward clips, loops, playback control, and simple spatial stereo. Add an application mixer policy for categories and transitions. Move to an audio-graph library only when the measured/design requirement exceeds that boundary.
Canonical pattern
use bevy::{audio::Volume, prelude::*};
#[derive(Component)]
struct Music;
fn start_music(mut commands: Commands, assets: Res<AssetServer>) {
commands.spawn((
Name::new("Exploration music"),
Music,
AudioPlayer::new(assets.load("audio/exploration.ogg")),
PlaybackSettings::LOOP.with_volume(Volume::Decibels(-9.0)),
));
}
fn mute_music(mut sinks: Query<&mut AudioSink, With<Music>>) {
for mut sink in &mut sinks {
sink.mute();
}
}Bevy inserts AudioSink after non-spatial playback begins and SpatialAudioSink for
spatial playback. Query the sink for live volume, mute, pause, speed, position, seek,
and stop. Changing PlaybackSettings or GlobalVolume does not update audio that is
already playing.
PlaybackSettings::{ONCE, LOOP, DESPAWN, REMOVE} define completion ownership. An
ONCE player cannot simply replay after its sink drains; remove/reinsert the audio
components or spawn a new player. Removing a sink while AudioPlayer remains causes
the unchanged source to start again.
Gotchas
PlaybackSettingsandGlobalVolumeaffect initial playback, not existing sinks.- A sink appears only after playback starts; query it optionally.
- Drained
ONCEplayback is not replayable without replacing audio components. - Removing a sink while its unchanged player remains restarts the source.
- Built-in spatial audio is stereo panning, not HRTF or a general effects graph.
- 0.20:
bevy_seedling 0.8.0pins Bevy^0.19; no 0.20-compatible release exists (crates.io, 2026-11-03). Adding it to a 0.20 app fails with twobevy_ecsversions. 0.20: observers lost the bundle generic. React to a sink appearing with
On<Add<AudioSink>>(0.19 output writesOn<Add, AudioSink>):fn on_sink_ready(add: On<Add<AudioSink>>, mut sinks: Query<&mut AudioSink>) { if let Ok(mut sink) = sinks.get_mut(add.entity) { sink.set_volume(Volume::Decibels(-6.0)); } }- 0.20:
Name: From<&'static str>only;Name::new(string.to_owned())for runtime text. - 0.19: the
audiofeature is no longer implied by2d/3d/ui. Withdefault-features = false, addaudio(andvorbis/mp3/flacas needed) orAudioPlayerdoes not exist.
Spatial audio boundary
fn spawn_spatial_loop(mut commands: Commands, assets: Res<AssetServer>) {
commands.spawn((
SpatialListener::new(0.2),
Transform::default(),
));
commands.spawn((
AudioPlayer::new(assets.load("audio/generator.ogg")),
PlaybackSettings::LOOP.with_spatial(true),
Transform::from_xyz(4.0, 0.0, 0.0),
));
}Keep exactly one SpatialListener; attach it to the authoritative listener/camera
pose. Configure SpatialScale when world units do not match audio distance. Built-in
spatialisation is simple left/right stereo panning: it does not provide HRTF or a full
3D acoustic model.
Mix groups and transitions
Built-in audio has no general bus/effects graph. Model categories (Master, Music,
Sfx, Dialogue, Ambience, Ui) as application state and tag player entities.
Compute effective gain from master × group × transition/ducking × source gain, then
write sinks. Store sliders in decibels or a perceptually useful curve, not a raw linear
UI that puts most useful range in a few pixels.
For music/ambience changes, overlap old and new loops and crossfade using real/virtual time according to pause policy. Do not despawn the old entity until its sink reaches silence. Preload assets before a latency-critical transition, and define what happens when a new track is not ready.
Browser rule
Browsers commonly block audible playback until a user activation. Treat audio unlock as an explicit app state: let the first intentional input resume/start audio, keep the request pending if blocked, and present a usable muted/unlock control. Test refresh, tab background/foreground, device change, and mobile browsers; startup playback is not evidence that every browser will allow it.
Built-in versus Seedling
Choose built-in Bevy audio for simple playback/control/spatial panning.
bevy_seedling 0.8 is the graph-based option for buses/effects, pooled emitters,
sample-accurate scheduling, richer routing, or HRTF through its Firewheel stack. It
pins Bevy ^0.19: on Bevy 0.20 stay on built-in audio until a Seedling release
declares 0.20 support, and verify on crates.io before adding the dependency. HRTF is not a default feature; enable Seedling's hrtf feature (and
hrtf_subjects only when all embedded subjects are needed). Disable Bevy's built-in
audio feature when using Seedling so the two backends/types do not compete. Pin and
test the exact library release and platform.
Choose the relevant deep dive
| Problem | Read |
| Players, playback modes, sinks, replay and cleanup | Built-in audio |
| Mix model, crossfades, ducking, pause and asset lifetime | Mixing, lifecycle, and transitions |
| Spatial limits, browser unlock, accessibility and Seedling boundary | Spatial, web, and Seedling |
Review checklist
- Playback entity ownership and completion mode are intentional.
- Runtime changes target the sink, not
PlaybackSettings. - Group/master changes update already-playing sinks without losing source gain.
- Transitions handle delayed assets, rapid state changes, pause, and entity cleanup.
- Exactly one listener exists and scale/pose follow the intended viewpoint.
- Browser audio unlock/failure is visible and recoverable.
- Dialogue has captions and important audio cues have non-audio equivalents.
- Headless tests exercise mixer/state logic without requiring an audio device.
See also
bevy-a11y— captions, cue alternatives, dynamic range, and controls.bevy-assets— load state, handles, and asset lifetime.bevy-testing— deterministic mixer/transition tests.bevy-migration-0-19-to-0-20—On<Add<T>>,Name, feature changes.- Bevy audio module
bevy_seedling 0.8
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

