audio-analyzer

An OpenClaw skill that turns any MP3 into BPM, key, color waveform, beat-grid MIDI, Traktor cues, melody MIDI, and 4-stem separation.

// built 2026-07-24 // fedgeops.com // cpu only, no gpu required

What it does

Drop in a song, get back a folder full of stuff you can use in FL Studio, Traktor, or any DAW. The skill is local (no cloud), runs on the CPU, and finishes a 4-minute track in about 5 minutes including stem separation.

Track analyzed
Move Higher
Sub Focus, F minor
Duration
252.9s
4:12
BPM
126.05
532 beats total
Drum onsets
1062
41 kicks, 114 snares, 5 hats, 296 toms
Melody notes
629
via basic-pitch
Pipeline runtime
308.5s
Ryzen 7 5700U, CPU only

Color waveform

The full track as a log-frequency spectrogram. Frequency is mapped to color (cool = low, warm = high). Every detected beat gets a yellow tick โ€” large for downbeats (every 4th), faint for off-beats. Time stamps every 10 seconds.

Color waveform of Move Higher with beat ticks
waveform.png โ€” full track, 4:12, all 532 beats visible

Stem contact sheet

All four stems (drums, bass, other, vocals) stacked vertically on a shared time axis, with beat ticks running through every row so you can see what lands on each beat across the whole mix. The bass row carries serious energy here โ€” that deep sub is what gives Sub Focus his signature weight.

Stem contact sheet with all 4 stems stacked
stem-contact-sheet.png โ€” drums / bass / other / vocals, time-aligned
drums
bass
other (instruments, fx)
vocals

Beat builder

Click a cell in the grid to toggle a hit. Hit "Play" to loop your pattern at the song's tempo. The sounds come from the real one-shots extracted from the track's drums stem.

Tempo: BPM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
KICK
SNARE
HAT
TOM
OTHER
Ready. Click cells to build a pattern, then press Play.

Soundboard

Click a pad to play a single hit. The one-shots are individual drum hits extracted from the track. The stem previews are 30-second clips starting at 0:30 (skipping the intro).

Drum one-shots

Each is a single hit, ~280ms. Drop them into your sampler.

โ—
Kick 1
first
โ—
Kick 2
early
โ—
Kick 3
mid
โ—
Kick 4
final
โ—
Snare 1
first
โ—
Snare 2
early
โ—
Snare 3
mid
โ—
Snare 4
late
โ—
Hat 1
open
โ—
Hat 2
closed
โ—
Hat 3
edge
โ—
Tom 1
low
โ—
Tom 2
mid
โ—
Tom 3
high
โ—
Tom 4
accent
โ—
FX 1
percussion
โ—
FX 2
percussion
โ—
FX 3
percussion
โ—
FX 4
percussion

Stem previews (30s each, starting at 2:10)

All clips start at 2:10 โ€” that's the good-mix-of-everything section. The first pad is the original track, then the four separated stems. A/B between them to hear what HTDemucs pulled apart.

โ–ถ
Original
full mix @ 2:10
โ–ถ
Drums
30s @ 2:10
โ–ถ
Bass
30s @ 2:10
โ–ถ
Other
30s @ 2:10
โ–ถ
Vocals
30s @ 2:10

Pipeline

Eight stages run in order. The first five are fast (under a minute on a 4-minute track). Stem separation is the bottleneck โ€” about 1.2x real-time on CPU.

01
BPM + Key
librosa beat tracking + Krumhansl-Schmuckler key profiles
02
Features
spectral centroid, ZCR, RMS, MFCC, brightness, energy
03
Waveform
color spectrogram PNG with beat ticks + time stamps
04
Beat MIDI
kick + snare backbeat, ready for FL Studio
05
Traktor Cues
hot-cue CSV: load + 7 downbeats + 4-beat loop
06
Melody
Spotify's basic-pitch, ONNX, ~10MB model
07
Stems
HTDemucs 4-stem, CPU only, ~1.2x real-time
07b
Drum split
5-band frequency classification of onsets
07c
Contact sheet
all stems stacked with aligned beats

Quick start

All outputs go to analysis/<track-name>/ next to the input file (or use --out <dir> to override).

# Fast pipeline (BPM, key, features, waveform, beat MIDI, cues, melody)
# ~15-30 seconds for a 2-minute track
python analyze.py path/to/track.mp3

# Full pipeline including stem separation
# ~3-5 minutes for a 2-minute track on CPU
python analyze.py path/to/track.mp3 --stems

# Skip the slow stuff
python analyze.py path/to/track.mp3 --no-melody --no-stems

# Speed up stem separation (lower quality)
python analyze.py path/to/track.mp3 --stems --shifts 0 --overlap 0

SKILL.md

The full skill specification, copy-pasted from skills/audio-analyzer/SKILL.md.

# audio-analyzer

Analyze an MP3 (or any audio file) into:
- BPM + beat grid
- Musical key (Krumhansl-Schmuckler)
- Spectral / energy / loudness fingerprint
- Color waveform PNG with beat ticks and section markers
- Traktor hot-cue CSV
- Beat-grid MIDI (for FL Studio)
- Melody MIDI via basic-pitch
- 4-stem separation via HTDemucs (CPU, slow)

All outputs go into a per-track subfolder.

## When to use

When the user says things like:
- "Analyze this track"
- "What's the BPM / key of this song"
- "Split this into stems"
- "Make a Traktor-ready CSV from this MP3"
- "Render a color waveform"
- "Extract the melody as MIDI"

## Quick start

    # Just the fast analysis (BPM/key/waveform/MIDI/CSV) โ€” no stem separation
    python .openclaw/workspace/skills/audio-analyzer/analyze.py path/to/track.mp3

    # Full pipeline including HTDemucs (slow on CPU: ~10-30 min for 4-min track)
    python .openclaw/workspace/skills/audio-analyzer/analyze.py path/to/track.mp3 --stems

    # Skip the slow stuff
    python .openclaw/workspace/skills/audio-analyzer/analyze.py path/to/track.mp3 --no-melody --no-stems

Outputs go to `analysis/<track-name>/` next to the input (or `--out <dir>`).

## Outputs

For input `foo.mp3`:
- `analysis/foo/analysis.json` โ€” full structured result (BPM, key, beats, features)
- `analysis/foo/waveform.png` โ€” color waveform with beat ticks + section marks
- `analysis/foo/beats.mid` โ€” MIDI file with one note per beat (FL Studio)
- `analysis/foo/cues-traktor.csv` โ€” Traktor hot-cue CSV (cue #, time, type, comment)
- `analysis/foo/melody.mid` โ€” melody extracted by basic-pitch (if enabled)
- `analysis/foo/stems/{drums,bass,vocals,other}.wav` โ€” HTDemucs output (if enabled)
- `analysis/foo/stems/drum-split/oneshots/{kick,snare,hihat,cymbal,tom}/*.wav` โ€” per-hit one-shots
- `analysis/foo/stems/drum-split/tracks/{kick,snare,hihat,cymbal,tom}.wav` โ€” per-piece continuous tracks
- `analysis/foo/stems/drum-split/drum-kit-multitrack.wav` โ€” all pieces in one multichannel WAV
- `analysis/foo/stems/drum-split/drum-hits.csv` โ€” every detected hit with time + label
- `analysis/foo/stem-contact-sheet.png` โ€” all 4 stems stacked vertically with aligned beat ticks + time stamps

## Dependencies (already installed in this env)

- librosa 0.11.0
- soundfile 0.14.0
- matplotlib 3.11.1
- basic_pitch 0.4.0
- demucs 4.1.0
- torch 2.7.1+cu118
- numpy, scipy, numba

## Important runtime notes

- **CPU only** on this host. The Vega iGPU is not in torch's CUDA allowlist, so do NOT pass `--device cuda` to demucs. The script forces `device=cpu`.
- HTDemucs first run downloads ~80 MB of model weights to `~/.cache/torch/hub/`.
- basic-pitch first run downloads ~10 MB of model weights.
- Stem separation on CPU: ~10-30 min for a 4-min track. Use `--shifts 0 --overlap 0` to speed up if quality is acceptable.
- This script NEVER uses random network calls beyond the initial model downloads.

## Files

- `analyze.py` โ€” orchestrator
- `stage_bpm_key.py` โ€” BPM + key + beat grid
- `stage_features.py` โ€” spectral/energy features
- `stage_waveform.py` โ€” color waveform render
- `stage_midi.py` โ€” beat-grid MIDI
- `stage_melody.py` โ€” basic-pitch melody extraction
- `stage_stems.py` โ€” HTDemucs 4-stem
- `stage_drum_split.py` โ€” split drums into kick/snare/hihat/cymbal/tom
- `stage_contact_sheet.py` โ€” render all stems stacked with aligned beats
- `stage_cues.py` โ€” Traktor hot-cue CSV

Outputs from this run

Every run writes its results to analysis/<track-name>/. The folder for the track on this page (move-higher) contains:

analysis/move-higher/
โ”œโ”€โ”€ analysis.json              # full structured result
โ”œโ”€โ”€ beats.mid                  # 532-beat kick+snare pattern for FL Studio
โ”œโ”€โ”€ cues-traktor.csv           # 7 hot cues + 4-beat loop suggestion
โ”œโ”€โ”€ melody.mid                 # 629 notes via basic-pitch
โ”œโ”€โ”€ waveform.png               # color spectrogram (shown above)
โ”œโ”€โ”€ stem-contact-sheet.png     # all stems aligned (shown above)
โ””โ”€โ”€ stems/
    โ”œโ”€โ”€ drums.wav              # 22 MB
    โ”œโ”€โ”€ bass.wav               # 22 MB
    โ”œโ”€โ”€ other.wav              # 22 MB
    โ”œโ”€โ”€ vocals.wav             # 22 MB
    โ””โ”€โ”€ drum-split/
        โ”œโ”€โ”€ oneshots/          # 1062 individual hit WAVs by category
        โ”œโ”€โ”€ tracks/            # per-piece continuous WAVs
        โ”œโ”€โ”€ drum-hits.csv      # every detected hit with time + label
        โ”œโ”€โ”€ drum-kit-multitrack.wav
        โ””โ”€โ”€ drum-split-summary.json
โ† back to fedgeops.com