Loop Glitch Removal

When bouncing loops from a DAW such as Ableton Live, you may have problems with glitches at the loop point.

Exporting from Ableton Live
When Ableton Live exports audio with the 'loop' enabled, it first runs through the loop once, and then bounces the second loop to disk. This will work well with certain effects such as delay from the end of the first loop that gets mixed with the start of the second loop.

However, this is only guaranteed to not create a glitch if instruments don't play over the loop boundary and any effect that isn't time-invariant.

A couple of very simple examples that will contain glitches:


 * Constant sine wave of almost any frequencies
 * A chorus or flanger effect where the LFO isn't synchronized to song tempo

Examples of time-invariant effects that should be OK for looping:


 * Any delay effect
 * Distortion
 * Reverbs as long as chorus or similar effects are disabled
 * Equalizers
 * Compressors are inherently time-varying, but as long as the attack and release are short enough, the same input should produce the same output

During the production of 140, I spend a lot of time carefully working around these limitations. There are easier options, though, and I will attempt to descibe a few below.

Approaches to Looping
My basic approach to creating glitch-free loops has been:


 * Export non-looped audio of double the length of the final loop. We name the first half of the exported audio A, and second half B
 * We mix the two halves A and B together, starting with playing only B and then at some point cross-fading to A
 * The end of A loops perfectly into B, as these were originally stitched together

With this approach, we need to figure out:


 * the time and duration of the crossfade, and
 * the crossfade curve

Sync-points
A certain class of loops have a sync point, a point in time in the loop where A and B are audibly the same. In this case, we can just switch from B to A at the sync point, with no crossfade. See Sync-point Looping.

Cross-fades
The more general class of loops will require a crossfade to avoid glitches. I have experimented with crossfades that follow this formula:

out = in_A * t^p + in_B * (1 - t) ^ p

where out is the output sample and in_A and in_B the input samples at time t (which is assumed to be in the interval 0..1), and p is the fade curve:

p = 0.5 equal power fade (at t=0.5, inputs are multiplied with sqrt(0.5) ~ 0.707, ~ -3dB) p = 1.0 linear fade      (at t=0.5, inputs are multiplied with 0.5,               ~ -6dB) p = 2.0 exponential fade (at t=0.5, inputs are multiplied with 0.25,              ~ -12dB)

The equal power fade preserves signal power and generally sounds best.

To avoid having to do this work manually, I created a command-line tool named Loopify.