Master Invictus

Guide

How to loop an ambient bed without a click

4 December 2026

A loop clicks when the last sample of the file and the first sample do not meet, and it gaps when the file or the player adds a moment of silence at the join. So a clean loop needs two things: a file whose end flows into its start, and a player that goes from the last sample straight back to the first. Use an Ogg Vorbis or WAV file made to loop, and switch on looping where the engine imports the file.

Why a loop clicks

Sound is a wave. If the wave is high at the end of the file and low at the start, the speaker has to jump between the two in an instant, and that jump is heard as a click. Cutting a piece out of a longer recording nearly always leaves such a jump. A fade out and a fade in removes the click, but the bed then dips in volume every time it comes round, which is just as easy to hear.

Why a loop gaps

MP3 is the usual cause. The format stores sound in fixed blocks, and encoding adds a short stretch of silence at the start and pads the last block at the end. Played once, nobody notices. Played on repeat, that silence comes round every time. Some players remove it and many do not. Ogg Vorbis and WAV store the exact length, so a loop made in either format can join sample to sample.

How to make a file loop

  1. Record or build a bed longer than you need.
  2. Cut a few seconds from the end and lay that piece over the start.
  3. Fade the moved piece out while the start fades in, so the two cross. The old end now flows into the old start, and the new end is a point that was continuous in the original.
  4. Trim both ends at that cut, export as Ogg Vorbis or WAV, and listen to the join on repeat with headphones.

A steady bed, such as wind, rain or a machine hum, hides a crossfade well. Anything with a clear event in it, such as one thunderclap, gives the loop away each time it returns, so keep single events out of a bed and play them on top as separate sounds.

Looping in Godot 4

For an Ogg Vorbis file, double-click it in the FileSystem dock to open the Advanced Import Settings, tick Loop, and reimport. Loop Offset in the same window sets where playback returns to, and zero means the start. For a WAV file, select it, open the Import dock, and set Loop Mode to Forward. Then put the file on an AudioStreamPlayer and call play() once. The Godot manual suggests Ogg Vorbis for music and long sound effects, and a two-minute bed is one.

Looping in a browser

An audio element with the loop attribute is the short way, and in some browsers it leaves a small gap at the join. The Web Audio API loops a decoded buffer from its last sample to its first:

const context = new AudioContext();
const file = await fetch("/audio/machine-room.ogg");
const buffer = await context.decodeAudioData(await file.arrayBuffer());
const source = context.createBufferSource();
source.buffer = buffer;
source.loop = true;
source.connect(context.destination);
source.start();

Browsers only start audio after the visitor has clicked or tapped, so run this from a button.

Looping in a video editor

Lay copies of the file end to end on one track. If the editor shows a hairline of silence between two MP3 copies, overlap them by a fraction of a second, or use the Ogg or WAV copy if the editor opens it.

Check the loop before you ship

  • Listen to the join at least five times in a row, on headphones, at a normal level.
  • Listen for a rhythm. A loop of a few seconds becomes a pattern the ear learns, and one of a minute or more does not.
  • Play it under the game's other sounds. A bed should sit well below speech and effects.

Each bed in Cold Relay Ambience: 16 Seamless Ambient Beds is exactly 120 seconds and already loops, so the steps above come down to ticking Loop.

Questions

Why does my MP3 loop have a gap?

Encoding an MP3 adds a short silence at the start of the file and pads the end. A player that does not remove it plays that silence every time the loop comes round. Use an Ogg Vorbis or WAV copy for looping.

How long should an ambient loop be?

Long enough that the ear cannot learn it. A loop of a few seconds is heard as a rhythm. A minute or more of a steady bed, with no single stand-out event in it, is hard to hear as a loop.

How do I loop an Ogg file in Godot 4?

Double-click the file in the FileSystem dock to open the Advanced Import Settings, tick Loop and reimport. Then play it once from an AudioStreamPlayer and it repeats until stopped.

All guides

Back to the home page