Quick answer: Audio editors handle loop points by crossfading internally. Godot plays the raw samples, so any waveform discontinuity at the loop boundary produces an audible click.
Here is how to fix audio popping clicking between loops Godot. Your background music loops perfectly in your audio editor but plays an audible pop or click at the loop point in Godot. This jarring artifact breaks immersion and makes your game sound unfinished. The fix depends on your audio format and how Godot handles loop boundaries.
The Symptom
A sharp click, pop, or thump sound occurs at the exact moment the audio stream restarts from the beginning. This is most noticeable with music loops but can also affect looping ambient sounds and sound effects. The pop may be subtle on some speakers but very obvious on headphones.
What Causes This
Audio pops at loop points are caused by a discontinuity in the waveform. When the last sample of the audio and the first sample differ significantly, the speaker cone jumps instantly between two positions, producing an audible click. This happens when:
- The audio file has silence padding — MP3 encoders add padding frames at the start and end of files. OGG Vorbis does not.
- The loop point is not at a zero crossing — The waveform is not at zero amplitude where the loop restarts.
- The AudioStreamPlayer loop property is misconfigured — The stream plays through trailing silence before restarting.
The Fix
Step 1: Use OGG Vorbis instead of MP3. OGG files support seamless looping natively without encoder padding. Export your audio as .ogg from your audio editor.
# In the Import tab for your .ogg file:
# Loop = true
# Loop Offset = 0.0 (or your desired loop start point)
Step 2: Ensure the waveform starts and ends at zero crossing. In your audio editor, zoom into the start and end of the file. Both should cross the center line (zero amplitude). Trim the file so the loop point is seamless.
Step 3: Enable loop mode on the AudioStream resource. Select the audio file in the FileSystem dock, open the Import tab, check Loop, and click Reimport.
# Programmatically set loop mode
var stream = load("res://audio/music.ogg")
stream.loop = true
$AudioStreamPlayer.stream = stream
$AudioStreamPlayer.play()
Step 4: For MP3 files you cannot replace, use AudioStreamPlayer with a crossfade technique. Start a second player slightly before the first ends and fade between them.
Related Issues
See also: Fix: Multiple Sounds Cutting Each Other Off in Godot.
See also: Fix: AudioStreamPlayer Not Playing Sound.
OGG Vorbis, zero crossings, seamless loops.