Drum Loop Slicer
Operator: Abdulla Al Fahad. How tools are built and checked
A two-bar break holds a kick, a snare and a dozen hats, and the useful thing is each of them on its own key. The hits in a drum loop are found and marked on the waveform, the loop is cut into slices at those marks, and every slice can be played on a pad before anything is exported.
The exports are the ones a sampler or a DAW wants: a ZIP of WAV slices with an SFZ file that maps them to keys, a MIDI file that plays the slices back at their original positions, and the loop rebuilt at a new tempo by starting each slice at a scaled time, not by stretching it, so the transients stay sharp.
It is made for drums and other percussive audio; a sustained pad or a vocal has no hits to find.
Key features
- Hit detection by log-compressed spectral flux with an adaptive threshold, a sensitivity slider and a closest-hits setting of 20 to 150 ms
- Marker editing on the waveform: click to add, drag to move, plus a list with millisecond fields and a remove button
- Grid snap to quarter, eighth or sixteenth notes, a pre-roll of 0 to 15 ms, rising zero-crossing cuts, and fades of 1 ms in and 1 to 120 ms out
- Tempo from the loop's length in bars, or estimated, and 36 pads that answer to the keyboard
How hits are found and how the exports map back to the loop
The loop can be WAV, MP3, FLAC, M4A or OGG of up to 2 minutes, stereo or mono; stereo is kept in the slices and mixed to mono only for detection. Detection works at the file's own sample rate, up to 48 kHz.
The ZIP holds one 24-bit WAV per slice, named slice-01.wav, slice-02.wav and so on, and a .sfz file with one region per slice from MIDI note 36 upward, with one-shot playback and a 20 ms release. Note 36 is C1 where middle C is C3 and C2 where middle C is C4. The MIDI file is format 0, 480 ticks per quarter note, with the tempo and a 4/4 signature, one note per slice at its position and as long as the slice, and holds at most 92 slices.
A WAV at a new tempo is 24-bit and has the length of the loop scaled by the tempo ratio, from the first slice to the end.
How it works
The loop is analysed in frames of 1,024 samples every 256. For each frame, the log of the magnitude from the bins up to 9 kHz is compared with the previous frame, and the increases are added up, which gives a flux value per hop. A hit is a peak that stands above the local median by a number of local spreads set by the sensitivity, plus a floor of 6% of the largest flux.
A weak peak within 70 ms after a stronger one is dropped as the ring of that hit, and peaks closer than the minimum gap keep the stronger. The time is then refined on the waveform: the page looks at 1 ms energy blocks around the flux peak and walks back to where the energy first climbs above 1% of the peak, which places the marker at the start of the attack, usually within a few milliseconds.
Cut points are the markers, optionally snapped to the grid measured from the first marker, then moved earlier by the pre-roll, then to the nearest rising zero crossing within 3 ms. Each slice runs to the next cut, the last to the end of the file, with the fades applied.
The loop at a new tempo places every slice at its start time times the old tempo over the new one, plays it at its original speed, and fades it over 5 ms where it would run into the next slice; a slower tempo leaves a gap.
Common use cases
- A beatmaker drops a vinyl break, fixes two missed ghost snares by clicking them in, and loads the SFZ into a sampler.
- A producer turns a 92 BPM loop into a MIDI pattern, then rewrites the pattern and plays it back through the kit.
- A sound designer lowers the sensitivity to keep only the main kicks and snares of a busy hat pattern.
How to use this tool
- Drop the loop and wait for the markers; move the sensitivity until each hit has a marker and none sits in a tail.
- Choose the loop length in bars if you know it, so the tempo is exact, then add, move or remove markers by hand.
- Play the pads, then export the ZIP, the MIDI groove or a WAV at a new tempo.
Example
A two-bar breakbeat at 120 BPM, 4.000 s long, with 16 hits (kick and snare on the beats, a hat on each off-beat)
Leave sensitivity at 70% and the closest hits at 40 ms, choose 2 bars, export the kitMarkers, kit and tempo changes
In a clean synthetic loop of this kind the markers land within 4 ms of the true hits; a ringing snare or hat can add an extra marker (19 markers for 16 hits in one such loop), which you delete with its remove button
Slices begin at a rising zero crossing, and the SFZ maps slice 1 to note 36, slice 2 to note 37 and so on
Rebuilt at 100 BPM the 4.000 s loop lasts 4.800 s, and at 140 BPM 3.429 s, with every slice cut at the next oneTips for best results
- Raise the pre-roll to 5 to 8 ms if the front of each hit sounds clicked or dull: the cut is then made earlier, in the silence before the attack.
- Use a long fade-out (60 to 120 ms) on a kit with room reverb so each slice dies away instead of stopping.
- Choose the loop length in bars whenever you know it, because an estimate on a short loop can be off by an octave of tempo.
- Delete a marker that sits in a ring with its remove button instead of lowering the sensitivity for the whole loop.
Common pitfalls
A snare and a hat that fall at the same instant are one hit here, so they stay one slice.
Reverb tails overlap the next hit, so a slice can contain the end of the previous sound unless its fade-out is long.
Snapping to a grid moves the cut, not the sound, and a cut that lands after a hit's start loses its attack.
A tempo estimate needs about four seconds of loop and is often a half or double; the bar count avoids the problem.
Sustained or melodic material has no sharp onsets, so the markers are not meaningful.
Common errors and how to fix them
- This file is longer than 2 minutes
- Cut the loop or break out of the longer recording first.
- The tempo is a default of 120 BPM
- The clip is too short or sparse to estimate; choose its length in bars so the tempo is exact.
Best practices
- Export the ZIP and keep its files together: the SFZ names the slices slice-01.wav, slice-02.wav and so on, so renaming or moving one breaks its region.
- Set the loop length in bars before exporting the MIDI groove, so the file carries the right tempo and the pattern lines up with a DAW grid.
How accurate the hit detection is
On clean synthetic loops, with sharp kicks, snares and hats, the markers fall within a few milliseconds of the true hit times at the default sensitivity. A sampled break from a record is harder: it has ghost notes, room sound and layered hits, so expect to add or delete a few markers by hand. No score for real recordings is claimed.
Re-triggering instead of stretching
Stretching a drum loop smears its transients. Re-triggering keeps each hit exactly as recorded and moves only when it starts, which is how REX-style loop players change the tempo of a loop. The price is the gap after each slice when you slow the loop down, and a hit cut short by the next when you speed it up. A slowed loop with long ringing slices sounds gapped unless the slices are long enough to cover the spacing.
Frequently asked questions
Why start at MIDI note 36?
It is the usual first key of a drum kit mapping, and the SFZ and MIDI file use the same notes, so the pattern plays the kit without any editing.
Why are there more markers than hits?
A snare or hat that rings can show a second flux peak after the first. The page drops a weak peak within 70 ms of a stronger one, but a stronger ring survives; remove it with its button, or lower the sensitivity if the whole loop is affected.
Does the MIDI groove keep the swing of my loop?
Yes. Each slice becomes one note at its measured position, and the positions are not quantised unless you snap the cuts to a grid first, so the pattern plays back with the loop's own feel.