# Option 1: Let script handle separation
python src/multi_stem_analysis.py \
--audio data/input/song.mp3 \
--output data/cuts.json \
--stems other \
--methods spectral \
--min-gaps 0.15
# Option 2: Use pre-separated stems (faster for iteration)
demucs -n htdemucs data/input/song.mp3 -o data/separated
python src/multi_stem_analysis.py \
--audio data/input/song.mp3 \
--output data/cuts.json \
--separated-dir data/separated/htdemucs/song \
--stems other \
--methods spectral \
--min-gaps 0.15 \
--skip-separationpython src/multi_stem_analysis.py \
--audio data/input/song.mp3 \
--output data/cuts_other_bass.json \
--stems other bass \
--methods spectral default \
--min-gaps 0.15 0.25 \
--merge-strategy union \
--proximity 0.05What this does:
otherwith spectral method → catches melodic/harmonic changesbasswith default method → catches groove changesunionstrategy → combines all onsetsproximity 0.05→ merges onsets within 50ms (avoids double-cuts)
python src/multi_stem_analysis.py \
--audio data/input/song.mp3 \
--output data/cuts_layered.json \
--stems drums other \
--methods energy spectral \
--min-gaps 0.5 0.1 \
--merge-strategy unionWhat this does:
drumswith min-gap 0.5s → only major drum hitsotherwith min-gap 0.1s → detailed melodic cuts- Creates layered rhythm: major accents + intricate details
python src/multi_stem_analysis.py \
--audio data/input/song.mp3 \
--output data/cuts_conservative.json \
--stems drums bass other \
--methods energy default spectral \
--min-gaps 0.2 0.2 0.2 \
--merge-strategy intersectionWhat this does:
- Analyzes all three stems
intersection→ only keeps onsets that appear in multiple stems- Result: Only major musical events where multiple elements change together
--merge-strategy union --proximity 0.05- Combines ALL onsets from all stems
- Removes duplicates within 50ms
- Use when: You want rich, varied cuts from multiple sources
- Result: Most onset times, layered rhythm
--merge-strategy intersection --proximity 0.1- Only keeps onsets that appear in multiple stems (within 100ms of each other)
- Use when: You want only major musical moments
- Result: Conservative, only significant changes
--merge-strategy primary_plus --proximity 0.1- Uses first stem as the base
- Adds onsets from other stems only if they don't create dense clusters
- Use when: One stem is primary, others are accents
- Result: Structured rhythm with occasional variation
--merge-strategy weighted- Currently treats all equally, but you can modify the code to weight stems
- Use when: You want algorithmic blending with priorities
- Method:
energy(detects percussive hits) - Min-gap: 0.1-0.5s depending on density desired
- Use for: Regular rhythm, beat-based cuts
- Method:
defaultorenergy - Min-gap: 0.2-0.4s
- Use for: Groove changes, low-frequency accents
- Method:
spectralorcombined - Min-gap: 0.1-0.2s
- Use for: Melodic/harmonic changes, irregular rhythm (YOUR CHOICE)
- Method:
defaultorspectral - Min-gap: 0.3-0.6s
- Use for: Lyrical phrases, vocal emphasis
The script outputs JSON with both merged and individual stem data:
{
"audio_file": "data/input/song.mp3",
"num_onsets": 187,
"onset_times": [0.12, 0.58, 1.02, ...],
"segment_durations": [0.46, 0.44, ...],
"stems": {
"other": {
"num_onsets": 145,
"onset_times": [...],
"method": "spectral",
"stats": {...}
},
"bass": {
"num_onsets": 78,
"onset_times": [...],
"method": "default",
"stats": {...}
}
}
}-
Separate once:
demucs -n htdemucs data/input/song.mp3 -o data/separated
-
Try different combinations:
# Just other (your preference) python src/multi_stem_analysis.py --audio data/input/song.mp3 \ --separated-dir data/separated/htdemucs/song --skip-separation \ --stems other --output data/cuts_other.json # Add bass for comparison python src/multi_stem_analysis.py --audio data/input/song.mp3 \ --separated-dir data/separated/htdemucs/song --skip-separation \ --stems other bass --output data/cuts_other_bass.json # Conservative (intersection) python src/multi_stem_analysis.py --audio data/input/song.mp3 \ --separated-dir data/separated/htdemucs/song --skip-separation \ --stems other bass drums --merge-strategy intersection \ --output data/cuts_conservative.json
-
Compare results and pick the one that fits your artistic vision!
- Single stem (other): Clean, irregular rhythm following melody/harmony
- Two stems (other + bass): Adds low-frequency groove changes
- Three stems (other + bass + drums): Full musical spectrum, busier
- Intersection of multiple: Only major structural changes
For your stated goal (irregular, non-regular sequences), stick with just "other" using spectral method. Combining would add more regularity from drums/bass.