---
name: tempo-fix
description: Change the tempo (BPM) of any audio file without altering its pitch — or change the pitch without altering the tempo — or both at once. Auto-detects source BPM via librosa, then time-stretches to your target. Optional pitch shift in semitones for key matching. Drop-in for sample/loop matching, DJ prep, "make this fit my beat", or repitching a vocal up/down. Use when the user asks to "stretch this to 140 bpm", "match the tempo", "change pitch without changing speed", "warp this sample", or "make this fit my beat".
---


# tempo-fix

Time-stretch and/or pitch-shift any audio. Pitch and tempo are independent.

## Match a target BPM

```bash
python3 ~/.claude/skills/tempo-fix/scripts/fix.py --input loop.wav --target-bpm 140
# auto-detects source BPM, stretches to 140
```

## Stretch by ratio (no detection)

```bash
python3 ~/.claude/skills/tempo-fix/scripts/fix.py --input loop.wav --rate 1.25
# 1.0 = unchanged · 1.25 = 25% faster · 0.8 = 25% slower
```

## Repitch up/down (no tempo change)

```bash
python3 ~/.claude/skills/tempo-fix/scripts/fix.py --input vocal.wav --pitch +3
# +3 semitones up

python3 ~/.claude/skills/tempo-fix/scripts/fix.py --input vocal.wav --pitch -2
```

## Tempo + pitch together

```bash
python3 ~/.claude/skills/tempo-fix/scripts/fix.py --input loop.wav \
  --target-bpm 95 --pitch -2
# slow it down to 95 BPM AND drop it 2 semitones (so it sits on a different key)
```

## Match key + tempo to a reference track

```bash
python3 ~/.claude/skills/tempo-fix/scripts/fix.py --input sample.wav --match reference.wav
# detects bpm + key of reference, repitches + stretches sample to match
```

## Folder mode

```bash
python3 ~/.claude/skills/tempo-fix/scripts/fix.py --input ~/loops --target-bpm 140 --recursive
```

## Output format

By default, outputs WAV. Use `--format mp3` or `--format flac` for compressed.

```bash
python3 ~/.claude/skills/tempo-fix/scripts/fix.py --input loop.wav --target-bpm 140 \
  --format mp3 --output ~/processed/
```

## Flags

- `--input` — file or folder
- `--output` — output file or folder (default `<input>_<bpm>bpm.wav`)
- `--target-bpm` — target tempo (auto-detects source)
- `--rate` — direct stretch ratio (overrides --target-bpm)
- `--pitch` — semitones to shift (e.g., `+3` or `-2`)
- `--match` — reference file; copy its BPM + key
- `--recursive` — descend folders
- `--format` — `wav` (default), `mp3`, `flac`, `m4a`
- `--quality` — for mp3: 0–9 LAME q-scale (default 2)
- `--engine` — `librosa` (default, fast) or `rubberband` (higher quality, install with `brew install rubberband`)

## How it works

- librosa for BPM/key detection
- librosa `effects.time_stretch` (phase vocoder) for tempo change
- librosa `effects.pitch_shift` for pitch change
- Optional [rubberband](https://breakfastquay.com/rubberband/) for studio-grade quality (5x slower but cleaner transients)

## Pairs well with

- `sample-pack` → tempo-fix every loop to a unified BPM, then pack
- `chord-rip` → detect a sample's key, then `tempo-fix --pitch` to match your beat
- `stems` → split first, then tempo-fix each stem independently
- `loudness-fix` → tempo-fix changes peaks; re-master after
