
Godot Audio
Play and mix audio in Godot 4.7: AudioStreamPlayer (2D/3D variants), audio buses with...
Install
npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill godot-audio -g -a claude-code -y- Repository
- gamedev-skills/awesome-gamedev-agent-skills6.4k
- Category
- Media
- Updated
- 8d ago
- License
- Apache-2.0
- Context cost
- Lightabout 1,278 tokens
- Runs scripts
- No, instructions only
What it does
Play and mix audio in Godot 4.7: AudioStreamPlayer (2D/3D variants), audio buses with volume/mute and effects, music vs SFX routing, db/linear volume, and precise sync-to-beat playback timing. Use when playing sounds or music in a Godot project, routing AudioStreamPlayer nodes to buses, adjusting bus volume via AudioServer, or syncing gameplay to the beat.
Godot Audio (4.x)
Play SFX and music, route them through buses, control volume in decibels, and time gameplay to the beat. Targets Godot 4.7.
When to use
- Use when playing sound effects or music, routing audio to buses (Master/Music/SFX), adjusting volume/mute from code, adding bus effects (reverb, compressor), positional 3D audio, or syncing events to music.
When not to use: engine-agnostic audio design (adaptive music structure, mixing
philosophy, ducking patterns) → audio-design; importing/encoding assets outside Godot.
Core workflow
- Pick the player node:
AudioStreamPlayer, non-positional (music, UI, global SFX).AudioStreamPlayer2D/AudioStreamPlayer3D, positional; volume/pan from distance.
- Assign an
AudioStreamtostream(.oggfor music/loops,.wavfor short SFX) andplay(). Setautoplayfor music that starts with the scene. - Route to a bus. Set the player's
busto a named bus (e.g."Music","SFX"). Define buses in the Audio panel (bottom dock); each can have volume, mute, solo, and effects. - Control volume in dB, not linear (audio is logarithmic).
0 dB= unchanged,-80 dB≈ silent. Convert withlinear_to_db/db_to_linear, or use the linear helpers (volume_linearon players,AudioServer.set_bus_volume_linear()), which convert for you. - Drive volume/mute from code with
AudioServerby bus index. - For rhythm, compute precise playback time using output latency compensation.
Patterns
1. One-shot SFX (fire-and-forget)
@onready var sfx: AudioStreamPlayer = $Sfx # stream assigned in the editor
func play_jump() -> void:
sfx.pitch_scale = randf_range(0.95, 1.05) # slight variation avoids fatigue
sfx.play()
# For overlapping copies, raise sfx.max_polyphony (default 1), use an
# AudioStreamPolyphonic stream, or spawn short-lived players and free on `finished`.


