Hey guys I'm currently working on a project and I need a program that loads an mp3 file, finds out it's bpm (Beats per minute) and returns me that value. Preferred language is C but python can work too. I'm really stuck in this could really use your help. It's an IOS app (music player) and I wanna use bpm of the song to help in creating playlist. Not looking for an Xcode solution. Need to program in C and then embed C in my IOS app. Could really use some help guys.
3 Answers
There is no straightforward way to detect beat just by read mp3 file. You will first need to explore various beat detection algorithms and find appropriate one to suite your requirement. You can get some help from this.
How to detect the BPM of a song in php
Also this particular article explain nicely about one such beat detection algorithm http://www.flipcode.com/misc/BeatDetectionAlgorithms.pdf
You will also need to get hold of some audio/video framework to decode mp3 file. FFMS2 gives you decoded audio sample from mp3 file and also from video file.
https://code.google.com/p/ffmpegsource/
To process these raw sample you can take help Portaudio open source framework or you can do it on your own.
Both the above framework are easy to use and set-up.
Apart from this you can look into existing implementation of beat finder in Audacity which is an excellant open source tool to analyse audio.
http://audacity.sourceforge.net/
I hope the above information helps.
-
Thanks @praks411. This cleared up a lot of confusion that I had about how approach to a solution to this problem. – Xk0nSid Mar 09 '14 at 15:00
BPM isn´t a technical thing which can be read from the file or something like that.
You could try to gain some information by analyzing the raw audio data
(ie. amplitude, frequency...) and apply heuristics, but that is
a) not necessarily accurate and b) complicated.

- 11,268
- 3
- 32
- 49
If you're lucky, you could read that info from embedded metadata. ID3v2 for instance has a TBPM tag which could hold that value. But audio files are not required to contain that data, so it's a shaky solution at best.

- 253
- 2
- 12
-
Furthermore, there's one massive assumption in BPM metadata: that tracks have a constant tempo. – marko Mar 09 '14 at 11:15
-