Views
No views yet
song.mp3
│
▼ [1] HTDemucs v4 (fine-tuned) ─── stem separation
drums.wav
│
▼ [2] Multi-band onset detection ─── librosa (backtracking, 3-band)
hits/hit_001.wav, hit_002.wav, ...
│
▼ [3] Spectral band decomposition ─── separate overlapping kick+snare+hihat
hits_separated/{kick/, snare/, hihat/}
│
▼ [4] Feature embeddings + clustering ─── librosa (58-dim) or CLAP (512-dim)
│ Auto-K via silhouette score
│
▼ [5] Best representative selection ─── 60% centroid-proximity + 40% energy
│
▼ [6] Optional: weighted synthesis ─── peak-aligned averaging across cluster
│
▼ EXPORT
samples/kick_0__best.wav # best real sample per cluster
synthesized/kick_0__synthesized.wav # synthetic "ideal" version
manifest.json # metadata for all clusters1pip install demucs librosa soundfile scikit-learn numpy torch transformers
2
3python drum_extractor.py song.mp3 -o ./my_samples1# Basic - extract from any audio file
2python drum_extractor.py song.mp3 -o ./samples
3
4# CPU-only (no GPU required for any stage)
5python drum_extractor.py song.wav -o ./samples --no-gpu
6
7# Use CLAP embeddings for semantic clustering (slower but more accurate)
8python drum_extractor.py song.wav -o ./samples --clap
9
10# Skip overlap separation (faster, but simultaneous hits stay merged)
11python drum_extractor.py song.wav -o ./samples --no-separate
12
13# Skip synthesis (only export real samples, no averaging)
14python drum_extractor.py song.wav -o ./samples --no-synthesize
15
16# Tune detection sensitivity
17python drum_extractor.py song.wav -o ./samples \
18 --min-hit-dur 0.05 \
19 --max-hit-dur 1.0 \
20 --energy-threshold -35output_dir/
├── drums_stem.wav # Isolated drum track from Demucs
├── all_hits/ # Every detected hit (intermediate)
│ ├── hit_0000_kick_0.500s.wav
│ ├── hit_0001_snare_1.000s.wav
│ └── ...
├── samples/ # Best representative per cluster
│ ├── kick_0__best.wav
│ ├── snare_0__best.wav
│ ├── hihat_closed_0__best.wav
│ └── ...
├── synthesized/ # Synthesized "ideal" samples
│ ├── kick_0__synthesized.wav
│ └── ...
└── manifest.json # Full metadatahtdemucs_ft) — the current SOTA for music source separation at 8.4 dB SDR on drums (MUSDB18-HQ). Falls back to htdemucs if the fine-tuned variant is unavailable.laion/larger_clap_general — semantic audio embeddings via Contrastive Language-Audio Pretraining. Better at distinguishing subtly different drum types but slower.| Stage | Current | Upgrade | Benefit |
|---|---|---|---|
| 3 (overlap separation) | Spectral bands | AudioSep | Text-queried separation ("kick drum"), 10.5 dB SDRi |
| 3 (overlap separation) | Spectral bands | SAM Audio | Diffusion-based + temporal span prompts (gated, Meta license) |
| 4 (clustering) | librosa features | CLAP embeddings (--clap) | Semantic similarity, better cross-genre generalization |
| 2 (onset detection) | librosa | madmom RNNOnsetProcessor | 0.89 F1 on ENST-drums (needs Python ≤3.10) |
demucs>=4.0
librosa>=0.10
soundfile
scikit-learn
numpy
torch
transformers # only needed with --clap