Articles / Image and audio basics

Why Looping BGM Clicks or Gaps and How to Fix It: What Differs Between MP3, OGG, and WAV

A guide to why a looping track breaks at the seam, separating causes that come from the audio format from causes that do not.

What happens at the loop seam

Background music in games often loops: when it reaches the end, it returns to the beginning and repeats. At the moment it jumps back, you may hear a brief stretch of silence or a small “click.”

There is more than one cause. They fall into two broad groups:

  • Causes from how the audio format works: Because of how compression works, extra silence that is not part of the original sound ends up at the start or end of the track.
  • Causes in the audio data itself: The end and the start of the loop do not connect in the waveform, so the sound jumps.

This article explains the two separately. The format is not always the cause, so we cannot say flatly that “MP3 cannot be used” or that “OGG is always fine.”

Cause 1: Compression adds silence at the start and end

Lossy formats such as MP3, AAC, and Vorbis process audio in fixed-length chunks called frames. As a result, a converted file gets extra parts like these:

  • Encoder delay: A near-silent stretch added at the start of the track because of how encoding works.
  • Padding: Filler at the end of the track when its length is not an exact multiple of the frame length.

If information about how to remove these extra parts is stored correctly, and the player reads that information and applies it, no silence appears at the seam. If either is missing, silence remains at the loop seam.

MP3

The MP3 format has no defined way to record the amount of delay or padding, and the delay also differs from encoder to encoder. To work around this, the LAME encoder writes its own information, known as the LAME tag, into the first frame of the file, recording the delay and padding. Players that support it read the tag and remove the extra parts.

So whether the seam of an MP3 is noticeable depends on two things:

  • Whether the delay and padding information was written into that MP3.
  • Whether the player, such as a game engine or browser, reads that information and applies it.

An older version of the Unity manual (4.x) also states, in essence, that standard MPEG encoders introduce a short silence at the loop point, heard as a brief click or pop. Note that this statement comes from an old version. Check in your own environment whether the same symptom appears in the latest version.

OGG (Vorbis)

Vorbis also compresses in frames, like MP3, but the Ogg structure has a way to state exact start and end positions in samples. According to an explanation by the Vorbis developers, each page carries a running sample count called the granule position, and on the last page the decoder discards any extra samples decoded beyond the real length. In terms of the specification, the original length can be expressed exactly without adding extra silence.

This is why OGG is considered well suited to looping. Keep in mind, though, that this describes what the specification allows. It does not guarantee that every encoder and player handles it correctly.

Opus

The Ogg Opus specification (RFC 7845) puts a value called pre-skip in the header, which tells the decoder how many samples to discard at the start. It also defines a way to trim extra samples at the end through the granule position of the last page (End Trimming). As with OGG (Vorbis), the length can be handled exactly according to the specification. Some game engines cannot import Opus, so check what your environment supports.

AAC / M4A

AAC also begins with a stretch of silence (priming samples) whose length varies by encoder. The amount is recorded in information such as iTunes-style metadata (iTunSMPB) or the MP4 edit list. Apple’s QuickTime File Format documentation also describes ways to represent encoder delay explicitly, using an edit list and related structures. If the player does not read this information, silence remains at the start.

WAV

WAV stores the audio data as it is. Since there is no compression delay or padding, the format itself does not normally cause silence at the seam.

Summary of tendencies by format

FormatHow the length is handledEffect on looping
WAVStores the audio data as is, so there are no extra parts.Unlikely to add silence because of the format.
OGG (Vorbis)The specification can express start and end positions to the sample.Considered unlikely to add silence at the seam.
OpusExpressed with pre-skip and end trimming.Similar to OGG. Check what your environment supports.
MP3The standard has no way to record it; LAME and others add their own tag.Silence appears if the information is missing or the player does not read it.
AAC / M4AExpressed with metadata such as iTunSMPB or an edit list.Depends on whether the player reads it.

This table shows general tendencies based on format specifications and published documents. What actually happens depends on the encoder, the game engine version, and the playback environment.

Cause 2: The waveform does not connect at the loop point

The cause can also be in the audio data itself, regardless of format. If the height of the waveform at the end of the loop is very different from the height at the start, the sound jumps at the moment it returns, and you hear a click. This can happen even when you save as WAV.

Common causes include:

  • Cut mid-phrase: The waveform was cut at a position unrelated to beats or bars.
  • Tail cut off: The final reverb or cymbal tail does not overlap with the start of the loop and stops abruptly.
  • Margins at the ends: Silence remains at the start or end of the track.

Lossy compression changes the waveform slightly

Lossy compression such as MP3 and OGG discards information that is hard to hear, so the waveform is never exactly the same before and after conversion. Even when no silence is added because the file is handled correctly, the waveform at the loop seam could in theory differ slightly from the original WAV. In most cases you cannot hear the difference, but for music where the seam is critical, listening to it yourself is important.

How engines handle it

Unity

According to the official Unity manual, when you import an audio file, Unity re-encodes it to a format suited to the build target. By default that format is Vorbis, and it can be changed per platform to ADPCM, MP3, and others. In other words, the format of the file before import does not simply become the final format.

For this reason, it is safest to import looping music from a lossless source (such as WAV) as it is and let Unity do the conversion. If you import material that is already an MP3, we could not find an explicit statement in the official manual about whether the silence at the start is removed on import. In that case, check it yourself.

An older version of the Unity manual (4.x) also lists a Gapless looping setting, for Android and iOS only, for preserving continuity at the seam when compressing a seamlessly looping source to MP3. We have not found this setting described in the current manual. Check whether your version’s Inspector has it.

Godot

The official Godot documentation says you can import WAV, Ogg Vorbis, and MP3. It suggests Ogg Vorbis for music and long sound effects and WAV for short repetitive sound effects, and describes MP3 as useful for mobile and web projects where CPU resources are limited, especially when playing several compressed sounds at once.

Loop settings also differ. For WAV, you can set both a loop start and a loop end. For Ogg Vorbis and MP3, you can set only the loop start (Loop Offset), not a loop end. The Advanced import dialog in Godot lets you adjust the loop point with a preview.

How to fix it: check in this order

  1. Prepare the source as WAV: Make the looping track as a lossless WAV. If you rebuild it from already compressed audio, it is harder to separate the effect of the format from the effect of the waveform.
  2. Align the loop point to beats or bars: Make the start and end of the track connect on a beat boundary. Instead of cutting off the tail, you can sometimes overlap it onto the start of the loop.
  3. Check the waveform at the seam: In an audio editor, join the end and start of the loop, zoom in on the join, and check that the waveform does not jump. If it does, move the cut to a point where the waveform crosses zero, or add a very short fade to smooth the join.
  4. Convert to the distribution format once, from the original WAV where possible: Avoid repeatedly re-converting lossy formats. If your game engine converts at import, import the WAV as it is.
  5. Listen in the real environment: Do not rely on the editor alone. Build the game and listen to the seam several times on the target device or browser.

When in doubt, try WAV (or an OGG converted from it) first and compare whether the silence at the seam disappears. That makes it easier to tell whether the cause is the format or the data.

A note on using our tool

Our Audio Format Converter converts audio to WAV, MP3, and OGG. However, it does not guarantee that a loop will connect perfectly at the seam. For looping music, we recommend importing the original data (WAV) into your game engine as it is and letting the engine do any needed conversion. If you use a file converted with the tool for looping, listen to the seam in your actual environment.

For the general differences between audio formats, see Audio Formats Compared: WAV, MP3, OGG, and More for Game Development.

This article is based on the official documentation for Unity and Godot Engine, RFC 7845 (Ogg Opus), an explanation of sample-granularity length in Vorbis by a Xiph.Org developer, Apple’s QuickTime File Format documentation, and an overview of gapless playback for MP3. Setting names and behavior in game engines may differ between versions. Be sure to also check the manual for the version you use.

← Back to all articles