/bevy-skills:bevy-audiofrom bevy-skills
Implements audio in Bevy 0.20 using `AudioPlayer`, sinks, spatial listeners, mix groups, and transitions. Covers browser gesture restrictions and `bevy_seedling` compatibility.
Ships in bevy-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
AudioPlayer and sink components.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.
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.
PlaybackSettings and GlobalVolume affect initial playback, not existing sinks.
A sink appears only after playback starts; query it optionally.
Drained ONCE playback 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.0 pins Bevy ^0.19; no 0.20-compatible release exists
(crates.io, 2026-11-03). Adding it to a 0.20 app fails with two bevy_ecs versions.
0.20: observers lost the bundle generic. React to a sink appearing with
On<Add<AudioSink>> (0.19 output writes On<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 audio feature is no longer implied by 2d/3d/ui. With
default-features = false, add audio (and vorbis/mp3/flac as needed) or
AudioPlayer does not exist.
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.
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.
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.
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.
| 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 |
PlaybackSettings.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_seedling 0.8What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
bevy, game-audio, audio-sink, spatial-audio, playback-settings
32 skills in this plugin
/bevyUse when starting any Bevy task, choosing between Update and FixedUpdate, picking Cargo feature flags, or recalling which sibling skill covers ECS, assets, rendering, UI, or migration. Routes to the right Bevy 0.20 skill and pins the engine version for downstream snippets./bevy-a11yUse when designing or auditing high-standard video-game accessibility in Bevy 0.20, integrating screen readers and focus navigation, supporting adaptive controllers and complete remapping, implementing captions or audio description, checking contrast and motion safety, or building disabled-player test evidence./bevy-animationUse when wiring `AnimationPlayer` + `AnimationGraphHandle`, building an `AnimationGraph` from glTF clips, blending state-driven animations with `AnimationTransitions::play`, isolating body parts with `AnimationMask`, firing gameplay sync via `#[derive(AnimationEvent)]` + `On<E>` observers, tweening with `AnimatableCurve` / `EaseFunction` / `CubicSegment::new_bezier_easing` from `bevy::curve`, or applying the 12 Basic Principles of Animation to 3D characters in Bevy 0.20.npx claudepluginhub chrisgliddon/bevy-skills --plugin bevy-skillsOther plugins' skills for the same job