Browser-based audio analysis · tempo, key, Camelot

BPM and Key Detector

Drop one track or a whole folder worth and get the tempo to a tenth of a BPM, the musical key and its Camelot code, then export the table as CSV. The analysis runs in a background thread of this tab; no file is uploaded.

Tracks

Up to 30 files, each up to 30 minutes. Audio or the soundtrack of a video.

Drop audio files here or click to choose

.mp3, .wav, .m4a, .flac, .ogg, .mp4, .webm. Select several at once.

Results appear here, one card per file.

Tempo and key are estimates. Where the half or double of the tempo is more natural for your use (a 70 BPM ballad counted as 140, for instance), pick it from the buttons under the figure; the CSV uses the one you picked.

Tap tempo

Tap along with a song to check a result. Uses the last 8 taps; a pause of 2.5 seconds starts over.

– BPM

No taps yet.

Key is shown with Camelot codes: 8A is A minor and 8B is C major, its relative major. Tracks with the same number, or one step either way on the wheel, usually mix without a key clash.

BPM and Key Detector

Operator: Abdulla Al Fahad. How tools are built and checked

DJs, producers and runners who build playlists by tempo usually reach for a paid tool that tags a library with BPM and key. This page does the same job on files you drop in: it reports the tempo to a tenth of a BPM, the musical key with its Camelot code, a confidence reading for each, and a CSV of the whole batch. A tap-tempo pad sits beside it for the cases where you would rather check by ear.

Everything runs in a Web Worker in your browser. The files are decoded to 22.05 kHz mono, analysed and then discarded, one at a time, so a batch of 30 never holds more than one decoded track in memory.

Key features

  • Tempo to 0.1 BPM from an onset-strength envelope, an autocorrelation with a tempo prior and a Fourier refinement
  • Half-time and double-time alternatives as one-click buttons, with the chosen value used in the CSV
  • Key from a tuning-corrected chroma vector and the 24 Krumhansl-Kessler profiles, with the Camelot code, runner-up and a twelve-bar chroma chart
  • A steadiness figure: how many 12-second windows agree with the overall tempo
  • Batch queue of up to 30 files with a progress bar, cancel and retry
  • CSV export of the table
  • Tap tempo from the last eight taps, with a reset after a pause of 2.5 seconds

How tempo and key are measured, and where they fail

Input is any audio the browser can decode (MP3, WAV, M4A and AAC, FLAC, Ogg, Opus, WebM) or the soundtrack of a video (MP4, MOV, WebM). Up to 30 files can be queued, each up to 30 minutes and within the usual size caps of 1 GB for audio and 1.5 GB for video. Files are analysed one after another, and the decoded samples of one file are released before the next begins, so the memory used does not grow with the batch.

Tempo is searched between 50 and 220 BPM. The estimate is reported to 0.1 BPM, and the two related values (half and double) are offered when they fall inside that range. The key is one of 24 (12 major, 12 minor) and is accompanied by the Pearson correlation of the winning profile, the gap to the runner-up and the detected tuning offset in cents from A = 440 Hz. Clips shorter than four seconds give no tempo, and a silent file gives neither.

The CSV has one row per finished file with the columns file, duration_seconds, bpm, key, camelot, key_correlation and tempo_confidence. If you picked the half or double value for a track, the CSV carries the value you picked. File names that begin with a character a spreadsheet could read as a formula (=, +, - or @) get a leading apostrophe.

Camelot notation numbers the circle of fifths from 1 to 12 and adds A for minor and B for major. C major is 8B and its relative minor, A minor, is 8A; G major is 9B. Tracks whose codes are identical or one step apart share most of their notes, which is why DJs use the wheel for harmonic mixing.

How it works

Tempo. The audio is cut into 1024-sample frames with a hop of 256 samples (about 86 frames per second at 22.05 kHz), Hann-windowed and transformed with an FFT. The log of each bin's magnitude below 8 kHz is compared with the previous frame, and only the increases are summed: the spectral flux, a measure of how much new sound arrived. A moving average of half a second is subtracted so that slow swells do not count as beats, leaving the onset envelope.

The envelope is autocorrelated for lags that correspond to 50 to 220 BPM. Each candidate lag scores its own correlation plus half the correlation at twice the lag and a quarter at four times the lag, which rewards a tempo that also repeats on the bar, and the result is multiplied by a log-normal prior centred on 120 BPM with a width of one octave. The best lag is refined by a parabola, then by scanning 4% either side in 0.05 BPM steps for the strongest Fourier component of the envelope, which is what gives the tenth-of-a-BPM figure. A click track at 128 BPM comes out as 128.0.

Key. The audio is cut into 8192-sample frames with a hop of 4096. Spectral peaks between 80 Hz and 2 kHz vote, weighted by magnitude, for how far the recording sits from A = 440 Hz, and that offset is removed. Each bin is then assigned to one of the twelve pitch classes (bins that fall between two semitones are skipped), magnitudes are raised to the power 1.5 so that strong partials count more than faint overtones, and frames are summed with louder frames weighing more. The twelve totals are correlated with the major and minor Krumhansl-Kessler profiles rotated to every tonic, and the highest correlation wins.

Common use cases

  • Tagging a crate of tracks with BPM and Camelot codes before a DJ set, then sorting the CSV by key and tempo
  • Finding the tempo of a sample or a loop so a drum machine or a DAW project can be set to match it
  • Choosing running or cycling music by cadence, by listing the tracks near 160 to 180 BPM
  • Checking which key a backing track is in so a singer can pick a comfortable part
  • Comparing the tempo you feel with an objective measurement, using the tap pad against the detected value

How to use this tool

  1. Drop one or more audio files on the page, or click it to choose them. The analysis starts at once.
  2. Watch the progress bar; each file becomes a card with its tempo, key and Camelot code when it finishes.
  3. If a tempo looks like half or double what you feel, press the other value on the card.
  4. Press Download CSV to save the table, or Clear list to start over.
  5. Use the tap pad to cross-check a track: tap on the beat for a few bars and read the BPM.

Example

A 3:42 house track at 124 BPM in A minor, MP3 44.1 kHz stereo

night-drive.mp3, 8.9 MB
Decoded to 22,050 Hz mono, 4.9 million samples
Onset envelope: 19,100 frames at 86.1 per second
Autocorrelation peak near lag 41.6 frames, refined by Fourier scan

Card and CSV row

Tempo 124.0 BPM (alternative offered: 62.0), steady in 100% of 12-second windows
Key A minor 8A, r = 0.88, runner-up C major (8B), tuning +4 cents

file,duration_seconds,bpm,key,camelot,key_correlation,tempo_confidence
night-drive.mp3,222.0,124.0,A minor,8A,0.88,0.94

Tips for best results

  • Use the whole track rather than a clip. The Fourier refinement gets sharper the longer the audio is, and a 30-second excerpt can only fix the tempo to about 2 BPM.
  • When the result is exactly half or double the tempo you expected, press the alternative on the card. Pop at 70 BPM and dance at 140 share the same pulse, and either is a defensible answer.
  • For tracks with a long intro of pads or ambience, the overall estimate still follows the beat that dominates; check the steadiness figure, and cut the file to the section that matters if it is low.
  • A key whose gap to the runner-up is under 0.05 is a toss-up between relative keys, such as A minor and C major. The card says so and names the runner-up, and the Camelot codes of the pair share a number.
  • A strong sub-bass or a heavily detuned recording can pull the key. The tuning readout shows how far the track sits from A440, which also explains a key that looks off by a semitone in a sped-up or slowed-down version.

Common pitfalls

Tempo estimation is hard on music without a steady pulse: rubato piano, free jazz, a cappella and live recordings that drift. The card then shows a weak pulse and a low steadiness figure, and the BPM should not be trusted.

Tempo changes within a track are averaged. A song that speeds up from 100 to 120 BPM gets an in-between figure and a low steadiness reading rather than two tempos.

Half and double errors are the usual failure. A track with prominent hi-hats on eighth notes can read at twice its felt tempo, and a slow track with a strong backbeat can read at half. The buttons exist for this, and the page does not guess which you prefer.

Key detection assumes the music is in one key and uses the major and minor scales. Modal tunes, heavy modulation, atonal music and percussion-only loops give a low correlation and a key that means little.

Decoding is bounded by memory: a file longer than 30 minutes is refused with a message, because the decoded samples must fit in the tab.

How the figures were checked

Synthetic click tracks at 60, 75, 90, 100, 120, 128, 140 and 174 BPM, with an accent on every fourth click and a little noise, were analysed in 60-second lengths and each came back at the exact tempo. Drum patterns with a kick on beats 1 and 3, a snare on 2 and 4 and eighth-note hats came back right at 100 (lightly swung) and 126, but doubled the tempo at 80 BPM and halved it at 150, the half-and-double ambiguity described above.

For key, triads and scale-based melodies with harmonic overtones were generated in C major, G major, D minor, F# minor and Bb major, with some tuned 20 to 30 cents off, and all were identified correctly, with the tuning offset read back within one cent. A bare C major triad on its own is ambiguous with A minor, which is why the correlation margin is shown.

What leaves the tab

Nothing about your files is sent anywhere. Decoding uses the browser's own decoder, the analysis runs in a worker loaded from this site, and the results exist only in the open tab and in the CSV you choose to save.

Frequently asked questions

Why is my tempo exactly half or double what I expected?

Tempo has an inherent octave ambiguity: the pulse you tap and the pulse that dominates the sound can differ by a factor of two. Each card offers the half and double values as buttons, and the CSV uses the one you select.

How accurate is the key?

It is a statistical match against 24 standard key profiles, so it works best on tonal music with a clear home note. The card shows the correlation and the runner-up; when the gap is small, the relative major or minor is just as likely.

What does the Camelot code mean?

It is a numbering of keys around the circle of fifths. 8A is A minor and 8B is C major. Tracks with the same number, or numbers one apart on the same letter, are the ones that mix harmonically.

Is there a limit on batch size?

30 files per list, each up to 30 minutes. They are processed one at a time, so a big batch takes a while but does not use more memory.