PDFMove
Why Do Gaps and Sample Rate Problems Appear When Merging Audio?
Guide

Why Do Gaps and Sample Rate Problems Appear When Merging Audio?

8 min read

When you merge two audio files you may hear either a short silence or an unpleasant "click" at the transition point. These aren't random errors; they're structural consequences of audio formats and digital audio processing. This article explains why they happen and how they're prevented.

Problem 1: encoder delay and padding

Lossy audio codecs process audio in blocks. In MP3 a block is 1152 samples (about 26 milliseconds at 44.1 kHz); in AAC it's usually 1024 samples.

That block structure creates two kinds of gap:

Encoder delay. Because of how the encoder works, a delay of a few hundred samples appears at the start of the output. In MP3 that's typically 576 or 1105 samples. A silence not present in the source gets added to the start of the file.

Padding. If the audio duration doesn't divide evenly into the block size, the last block comes up short and the encoder fills it with silence. A recording of 3 minutes 12.3 seconds, for example, doesn't land on a whole number of blocks and a few hundred samples of silence get added at the end.

The result: every MP3 file has short silences at its start and end that aren't in the source. You don't notice when listening to a single file. But when you merge ten tracks one after another, that gap is audible at every transition.

How gapless playback solves it

Because this problem is known, a solution was added to the formats: the encoder records the amount of delay and padding it added into the file.

In MP3 that information is stored in the LAME tag (or Xing/Info header). It sits in the file's first frame and carries values like "576 samples of delay at the start, 1234 samples of padding at the end."

In AAC/M4A similar information lives in the iTunSMPB metadata field.

Players that can read it skip those samples during playback and provide gapless playback.

But there's an inconsistency here: not every player reads that information. The same album can play gaplessly in one player and with a gap between every track in another. Some converters and editors also don't preserve or update that tag.

What that means for merging

There are two different approaches to merging audio files, and their gap behavior differs.

Merging by stream-copying: the encoded data is appended as it is. Quality is preserved but the delay and padding gaps are preserved too. There's a short silence at every transition.

Merging by re-encoding: all the files are decoded to PCM, appended, and then encoded in a single pass. The intermediate gaps disappear entirely because there's only one encoding operation — only the final file has delay/padding at its start and end.

There's a quality trade-off: re-encoding adds another loss on lossy sources.

The cleanest method: prepare the source files in a lossless format (WAV, FLAC), merge them losslessly (no gaps appear because PCM has no block structure), then encode the final file to the target format once.

That's the standard workflow followed when preparing audiobooks and albums.

Problem 2: sample rate mismatch

Sample rate specifies how many audio measurements are taken per second. Common values:

| Rate | Typical use | |---|---| | 44,100 Hz | CD standard, music | | 48,000 Hz | Video, professional audio | | 32,000 Hz | Some broadcast applications | | 22,050 Hz | Low-quality speech | | 96,000 Hz | High-resolution audio |

Merging files at different rates without a proper conversion causes a serious problem: the second file plays at the wrong speed.

The reason is simple: if a file was recorded as "48,000 samples per second" and the player plays it as "44,100 samples per second," the audio slows by about 9% and the pitch drops. Speech gets deeper, music goes flat.

The same in the other direction: playing a 44.1 kHz file as 48 kHz speeds it up and raises the pitch.

Resampling

Proper tools solve this with resampling: the file's sample sequence is mathematically converted to the new rate.

That's an operation requiring interpolation. To produce 48,000 samples from 44,100, the intermediate values are computed by interpolation.

A well-done resample is nearly lossless but not entirely lossless. Depending on the quality of the filter used, small changes can occur at very high frequencies.

The practical advice: try to prepare the files you'll merge at the same sample rate. If you can control this at the recording stage, you eliminate the need for conversion later.

Problem 3: channel mismatch

If one file is mono and another stereo, merging needs a common structure.

Converting mono to stereo: the same signal is copied into two channels. There's no loss but the file size doubles and no real stereo image is created.

Converting stereo to mono: the two channels are summed and divided by two. The stereo information is permanently lost. And on recordings with phase problems (where the two channels are inverses of each other) the sound can weaken or disappear.

With speech content, merging to mono usually makes sense — the file halves and the loss is negligible. With music, stereo should be preserved.

Problem 4: zero crossings and clicks

An audio waveform oscillates above and below the zero line over time. A zero crossing is the moment the wave is at exactly zero.

When two pieces of audio join:

  • If both are at a zero crossing: the join is smooth.
  • If one was cut at a wave peak: a sudden value jump occurs at the join.

A sudden jump mathematically contains very high frequency components and is heard by the ear as a sharp "click."

This is a common problem when cutting and joining recordings by hand. Absolute silence is rare in recordings; even background noise is a waveform and gets cut at a random point.

The solution: crossfading

Crossfading briefly fades down the end of the first piece while briefly fading up the start of the second. So instead of a sudden jump you get a smooth handover.

The choice of duration matters:

| Duration | Effect | |---|---| | 5-20 ms | Prevents clicks, imperceptible to the ear | | 50-200 ms | Smooth transition, slightly noticeable | | 1-3 seconds | A musical transition, a deliberate effect |

If you only want to prevent clicks, 10-20 milliseconds is enough and that duration is imperceptible to the human ear. You lose nothing from the content.

If you're preparing a mixtape, 2-5 second transitions give a professional result — but that's now an artistic choice rather than a technical fix.

Problem 5: level differences

Merging doesn't touch audio levels. If recordings from different sources are at different levels, the listener has to adjust the volume at every transition.

There are two different approaches to measuring level:

Peak level: the highest value the waveform reaches. It's a simple measure but doesn't reflect perceived loudness. A quiet recording containing a short burst of noise can have a high peak value but sound quiet.

LUFS (Loudness Units Full Scale): a measure that accounts for the frequency sensitivity of human hearing and averages over time. That's the method used in broadcast and podcast standards.

Common targets:

| Medium | Target | |---|---| | Podcast | -16 LUFS (stereo), -19 LUFS (mono) | | Music streaming services | -14 LUFS | | Television broadcast | -23 LUFS |

Normalizing the pieces you'll merge to the same LUFS target prevents level jumps at the transitions.

The right workflow

An ordering that prevents all of the problems above:

1. Convert all sources to a lossless format (WAV or FLAC). On lossy sources this adds no loss; it just prepares a working space.

2. Match the sample rate and channel count. Make them all 44.1 kHz stereo, or all 48 kHz mono.

3. Normalize the levels. Set a common LUFS target.

4. Merge. Because there's no block structure in a lossless format, no gaps appear.

5. Apply short crossfades if needed. 10-20 ms prevents clicks.

6. Encode the final file to the target format once. One encode, one loss.

7. Add the tags and chapter markers if any.

That flow looks laborious, but it makes a difference in work where you want a quality result, like an audiobook, an album or a long podcast.

In summary

The gap and click problems encountered when merging come from the structure of the formats. Because lossy codecs work on blocks, there are delay and padding samples at the start and end of every file; players can skip them using tag information but not every player does. A sample rate mismatch, if not corrected, causes playback at the wrong speed. Pieces not cut at a zero crossing create a sudden jump at the join point that's heard as a "click" — a 10-20 millisecond crossfade solves that entirely. The cleanest approach is merging in a lossless format and encoding the final file in a single pass.

Frequently Asked Questions

Why is there silence at the start and end of MP3 files?

Because the MP3 encoder processes audio in fixed-length blocks, and if the source duration doesn't divide evenly into those blocks it adds padding samples at the end. The encoder's own processing delay also puts a few hundred samples of silence at the start of the file. That's a structural consequence of the format, and good encoders record those values in a tag block so players can trim them.

How does gapless playback work?

The encoder writes the amount of delay and padding it added into the file as an information block (the LAME tag in MP3, iTunSMPB in AAC). Players that can read it skip those samples during playback and no gap remains between tracks. In players that can't read that information you hear a gap — the same album can play gaplessly in one player and with gaps in another.

What exactly happens if I merge 44.1 kHz and 48 kHz files?

Without a proper resample, the second file plays at the wrong speed. Interpreting a 48 kHz file as 44.1 kHz slows the audio by about 9% and lowers the pitch — speech gets deeper, music goes flat. Proper tools solve this by resampling automatically, though that operation itself carries a very small quality effect.

What is a zero crossing, and why does it matter?

An audio waveform oscillates above and below the zero line over time. A zero crossing is the moment the wave is at exactly zero. If two pieces of audio join at those points, the transition is smooth. But if one piece is cut while at a wave peak and the other starts at a different value, a sudden jump occurs, and that's heard as a 'click.'

Try this out right away with Ses Birleştir.

Try Ses Birleştir