keyandbpm

How to match a sample to your beat's key and tempo

By Mike Farina ·

Find the sample's key and BPM, then either time-stretch it to your tempo and transpose it separately, or repitch it (change speed and pitch together, like a turntable). Every semitone of repitch changes the tempo by about 5.9%, so semitones = 12 × log2(new BPM ÷ old BPM); move the key by the smallest number of semitones, never more than 6.

You've got a loop you love and a beat that's already half built, and they don't agree. Either the tempo's off, the key's off, or both. There are two ways to fix it, and picking the right one matters more than any plugin setting.

Step one: find the sample's key and BPM

You can't move something to the right place if you don't know where it starts. Loop the sample, find the root note on a keyboard, and tap the tempo (the key of a sample guide goes through the by-ear method). Or drop the file on the analyser: it gives the key, BPM and tuning, and it plays the sample against a beat grid so you can hear whether the tempo it found is the one you'd count.

Write down the tuning figure too. If the sample sits 30 cents flat, your key shift will leave it 30 cents flat, and that's its own fix (covered in how to pitch a sample in cents).

Time-stretch or repitch: which should I use?

These are the two approaches, and they sound very different.

Repitch is what a turntable or tape machine does. Speed the sample up and it gets higher; slow it down and it gets lower. Pitch and tempo move together, locked. Ableton calls this the Re-Pitch warp mode; on an MPC or most samplers it's just what happens when you play a sample on a different note. Nothing is being calculated, so there are no stretching artefacts at all. The sound changes character (faster and brighter, or slower and darker), and a lot of classic hip hop sounds the way it does because of this.

Time-stretching changes the tempo without touching the pitch, and pitch-shifting changes the pitch without touching the tempo. Your DAW does this with algorithms: Ableton's warp modes, Logic's Flex Time and Flex Pitch, FL Studio's stretch modes. It lets you move the two independently, which is more flexible, at the cost of artefacts: smeared transients, a phasey or metallic quality on sustained notes, and a "chipmunk" or "underwater" formant shift on vocals once you go more than a few semitones.

My rule of thumb:

How many semitones should I transpose a sample?

Count the distance between the sample's key and the beat's key, in semitones, and take the shorter way round. There are only 12 semitones in an octave, so you never need to move more than 6 in either direction.

Example: the sample is in A minor and the beat is in C minor. C is 3 semitones above A (A, A#, B, C), so shift the sample up 3. You could also go down 9, but that's a much bigger shift for the same result.

Keep the mode in mind. If the sample is in a minor key and the beat is in its relative major, you don't need to move anything: A minor and C major share the same notes. The relative major and minor keys guide lists all 12 pairs. The same trick works for fitting a sample to a beat you haven't committed to yet: shift the beat, not the sample.

If the sample and beat are a tritone apart (6 semitones), try it both ways, up 6 and down 6. They'll sound quite different, and one usually works better.

The semitone and tempo maths

Because repitch changes speed and pitch together, a given key change fixes the tempo change too. One semitone is a frequency ratio of 21/12, which is about 1.0595. So every semitone up plays the sample about 5.9% faster, and every semitone down about 5.6% slower.

Here's what that does to a 90 BPM loop:

Repitch (semitones)Speed ratio90 BPM loop becomesTempo change
-50.749267.4 BPM-25.1%
-40.793771.4 BPM-20.6%
-30.840975.7 BPM-15.9%
-20.890980.2 BPM-10.9%
-10.943984.9 BPM-5.6%
01.000090.0 BPM0%
+11.059595.4 BPM+5.9%
+21.1225101.0 BPM+12.2%
+31.1892107.0 BPM+18.9%
+41.2599113.4 BPM+26.0%
+51.3348120.1 BPM+33.5%

Going the other way, if you know the tempo you want, the pitch shift you'll get from repitching is:

semitones = 12 × log2(new BPM ÷ old BPM)
      new BPM   = old BPM × 2^(semitones ÷ 12)

So taking a 90 BPM loop to 95 BPM by repitch raises it about 0.94 semitones, or 94 cents. That's nearly a semitone but not quite, which means the sample ends up between keys. You then have three choices: nudge the beat's tempo so the shift lands on a whole semitone (95.4 BPM here), fine-tune the rest of the beat to match the sample, or give up on pure repitch and stretch instead.

I nearly always take the first option. A beat at 95.4 BPM sounds no different to a listener than one at 95, and the sample stays in tune with no processing.

Should I move the sample or the beat?

If the beat is mostly drums and an 808, move the beat. Drums don't care about key, and transposing an 808 pattern or a synth is free and clean because it's MIDI. The sample stays untouched and sounds its best.

If the beat already has a vocal, or you've built a lot of melodic parts, move the sample. Keep the shift small, and if you can, find the one semitone in either direction where the sample sounds best and set the beat up around that.

What about half time and double time?

Don't forget the sample doesn't have to play at the same tempo as your drums. A 70 BPM soul loop fits a 140 BPM trap beat as it is, because 140 is double 70. A 180 BPM loop drops into a 90 BPM beat the same way. Before you stretch anything, check whether the tempo is already a factor of 2 away. Analysers and DAWs sometimes report the half or double value anyway, which is its own headache: see why is my BPM half or double.

A quick workflow

  1. Get the sample's key, BPM and tuning.
  2. Check for a relative key or a half/double tempo match before moving anything.
  3. Work out the smallest semitone shift to your key.
  4. Look up what that shift does to the tempo if you repitch. If it lands close to your target BPM, repitch and adjust the beat's tempo to match.
  5. If not, stretch to tempo and pitch-shift separately, and keep both moves as small as you can.
  6. Fix any leftover tuning offset in cents, on the sample or on everything else.
  7. Listen on its own and in the mix. Stretching artefacts that hide under drums can still show up in the intro.

Questions people ask

How do I change a sample's key without changing its tempo?

Use your DAW's pitch-shift or a warp mode that keeps tempo fixed, such as Ableton's Complex or Complex Pro, or Flex Pitch in Logic. Keep the shift small, because artefacts grow with every semitone.

How much does one semitone change the BPM?

When you repitch, one semitone up is about 5.9% faster and one semitone down is about 5.6% slower. A 90 BPM loop becomes about 95.4 BPM a semitone up and 84.9 BPM a semitone down.

Can I put a minor sample in a major beat?

Yes if the beat is in the sample's relative major, since they share the same notes: an A minor sample fits a C major beat with no shifting. Otherwise, transposing changes the root but keeps the sample minor.

Why does my sample sound slightly out of tune after I matched the key?

It was probably out of tune to begin with, which is common on old records and vinyl rips. Check its tuning in cents and fine-tune the sample or the rest of the beat by that amount.

What's the most I should pitch a sample?

You never need more than 6 semitones for a key change, because going the other way is shorter. With stretching, most material starts to sound processed beyond 3 or 4 semitones; with repitch the limit is whether you like the new tempo.