C# BPM Detector on Audio File
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Hi! My goal is a C# BPM Detector which can analyse audio files and produce a BPM reading.

I tried porting a JS beat detector, like this (minus the Spotify API code):
https://jmperezperez.com/bpm-detection-javascript/ with MediaFoundation reading the file and then NAudio converting it to a float array.

The premise of it is simple enough - for each 1/2 second of audio, the algorithm looks for peaks within and then compares the distances of all the peaks and sorts the intervals which occur most - with the most represented time interval indicating the BPM.

Unfortunately, I'm still not familiar enough with C# to get any type of accurate result with my efforts - it was producing really off-the-mark results. TBH I thought it'd be simple to port, and it probably is - but I'm going wrong somewhere. Please help me!

C# BPM Detector for existing audio files, ideally based on the Jose M Perez JS beat detector - but anything which has a fair amount of accuracy will work for me :)


awarded to TheOsch

Crowdsource coding tasks.

1 Solution

I found a sample that can appear to be what you need: https://github.com/matixmatix/bpmdetector/blob/master/BPMDetector.cs

However, if you don't like it and need just a translation of the algorithm by Jose M Perez, I'll make it in a few hours.

UPDATE: Done. You can see it at https://github.com/TheOsch/naudio-bpm . There's a class that contains almost literal translation of the JS code ( https://github.com/TheOsch/naudio-bpm/blob/master/NAudioBPM/NAudioBPM/BPMDetector.cs ) and a simplest console app showing how to use it.

Have previously looked at this one and the detection was much less accurate than the Jose M Perez one by a mile
verystack 1 month ago
Then I'll translate J.M.Perez's one. It won't take long, I know how to do it.
TheOsch 1 month ago
Done. Works exactly like the Peres's one
TheOsch 1 month ago
Sorry, if you've just cloned the project, please refresh it - I fixed some typos in the main program
TheOsch 1 month ago