Skip to content

Beat grids for Mixxx

First run: a dry run

Mixxx can stay open: a dry run only reads the library.

forro-beats mixxx --model ~/models/forro-ft1.ckpt --limit 5

It finds the library in ~/.mixxx/mixxxdb.sqlite, else in the Flatpak's ~/.var/app/org.mixxx.Mixxx/.mixxx/mixxxdb.sqlite. If yours is somewhere else (Mixxx's --settings-path), add --db /path/to/mixxxdb.sqlite. Each track is analysed once, which takes a few seconds per track on a CPU. The results are cached in ~/.cache/forro-beats/beats, so later runs are fast.

The run prints what it would do per track, a summary, and the path of a plan CSV in ~/.cache/forro-beats/plans (it opens in any spreadsheet). Nothing is written.

All of this was used and tested on Linux (Debian 13) only. On Windows and macOS (untested) the library, cache and plans are looked for where those systems keep them (see Install).

To narrow it down:

  • --only "feira de mangaio" "sao joao": tracks whose file name contains one of these. Case and accents are ignored.
  • --under ~/Music/forro: tracks inside one folder.
  • --limit N: the first N tracks left after the other filters.

Apply

Close Mixxx, then run the same command with --apply:

forro-beats mixxx --model ~/models/forro-ft1.ckpt --only "feira de mangaio" --apply

It refuses to write while Mixxx is running, or when it cannot check that. Before writing, it makes a read-only backup in a forro-beats-backups folder next to the library (or in backup_dir from the config, or --backup-dir). Then it writes all grids in one transaction and saves a change log (a .jsonl file with every old and new value) next to the plan. A track whose grid changed between the plan and the write (you edited it in Mixxx meanwhile, say) is skipped and its reason printed; the others are written. Add --lock to lock the BPM of the written tracks, so Mixxx does not replace them. If Mixxx is set to re-analyse tracks when analyser settings change, you get a warning that suggests --lock.

Each grid written carries a fingerprint of itself in Mixxx's beats_sub_version (beat_this=MODEL|forro_beats=VERSION|sha=...). A later run compares it with the stored grid: when they match, the grid is still exactly what forro-beats wrote, and it is replaced with the new one; when they do not, you edited it in Mixxx, and it is kept.

Undo

The apply step prints the exact commands. With Mixxx closed:

forro-beats mixxx-undo ~/.cache/forro-beats/plans/mixxxdb-20261029-210000-123456-apply.jsonl

This puts back the old values from the change log, track by track, where the grid is still the one forro-beats wrote; tracks you changed in Mixxx since are skipped and listed. It makes a backup first and writes its own change log.

To put the whole library back as it was at the backup, including anything else you changed in Mixxx after it:

forro-beats mixxx-restore ~/.mixxx/forro-beats-backups/mixxxdb-20261029-210000.sqlite

What it skips, and why

Reason Why
file not found the library points at a file that is not there
unsupported format only MP3, FLAC, WAV and AIFF: for other formats the offset between Mixxx's decoder and the one Beat This! sees is unknown
decoder offset unknown an MP3 without a LAME header (see below); --mp3-lag-frames N sets the offset by hand
BPM locked you locked the track in Mixxx; --include-locked replaces it anyway
unchanged the stored grid is exactly what forro-beats would write
written by forro-beats with model M, kept forro-beats wrote this grid before with another model; --replace-other-models replaces it. Hand edits of such grids cannot be detected, so the flag replaces those too
moved half a beat after forro-beats wrote it, kept the grid forro-beats wrote (same model) now sits half a beat away, so you moved it on purpose; --include-edited replaces it anyway
edited in Mixxx after forro-beats wrote it forro-beats wrote this track before with the same model and the grid is no longer what it wrote, so you probably fixed it by hand; --include-edited replaces it anyway
current grid already agrees a grid forro-beats did not write (or one you edited) already matches the new one (F-measure ≥ 0.9 within 70 ms); --max-agreement changes the limit
halving gave an irregular grid see below

A grid forro-beats wrote with the same model and that nobody changed since is replaced whenever the new one differs, however well they agree ("replacing an older forro-beats grid"). Grids written before the fingerprint existed are recognised by rebuilding them: one that differs only because the halving rule now decides otherwise ("replacing a forro-beats grid: halving changed"), or only by beats before the first or after the last new beat ("replacing an older forro-beats grid (edges only)"), is replaced too.

Beat This! results are cached per model and per audio content, not per file: re-tagging or moving a file keeps its cached beats.

Tempo: if Beat This! counts more than 130 BPM, the track is treated as a xote counted double and written at half tempo: the author's rule of thumb is that nobody dances forró above 130 BPM. --halve-above changes the limit. If every other beat does not give a steady grid at half tempo (a waltz, say), the track is skipped.

The MP3 offset

Mixxx 2.5 decodes MP3 with libmad on Linux, where this was measured. Its Windows build (untested here) is configured with libmad too. libmad keeps the encoder delay and the decoder delay at the start of the file. Beat This! reads audio with libsndfile, which removes both. So the same beat sits about 23 to 25 ms later in Mixxx. forro-beats reads the encoder delay from each file's LAME header and shifts the grid by that delay plus 529 samples. FLAC, WAV and AIFF need no shift. This was checked against offsets measured by cross-correlating both decodes on 394 MP3s, all encoded by ffmpeg (Lavc61.19) with a delay of 576: every one matched. Files encoded by LAME itself are untested.