MagicBPM SDK for developers
Add BPM detection to an iOS or Android app. The SDK processes audio on the device and updates the tempo while the music plays.
Overview
Send it audio from a microphone or your app’s audio engine. It updates the BPM as samples arrive and reports when the reading has settled. It does not need to wait for a finished recording.
Processing runs off the UI thread and makes no memory allocations in the audio path. The SDK keeps updating the tempo as new samples arrive.
The same Swift core and settings run on both platforms. It uses Accelerate on Apple devices and a small JNI bridge on Android. It has no third-party dependencies.
Connect your live audio stream using the included AVAudioEngine and AAudio capture layers, or feed samples from your own audio engine. Decoded audio from files works too.
One method finds repeating patterns. The other measures the time between note attacks. Using both helps it follow the tempo when the beat is harder to hear.
The SDK does not upload audio or need a network connection. Detection runs on the device.
Choose a tempo range and detection mode, and set how quiet the audio can get before detection pauses. Keep those choices behind the scenes or let your users adjust them.
Benchmarks
Accuracy is not the only concern for a live app. MagicBPM and aubio process audio as it arrives. As tested here, librosa, Apple’s MusicUnderstanding and Beat This! read the whole file before returning a tempo. MagicBPM Precise, the offline reading, runs MusicUnderstanding or Beat This! depending on the platform, 15 seconds at a time.
Reading live, MagicBPM scored higher than aubio on all five datasets, and higher than librosa and MusicUnderstanding on GiantSteps-Tempo, the electronic music dataset. Aubio used less processor time in the speed test. The highest scores went to the offline neural engines: MagicBPM Precise with Beat This! on GiantSteps-Tempo, Beat This! on its own on GTZAN, and MusicUnderstanding on the other three. Beat This! trained on two of those three, Ballroom and Hainsworth, so its scores there are left out. The results below cover accuracy, time to a stable reading, processor time, and platform support.
On tracks at 150 BPM or faster, mostly drum & bass, MagicBPM read 35% correctly and librosa 9%. Librosa starts from a guess of 120 BPM, so a 174 BPM track usually comes out near 116, two thirds of the real tempo.
MagicBPM doesn't win everywhere. It is tuned for music with a steady beat, and on GTZAN's jazz it read 36% to librosa's 46%. Every genre tested is in the table, the losses included.
| MagicBPMlive | MagicBPM Preciseoffline | librosaoffline | aubiolive | MusicUnderstandingoffline | |
|---|---|---|---|---|---|
| Right after | 8.9 s89% of tracks | 15 sone full window | 120 sthe whole track | 2.2 s77% of tracks | 120 sthe whole track |
| Processor time per minute of audio | 0.28 s | 0.17 sBeat This!2.11 sMusicUnderstanding | 0.12 s | 0.04 s | 0.68 splus 0.2 s to load, once |
MagicBPM Precise is the offline reading, and the neural network behind it depends on the platform. On iOS 27 and macOS 27 it is Apple's MusicUnderstanding. On older versions and on Android it is the Beat This! small0 model. Either way it reads completed 15 second windows and reports the median tempo across them, and the table has a column for each engine. The last two columns are the same two engines on their own, reading each file whole: MusicUnderstanding through Apple's framework, and small0 through its authors' code. On the 3 datasets that were not used to train small0, Precise read 82% of tracks within 4% of the labeled tempo with Beat This! and 79% with MusicUnderstanding, on average. On their own, with the whole file, Beat This! read 83% and MusicUnderstanding 76%. The MagicBPM live engine read 65%.
| Genre | Tracks | MagicBPMlive | MagicBPM Preciseoffline · Beat This! | MagicBPM Preciseoffline · MusicUnderstanding | librosaoffline | aubiolive | MusicUnderstandingoffline · Apple | Beat This!offline · small0 |
|---|---|---|---|---|---|---|---|---|
| GiantSteps-Tempo electronic, 2-minute previews | ||||||||
| All tracks | 629 | 70.4% | 87.0% | 77.4% | 58.7% | 43.1% | 65.8% | 86.0% |
| Deep house | 24 | 100.0% | 100.0% | 100.0% | 95.8% | 75.0% | 100.0% | 95.8% |
| House | 22 | 95.5% | 90.9% | 100.0% | 45.5% | 63.6% | 100.0% | 86.4% |
| Tech house | 21 | 95.2% | 100.0% | 100.0% | 100.0% | 71.4% | 100.0% | 100.0% |
| Psy-trance | 31 | 93.5% | 96.8% | 90.3% | 90.3% | 32.3% | 87.1% | 96.8% |
| Electro house | 21 | 90.5% | 85.7% | 85.7% | 76.2% | 71.4% | 66.7% | 90.5% |
| Trance | 69 | 89.9% | 95.7% | 91.3% | 97.1% | 63.8% | 65.2% | 95.7% |
| Techno | 58 | 89.7% | 87.9% | 94.8% | 79.3% | 63.8% | 86.2% | 91.4% |
| Progressive house | 19 | 84.2% | 100.0% | 100.0% | 89.5% | 68.4% | 100.0% | 100.0% |
| Breaks | 24 | 75.0% | 100.0% | 91.7% | 79.2% | 29.2% | 83.3% | 100.0% |
| Dubstep | 75 | 74.7% | 81.3% | 58.7% | 69.3% | 50.7% | 40.0% | 78.7% |
| Glitch hop | 17 | 70.6% | 82.4% | 70.6% | 47.1% | 35.3% | 70.6% | 76.5% |
| Electronica | 50 | 68.0% | 78.0% | 76.0% | 46.0% | 36.0% | 62.0% | 76.0% |
| Indie dance / nu disco | 11 | 63.6% | 100.0% | 100.0% | 36.4% | 36.4% | 90.9% | 100.0% |
| Hardcore / hard techno | 13 | 61.5% | 69.2% | 61.5% | 30.8% | 15.4% | 53.8% | 76.9% |
| Chill out | 14 | 57.1% | 78.6% | 57.1% | 57.1% | 57.1% | 64.3% | 78.6% |
| Drum & bass | 131 | 30.5% | 84.7% | 56.5% | 4.6% | 6.1% | 42.0% | 80.9% |
| Other, under 10 tracks each | 29 | 58.6% | 62.1% | 69.0% | 58.6% | 48.3% | 62.1% | 65.5% |
| GTZAN 10 genres, 30-second clips | ||||||||
| All tracks | 998 | 65.3% | 79.0% | 76.8% | 62.5% | 64.1% | 79.3% | 81.0% |
| Disco | 100 | 94.0% | 95.0% | 95.0% | 93.0% | 93.0% | 96.0% | 96.0% |
| Hip-hop | 100 | 91.0% | 95.0% | 99.0% | 77.0% | 81.0% | 98.0% | 96.0% |
| Pop | 100 | 76.0% | 87.0% | 89.0% | 67.0% | 72.0% | 89.0% | 90.0% |
| Rock | 100 | 74.0% | 89.0% | 89.0% | 76.0% | 77.0% | 92.0% | 92.0% |
| Blues | 100 | 69.0% | 74.0% | 73.0% | 65.0% | 63.0% | 77.0% | 73.0% |
| Reggae | 99 | 68.7% | 77.8% | 67.7% | 70.7% | 77.8% | 70.7% | 74.7% |
| Metal | 100 | 59.0% | 78.0% | 73.0% | 52.0% | 54.0% | 79.0% | 81.0% |
| Country | 100 | 49.0% | 81.0% | 70.0% | 46.0% | 53.0% | 77.0% | 83.0% |
| Jazz | 99 | 36.4% | 70.7% | 60.6% | 45.5% | 43.4% | 57.6% | 74.7% |
| Classical | 100 | 36.0% | 42.0% | 51.0% | 33.0% | 27.0% | 56.0% | 49.0% |
| Ballroom 8 dances, 30-second clips | ||||||||
| All tracks | 698 | 61.0% | 97.6%* | 81.7% | 54.0% | 58.0% | 85.5% | 97.6%* |
| Cha-cha-cha | 111 | 99.1% | 100.0%* | 99.1% | 100.0% | 98.2% | 100.0% | 100.0%* |
| Samba | 86 | 94.2% | 95.3%* | 95.3% | 61.6% | 77.9% | 95.3% | 96.5%* |
| Tango | 86 | 84.9% | 98.8%* | 97.7% | 98.8% | 91.9% | 98.8% | 98.8%* |
| Rumba | 98 | 84.7% | 100.0%* | 100.0% | 86.7% | 72.4% | 99.0% | 99.0%* |
| Waltz | 110 | 42.7% | 93.6%* | 77.3% | 3.6% | 10.0% | 92.7% | 95.5%* |
| Jive | 60 | 31.7% | 100.0%* | 85.0% | 50.0% | 71.7% | 78.3% | 100.0%* |
| Viennese waltz | 65 | 15.4% | 100.0%* | 78.5% | 7.7% | 30.8% | 96.9% | 96.9%* |
| Quickstep | 82 | 3.7% | 93.9%* | 11.0% | 4.9% | 6.1% | 12.2% | 93.9%* |
| Hainsworth 6 genres, rock to choral | ||||||||
| All tracks | 222 | 68.9% | 82.9%* | 81.1% | 67.6% | 65.8% | 83.3% | 82.0%* |
| Dance | 40 | 92.5% | 95.0%* | 92.5% | 87.5% | 87.5% | 97.5% | 95.0%* |
| Jazz | 40 | 75.0% | 80.0%* | 90.0% | 82.5% | 80.0% | 90.0% | 80.0%* |
| Rock/Pop | 68 | 75.0% | 89.7%* | 88.2% | 77.9% | 73.5% | 89.7% | 88.2%* |
| Folk | 22 | 72.7% | 81.8%* | 77.3% | 63.6% | 54.5% | 81.8% | 81.8%* |
| Classical | 30 | 50.0% | 63.3%* | 66.7% | 40.0% | 46.7% | 73.3% | 66.7%* |
| Choral | 22 | 18.2% | 72.7%* | 45.5% | 13.6% | 13.6% | 40.9% | 63.6%* |
| ACM MIRUM mostly pop and rock, no genre labels | ||||||||
| All tracks | 1,410 | 60.1% | 79.9% | 81.6% | 53.0% | 53.7% | 83.9% | 81.0% |
| MagicBPMlive | MagicBPM Preciseoffline | librosaoffline | aubiolive | MusicUnderstandingoffline | |
|---|---|---|---|---|---|
| iOS | iOS 18+ | iOS 18+Beat This!, MusicUnderstanding from iOS 27 | No | Yes | iOS 27+ |
| Android | Android 9+ | Android 9+Beat This! | No | From source | No |
| Mac | macOS 15+ | macOS 15+Beat This!, MusicUnderstanding from macOS 27 | Python | Yes | macOS 27+ |
| Windows and Linux | No | No | Python | Yes | No |
| Answers while it listens | Yes | Every 15 s | No | Yes | No |
A result counts as correct when it is within 4% of the labeled tempo, using MIREX Accuracy-1. Every engine uses its default settings. Librosa uses feature.tempo and reads the full file. Apple's MusicUnderstanding also reads the full file and has no live tempo mode. We tested it on a Mac running macOS 27. Aubio and MagicBPM process audio as it arrives. For aubio, we take the whole-track median from aubiotrack, as we do for MagicBPM. That is aubio's stronger reading: its aubio tempo summary scored 22.1% on GiantSteps-Tempo.
The speed test also uses GiantSteps-Tempo. "Right after" is the median amount of audio needed for a reading to become correct and stay correct for 5 seconds. The percentage below it is the share of tracks where that happened. Librosa and MusicUnderstanding return one result after reading the full file. Processor time is measured per minute of audio on an Apple M1 Pro, with one engine running at a time. Start-up is excluded. MagicBPM Precise has no tempo until its first 15 second window has played, and its time is four windows a minute at what one took here: 42 ms with Beat This!, and 528 ms with MusicUnderstanding, which reads the key in the same pass. For that time MagicBPM updates its reading hundreds of times a second, where librosa and MusicUnderstanding work out one reading per file. MusicUnderstanding also took 0.2 seconds to load its models once.
The platform table describes what each project ships. Aubio provides an iOS framework, and its source includes an Android build script. Librosa is a Python package. MusicUnderstanding ships with iOS and macOS 27. Dataset names link to their public audio and labels. We used GiantSteps-Tempo v2; GTZAN labels from TempoBeatDownbeat; corrected Ballroom and ACM MIRUM labels from tempo_eval; and Hainsworth's labels. Genres with fewer than 10 tracks share a row. The datasets, librosa, aubio and Beat This! are public, and MusicUnderstanding comes with macOS 27, so you can check these numbers yourself. Last run: October 2026.
MagicBPM Precise waits for each 15 second window to finish, so it does not provide a live reading. It reports the median tempo from consecutive windows, starting at the beginning of the file. Only windows where the engine finds at least 9 beats are counted. If no window qualifies, the track is scored as a miss. That happened on 5 of 3,957 tracks with Beat This! and on 2 with MusicUnderstanding. Beat This! is available under the MIT licence, and for the Precise column this test ran small0 through Core ML on a Mac. Its model file has to ship with the app. The Beat This! column is the same model run by its authors' code on each whole file. Its tempo is 60 divided by the median gap between its beats. Their larger model, final0, was not tested.
A Beat This! window took about 42 ms on an Apple M1 Pro. The first window after loading took about 200 ms. The Beat This! authors say small0 was trained on all of their data except GTZAN. Their paper lists Ballroom and Hainsworth as training data, but does not list GiantSteps-Tempo or ACM MIRUM. The table marks both Beat This! columns on Ballroom and Hainsworth with an asterisk. Across all 5 datasets, including those two, Precise averaged 85% with Beat This! and 80% with MusicUnderstanding. On their own, Beat This! averaged 86% and MusicUnderstanding 80%. The MagicBPM live engine averaged 65%.
Where it fits
Use live tempo readings to set the pace for loops and effects.
Help people find a workout pace that matches their music.
Let the tempo of the player’s music shape gameplay and visuals.
Help musicians follow their tempo as they practice and perform.
Tag audio clips with BPM to help creators plan edits and transitions.
Compare tempo readings across your recordings using the same engine on each platform.
Get in touch
Building an app that needs to follow live music? Tell us how you’re using audio and whether you’re targeting iOS, Android, or both.
Tell us what you’re building and which platforms you’re targeting. We’re happy to discuss pricing, licensing, and integration.
Email sdk@magicbpm.com