# Follow the beat

> Find the beats and downbeats in a recording so you can slice, sync and quantise to it: how beat tracking works, where it slips and what to build with it.

Canonical: https://maru.audio/help/follow-the-beat
Documentation index: https://maru.audio/help/llms.txt

A beat tracker listens to a recording and marks where you would tap your foot,
and which of those taps starts a bar. With that grid you can slice a loop on
the beat, sync an effect to a song that was not made to a click, or line up a
sample with the track it came from.

## Try it

In [StemSep](https://maru.audio/modules/stemsep), load a song, open **Beat grid** and choose
**Track beats in mix**, or split the stems first and choose **Track beats in
drums**. Export the grid as a MIDI file and drop it into your DAW to see it
line up; the file holds metronome hits on the beats, not the song's drum notes.

## How it works

A trained model listens for the patterns people tap along to: the strength and
regularity of onsets, the kick and snare, harmonic changes at bar lines. It
outputs a likelihood of a beat and of a downbeat over time, and the tracker
picks the most consistent sequence. [Beat and tempo tracking](https://maru.audio/learn/beat-and-tempo-tracking.md)
in Learn explains why trackers agree with listeners on common music and
struggle elsewhere.

Simpler tools find **onsets**, the moments sounds start, without a model. They
are good for slicing drums but do not know where the bar begins.

## Ideas

- **Slice on the beat.** Chop a break into hits that fall exactly on the grid.
- **Sync to a live recording.** Drive a delay or a filter sweep from the beats
  of a band that drifted in tempo.
- **Quantise with feel.** Snap transcribed notes to the song's own beats rather
  than a fixed tempo.
- **Find the one.** Align a loop to the downbeat before you layer it.
- **Make a DJ cue sheet.** Export the grid and mark the drops.

## What it gets wrong

- **Half or double time.** The tracker may tap twice as fast or half as fast
  as you would. Both can be musically right.
- **Unusual meters and rubato.** Odd time signatures, free-tempo passages and
  ambient music give weak or wrong grids.
- **Beats, not tempo.** You get beat times; a single tempo number is an
  average of them and can mislead on music that speeds up.
- Tracking the drum stem is usually steadier than the full mix.

## Build your own

Ask your coding agent to add a beat grid to your module:

```text
Read the Maru docs page "Beats and tempo in a module", then read StemSep's
source with `maru module files stemsep`, looking for how its face calls
trackRhythm. Add "slice on beats" to my sampler, falling back to onset
detection when no beat tracker is available.
```

Developers can start from [Beats and tempo in a module](https://maru.audio/docs/beats-and-tempo-in-a-module.md).
The [model directory](https://maru.audio/models) describes the beat tracking models.
