Overview
Godot provides a powerful and flexible audio system built around theAudioServer, which handles all audio processing, mixing, and output. The system supports multiple audio formats, real-time effects, and spatial audio for 2D and 3D games.
The AudioServer uses a bus-based architecture similar to professional audio software, allowing complex audio routing and effects chains.
AudioServer
TheAudioServer is a singleton that manages all audio in your game. It provides low-level audio access and controls the audio bus system.
Key Features
- Audio buses - Route audio through different channels with independent volume and effects
- Real-time effects - Apply effects like reverb, delay, EQ, and compression
- Flexible routing - Send audio from one bus to another
- Sample rate control - Access to mix rate and output latency
- Device selection - Choose input/output audio devices
Getting Audio Information
Audio Buses
Audio buses are channels that audio streams flow through. Each bus can have:- Independent volume control
- Multiple audio effects
- Routing to other buses
- Solo/mute states
Working with Buses
Volume Control
AudioServer works with decibels (dB) for volume:AudioStreamPlayer
TheAudioStreamPlayer node plays audio streams without positional audio:
stream- The AudioStream resource to playvolume_db- Volume in decibels (offset from stream volume)pitch_scale- Playback speed/pitch multiplierbus- Target audio bus nameautoplay- Start playing when entering the treemax_polyphony- Maximum simultaneous sounds
play(from_position)- Start playbackstop()- Stop playbackseek(to_position)- Jump to a position in secondsget_playback_position()- Get current position in seconds
AudioStreamPlayer2D and AudioStreamPlayer3D
For positional audio in 2D and 3D games:AudioStreamPlayer2D
AudioStreamPlayer3D
3D audio automatically handles attenuation (volume falloff) based on distance and supports different attenuation models.
Playback Control
Basic Playback
Polyphony
Play multiple sounds simultaneously from one player:Monitoring Playback
Bus Routing
Route audio from one bus to another:Peak Volume Monitoring
Monitor audio levels on buses:Best Practices
Use appropriate buses
Use appropriate buses
Separate audio into different buses (Music, SFX, Voice) to allow independent volume control and effects.
Preload frequently used sounds
Preload frequently used sounds
Load short sound effects at startup to avoid loading delays during gameplay.
Use streaming for music
Use streaming for music
Large audio files (music, voice) should use streaming formats like OGG Vorbis to reduce memory usage.
Consider polyphony limits
Consider polyphony limits
Set appropriate
max_polyphony values to prevent audio overload while allowing necessary overlaps.See Also
Audio Streams
Learn about audio formats and stream types
Audio Effects
Add effects like reverb, delay, and EQ to audio buses
Interactive Music
Create dynamic, adaptive music systems