Calculating BPM using Javascript and the Spotify Web API

This demo uses the browser's Audio API to determine the tempo of a song, processing a chunk of 30 seconds of a song.

For more information, read the blog post Beat Detection Using JavaScript and the Web Audio API, from where I've taken the code to perform the track analysis, and my blog post where I explain some changes I made to the original algorithm and how I used Spotify's APIs to find and match tracks.

How this works:

  1. Search for the track on Spotify using their Web API
  2. Use the 30s preview MP3 as the source for the Audio API
  3. Apply a lowbass filter
  4. Find peaks
  5. Count intervals between peaks
  6. Group them