Skip to content

Analyzers

Analyzers: forro analyze

An analyzer turns an audio file into facts. forro analyze runs analyzers on files, or on every file of a library, and records the results in the catalog:

forro analyze --with beats track1.ogg track2.ogg
forro analyze --with beats --model ~/models/forro-ft1.ckpt --db ~/.mixxx/mixxxdb.sqlite
forro analyze --with beats --target main --jobs 2

Each file is named as the importers name it: by its SPOTIFY_URI tag, else its ISRC tag, else its audio digest. Results are cached per analyzer, analyzer version and audio digest (in analyses next to the beats cache), so re-tagged, moved or duplicate files are not analysed again; --force analyses again. A fact gets the source <analyzer>:<version>, where the version names the analyzer's code and its model, so results of another model or forro-beats version are kept apart. --jobs N analyses N files in parallel processes. Settings per analyzer go into the config file:

[analyze.beats]
model = "~/models/forro-ft1.ckpt"   # --model overrides it
Analyzer Extra Facts (measured)
beats [beats] beats: {"times": [...], "numbers": [...] or null}, Beat This!'s beats in seconds and their numbers in the bar; grid: the grid forro-beats mixxx would write for a track that has none (same halving and skips, same blob and sub_version), measured on this file, so sync writes it byte for byte into a library with the same file
stems [stems] + ffmpeg stem: {"model": ..., "codec": ..., "streams": 5}, written once the file's Song.stem.mp4 is in place (see below)

An analyzer whose extra is missing stops with the install hint (exit code 2) before anything is read. A track without a grid (too few beats, irregular halving, unknown MP3 offset) still gets its beats; the summary counts why.

Stems. forro analyze --with stems Song.ogg separates the track with Demucs into drums, bass, other and vocals and writes Song.stem.mp4 next to Song.ogg: an NI-style stem file (the original mix plus the four stems, AAC 256 kbit/s or ALAC, with the moov/udta/stem manifest) that a stem-aware Mixxx plays in place of the original. The audio is decoded with libsndfile, so the stems stay on the source's timeline. Tags and cover art are copied from Ogg Vorbis, Opus and FLAC sources, the title gets " (stems)", and the model is recorded in a STEM_MODEL tag. Before it is put in place, the file must pass Mixxx's own stem checks (re-implemented here). It is written as a hidden .Song.stem.mp4.part in the target folder, compared byte for byte, then linked into place: an existing file is never overwritten. A valid Song.stem.mp4 already there is kept and not made again; any other file under that name makes the track fail. The temporary WAVs go to tmp in the forro-beats cache folder (~/.cache/forro-beats; on Windows, untested, %LOCALAPPDATA%\forro-beats) and are deleted afterwards, also when a step fails. A separation takes minutes per track on a CPU; Demucs downloads its weights from Hugging Face on first use. The catalog holds no paths: a cached result is reused without looking for the file, so after deleting a stem file run again with --force.

[analyze.stems]
model = "htdemucs"     # a Demucs model with the sources drums, bass, other, vocals; --model overrides it
codec = "aac"          # or "alac"
# out_dir = "~/stems"  # default: next to each audio file

Analyzers from other packages. A Python package can add analyzers through the entry point group forro_beats.analyzers:

# the other package's pyproject.toml
[project.entry-points."forro_beats.analyzers"]
loudness = "forro_loudness.analyzer:LoudnessAnalyzer"

The entry point names a factory (usually a class) that takes the settings dict ([analyze.<name>] plus --model) and returns an object with name, version, fields (the fact fields it may return), extra, check() (None when it can run, else what to install) and analyze(path, ctx) returning {field: (value, kind)}. Subclass forro_beats.analyzers.Analyzer for the defaults; ctx carries the file's catalog key, audio digest, decoder offset, sample rate and duration. Then forro analyze --with loudness runs it. A built-in name cannot be taken.

Programs in other languages or under other licences need no plug-in: let them write a facts CSV (above) and import it with forro catalog-import-facts. The catalog keeps their facts apart by source.