Why your loop clicks
You trim a sustained note, set it to loop, and every repeat lands with a small tick. The cause is a gap of one sample at the point where the loop restarts, and that gap is visible in the waveform. The panels on this page play audio.
A loop is a splice
Looping is the oldest trick in sampling: record a second of a note, then play that second over and over so it sustains for as long as a key is held. The sampler plays forward to the loop end and then carries on from the loop start, with no fade, no pause, and no transition of any kind.
That instant return is the whole mechanism, and it's also the whole problem. The two points you picked were never next to each other in the recording, and now the sampler is going to play them as though they were.
The click is a jump
Zoom far enough into the splice and the cause stops being mysterious. The last sample before the loop end sits at one level; the first sample after the loop start sits at another. Between them, no time passes at all. The speaker cone is being asked to move from one position to another in a single sample period.
A jump that steep is an impulse rather than a pitch, and an impulse contains energy at every frequency at once. A click is exactly that. The bigger the step, the louder the click, which is why panel 2 reports the step as a number.
Zero crossings get you most of the way
The obvious fix is to make the two values match, and the easiest value to match is zero. Move both loop points to where the waveform crosses the centre line and the step nearly vanishes. Nearly, because a sampled signal doesn't land exactly on the crossing. The closest you can get is the frame nearest to it, which leaves a step of a few thousandths. Snap both points to crossings going the same direction too, both rising, or you'll match the values and still have the waveform heading upward on one side and downward on the other.
Try it in panel 2 and watch the step collapse. Then look at the shape that's left: a corner. The waveform arrives at the join on one slope and leaves on another. For a single sine wave looped over whole cycles that corner doesn't exist and zero crossings are a complete answer. For anything with harmonics it does, because every partial has its own phase and you can only line up one of them at a time. A corner is a softer artefact than a step, a thump rather than a tick, but on a held note repeating every half second you will hear the thump.
The crossfade
A better approach is to remove the splice rather than improve it. Instead of cutting from the tail to the head, overlap them: fade the tail down while the head comes up, so no single instant carries the whole transition.
The arithmetic is short. Call the loop L
frames long and the crossfade X frames. The
new loop is N = L − X frames, and its first
X frames are a blend of the original head fading in with the original tail fading out:
out[i] = in[i]·fadeIn[i] + in[N+i]·fadeOut[i] i < X
out[i] = in[i] X ≤ i < N
The last frame of the loop is now
in[N−1] and the first is
out[0] = in[N], because at
i = 0 the fade-in is zero and the fade-out is
one. Those two frames were adjacent in the original recording. The crossfade doesn't smooth the join over, it
removes it: the loop now restarts on the frame that always followed. From there the sound returns to the true
head over the next X frames.
Which curve, and why
Now the fades need shapes, and the obvious choice goes wrong. Crossfades in audio are usually equal-power: sine up, cosine down. Equal-power is the right curve for blending two unrelated recordings, such as two takes or a DJ transition, because unrelated signals add as power and sin² + cos² = 1 keeps the perceived level steady.
A loop's head and tail are not unrelated. They're the same note, a fraction of a second apart, often at nearly the same point in the waveform. Correlated signals add as amplitude rather than as power. At the middle of an equal-power fade both sides sit at 0.707, and 0.707 + 0.707 is 1.41, so the signal is 41% louder in the middle of the blend than it was on either side.
Running an 0.8-amplitude sine through an equal-power loop crossfade peaks at 1.13, which is over full scale and clips hard in a 16-bit file. The fix is to pick curves that sum to exactly one: sin² up, cos² down. Those curves are also smooth at both ends, unlike a linear ramp, which sums to one correctly but meets its endpoints at a corner. SampleStack uses sin²/cos² for both reasons.
How long should it be?
Long enough to span a few cycles of the lowest frequency in the sample. At 440 Hz a cycle is 2.3 ms, so tens of milliseconds is plenty; at 55 Hz a cycle is 18 ms and you'll want considerably more. In practice 20–100 ms covers most pitched material, and pads, strings and low drones want 100–500 ms.
A longer crossfade is not automatically better. The crossfade blends two different moments of a performance on top of each other, so a long fade averages away the detail that made the recording worth sampling: vibrato flattens out, bow noise smears, movement turns to mush. The sample also gets shorter by exactly the crossfade length, which matters when you're working to a hardware memory budget.
What a crossfade can't fix
A crossfade removes the discontinuity at the seam, but it can't improve the loop points you chose. If the head and tail sit at different points in a vibrato cycle, blending them produces two slightly different pitches sounding at once, and you'll hear beating or a brief chorus through the overlap. If the note is still getting quieter across the loop, you'll hear the level step down on each repeat even though nothing clicks.
So pick the loop region first, in the steadiest part of the note and ideally at the same phase of any vibrato, then crossfade.
Writing the crossfade into the audio, rather than storing loop points as metadata, has one practical
advantage: it works on any sampler. Plenty of hardware ignores the loop points in a WAV file's
smpl chunk. None of it can ignore the
samples themselves.
Doing this in SampleStack
Select a region in the expanded player, then Edit → Make Seamless Loop and choose a crossfade length from 10 ms to 500 ms. It runs the arithmetic above on a working copy, so you can listen to the result and keep it or discard it. Cue points inside the new length survive.
Questions
- Why does my looped sample click?
- Because the waveform jumps. When playback reaches the loop end it continues instantly from the loop start, and unless those two points happen to hold the same value and head in the same direction, the signal steps from one level to another in a single sample. A step that sharp contains energy at every frequency, which is what a click is.
- Doesn't snapping to zero crossings fix it?
- It fixes half of it. Putting both loop points at a rising zero crossing means the waveform is at the same value either side of the splice, so the step disappears. But the slope either side will still differ, and that corner is audible as a soft thump on anything with harmonics. A single sine wave looped over whole cycles is the one case where zero crossings alone are perfect.
- How long should a loop crossfade be?
- Long enough to cover a few cycles of the lowest note in the sample, which usually means 20 to 100 ms, and longer for pads and low material. Longer is not automatically better: the crossfade blends two different moments of the recording together, so an over-long fade smears vibrato and movement. The sample also gets shorter by exactly the crossfade length.
- Will the crossfade work on my hardware sampler?
- Yes, because it rewrites the audio rather than writing loop metadata. Many hardware samplers ignore the loop points stored in a WAV file's smpl chunk, but none of them can ignore the audio itself. Once the crossfade is baked in, the file loops cleanly wherever you play it.
Written