Skip to main content

Overview

Godot supports multiple audio formats through the AudioStream system. Each format has different characteristics suited for specific use cases, from compressed music files to uncompressed sound effects.
AudioStream is the base class for all audio streams. Specific formats like WAV, OGG, and MP3 are implemented as specialized classes.

Supported Audio Formats

AudioStreamWAV

Uncompressed PCM audio, best for short sound effects: Advantages:
  • No decompression overhead (instant playback)
  • Perfect for sound effects
  • Supports loop points
  • Can be generated at runtime
Disadvantages:
  • Large file size
  • Not suitable for music or long audio
Key Properties:
  • format - Audio format (8-bit, 16-bit, IMA ADPCM)
  • loop_mode - Disabled, Forward, Ping-Pong, Backwards
  • loop_begin - Loop start point in samples
  • loop_end - Loop end point in samples
  • mix_rate - Sample rate in Hz
  • stereo - Mono or stereo

AudioStreamOggVorbis

Compressed audio format, ideal for music: Advantages:
  • Excellent compression ratio
  • Good quality
  • Supports looping
  • Widely supported
Disadvantages:
  • CPU cost for decompression
  • Lossy compression
OGG Vorbis is the recommended format for music and long audio files due to its balance of quality and file size.

AudioStreamMP3

MP3 audio support: Advantages:
  • Universal format
  • Good compression
  • Works well for voice and music
Disadvantages:
  • Slightly worse quality than OGG at same bitrate
  • Higher CPU usage for decoding
  • Licensing considerations (less relevant now)

Format Comparison

Looping Audio

Basic Looping

Most audio formats support loop mode:

Loop Points (WAV)

For WAV files, you can set precise loop points:

AudioStream Properties

Getting Stream Information

Metadata and Tags

Access audio file metadata:

AudioStreamGenerator

Generate audio procedurally at runtime:
AudioStreamGenerator is useful for synthesizers, dynamic sound effects, or audio visualization.

AudioStreamRandomizer

Randomly play variations of sounds:

AudioStreamPlayback

The AudioStreamPlayback represents an active playback instance:

Importing Audio Files

Import Settings

When importing audio files in Godot, you can configure: For WAV files:
  • force/8_bit - Reduce to 8-bit audio
  • force/mono - Convert to mono
  • force/max_rate - Limit sample rate
  • edit/trim - Remove silence
  • edit/normalize - Normalize volume
  • edit/loop_mode - Set loop behavior
  • edit/loop_begin - Loop start point
  • edit/loop_end - Loop end point
For OGG/MP3 files:
  • loop - Enable looping
  • loop_offset - Loop start offset in seconds
For mobile platforms, consider converting stereo to mono and reducing sample rates to save memory and improve performance.

Best Practices

Use WAV for short sound effects (< 1 second), OGG Vorbis for music and ambient sounds, and consider MP3 for voice dialogue.
Use appropriate bitrates: 128-192 kbps for music, 96-128 kbps for ambient, 64-96 kbps for voice.
Set proper loop points in your audio editor before importing to ensure seamless loops.
Convert to mono when stereo isn’t necessary to reduce file size and memory usage.
Ensure consistent volume across all audio files to avoid manual volume adjustments.

See Also

Audio Overview

Learn about AudioServer and basic playback

Audio Effects

Apply effects to audio buses

Interactive Music

Create dynamic music systems