IPB

Welcome Guest ( Log In | Register )

foo_bpm, Automatic song BPM analysis
fraganator
post Dec 21 2009, 16:33
Post #1





Group: Developer
Posts: 155
Joined: 22-March 06
Member No.: 28717



Updated to version 0.2.4.1. Download here: foo_bpm 0.2.4.1
From the changelist:

0.2.4.1 (20/04/2010)
- A few more bug fixes. Songs where the sample rate can not be queried will have the BPM set to zero.
- Context menu option to double/halve BPMs of selected tracks

0.2.4 (01/02/2010)
- Recompiled to include static link the Visual Studio 2008 Runtime. Download the static version if you're having runtime problems.

0.2.4 (12/01/2010)
- Crash report fix (component about info)

0.2.3 (11/01/2010)
- Updated to foobar2000 1.0 SDK
- Added double/halve buttons to results dialog
- Added option to auto write tags after analysis
- Limit preference range inputs
- Crash report fix (using info not yet cached)

Please note: foobar2000 1.0 is now the minimum supported version.

You can access the manual BPM calculation window through the context menu (right-click->BPM Analysis->Manually tap BPM for current track). Clicking the Update Tag button will write the BPM to the currently playing file.

No changes have been made to the algorithm itself, but the parameters are now available for tweaking. You will probably have the most luck experimenting with the "Samples Per Song" value, followed by "Seconds Per Sample". Try increasing one or both, though calculation speed will take a hit.

Here's a quick overview of some of the parameters:
"Seconds Per Sample" - The number of seconds of audio grabbed from the file at any one time. The result of this sample produces a single BPM value.
"Samples Per Song" - The number of times we grab an audio sample from the file. This determines the size of the final list of candidate BPMs.
"Sample Offset (Min/Max)" - When grabbing audio samples from a file, start from the minimum offset and move towards the max offset. These values are used to avoid slow fade in or fade outs of songs.
"Calculated BPM (Min/Max)" - Limits the range of the BPM calculation to these values. Change the min and max to suit particular styles of music (e.g. 70-110 for hip-hop, 150-200 for d'n'b, etc)

-----------------------------

Hi everyone,

I'd like to introduce my first foobar2000 component: foo_bpm

As the name suggests, it is designed to calculate the BPMs (beats per minute) of any tracks in foobar2000.

I like to DJ a bit in my spare time, and I also buy a fair number of CDs for DJing and general listening. The problem is when DJing, I'm not familiar enough with the tempo of my new tunes to drop them straight into mixes. So I wrote this component so I could use the foobar2000 to sort and manage new tracks by their BPM, helping me select new tracks to play with a minimum of fuss. The component could also presumably be used to come up with playlists of a certain tempo for exercise workouts, etc.

The BPM analysis algorithm is based loosely on the work presented in the paper Tempo and Beat Estimation of Musical Signals (pdf).

Here's a brief overview of how it works:
1. Grab a 10 second sample from the song
2. Transform the sample from the time domain into the frequency domain using windowed, overlapping FFTs, also know as Short Time Fourier Transforms (STFTs).
3. Onset (or beat) detection is performed on the resulting STFT. The onset detection function takes the spectral flux of the STFT to generate a list of candidate beats.
4. The candidate beats are run through an auto-correlation function to determine the dominant beat frequency, and hence the BPM.
5. These steps are repeated at different points throughout the song, resulting in a list of candidate BPMs.
6. The BPM list is sorted and the average mode value is chosen as the BPM.

The FFTW library is used for calculating the FFT. A dll for this library is included with foo_bpm.


Download:
foo_bpm 0.2.4.1

Installation:
- Download the above 7zip file.
- Unzip foo_bpm.dll to the foobar2000 components directory
- Unzip libfftw.dll to the foobar2000 directory (NOT the components directory)

Usage:
- Highlight one or more files in your playlist. Rightclick on them and select "BPM Analysis->Automatically analyse BPMs..."
- After the analysis has completed, the results are automatically written to the "BPM" field of the tag.
- If the BPM field already exists for a song, it will NOT be overwritten.

Known Problems:
- The calculated BPMs are not always accurate, especially for songs without obvious beats or large changes in tempo. You can compare the accuracy of the calculated BPM with the included manual BPM tapping function.
- In a number of cases a song's BPM may be calculated as double or half of its 'true' BPM. So don't be alarmed if you see some obviously slow R'n'B songs with BPMs of 180 or more! They are actually half of that.
- Songs shorter than 10 seconds will automatically have their BPM set to 0. This is by design as it isn't possible to accurately determine the BPM of such a short track.
- There can be large discrepancies between BPMs calculated to the nearest BPM and BPMs calculated to 1 or 2 decimal places. I would recommend using either 1 or 2 decimal places as they seem to be closer to the real BPM.
- Tapping the spacebar on the manual tapping window when the large Tap Here button loses focus will stop working. The button must be clicked again to regain focus so the spacebar will work.
- BPMs calculated for the same song at different bitrates (eg mp3 V0 vs mp3 V5) can have significantly different results. This relates to the spectral flux calculation and will be improved.

Future changes:
- Improve the current BPM algorithm (wrong BPMs, double/halved BPMs, overall speed)
- Implement other BPM algorithms such as this and this
- Add a menu option and dialog window with a button to manually calculate the BPM by tapping/clicking along with the current playing song- DONE
- Add a confirmation dialog after a BPM scan has completed before writing the values to the files (similar to ReplayGain) - DONE
- Add option to double/halve individual calulated BPMs if need be. - DONE Will also add to context menu. - ALSO DONE
- Add a properties page with all of the algorithm parameters available for tweaking - DONE
- Specialise the algorithm parameters for different genres, then automatically scan using those parameters based on the GENRE tag
- Cleanup and release the source code - DONE
- Handle manual BPM calculation when button is pressed down, not released


Please download it and let me know what you think! smile.gif

This post has been edited by fraganator: Apr 20 2010, 14:17
Go to the top of the page
+Quote Post

Posts in this topic
- fraganator   foo_bpm   Dec 21 2009, 16:33
- - Canar   Very nice! I need to test it out first, but I...   Dec 21 2009, 16:51
- - blonde   Very cool! Looking forward to trying this. T...   Dec 21 2009, 17:23
- - Keesface   I'm gonna try this, sounds very cool! Wil...   Dec 21 2009, 17:25
|- - kode54   QUOTE (Keesface @ Dec 21 2009, 08:25) Wil...   Dec 21 2009, 17:30
|- - fraganator   Yep, that's not a problem. I have a column in ...   Dec 21 2009, 17:32
- - Keesface   I just found out, it's awesome! p.s. The...   Dec 21 2009, 17:37
|- - fraganator   QUOTE (Keesface @ Dec 22 2009, 00:37) p.s...   Dec 21 2009, 17:47
|- - Keesface   QUOTE (fraganator @ Dec 21 2009, 17:47) Q...   Dec 21 2009, 17:52
- - Jack Schmaltz   thanks for this, just having a play with it now by...   Dec 21 2009, 17:43
- - Jack Schmaltz   QUOTE (fraganator @ Dec 21 2009, 16:47) Y...   Dec 21 2009, 17:53
- - fraganator   Autechre, Aphex Twin and Squarepusher were the yar...   Dec 21 2009, 18:01
- - Jack Schmaltz   if i can help in anyway with regards to testing ...   Dec 21 2009, 18:10
|- - fraganator   Alright, that'd be cool. I'll PM you if I ...   Dec 21 2009, 18:16
- - Jack Schmaltz   some of the inaccurate ones so far: I:gor - Icebr...   Dec 21 2009, 18:41
- - Canar   If the BPMs were simply normalized to between 100 ...   Dec 21 2009, 18:54
- - odyssey   Thanks! Any chance the written tag-field cou...   Dec 22 2009, 11:27
- - fraganator   Thanks everyone for the encouraging comments. I...   Dec 22 2009, 16:31
- - grimes   Analysing BPMs... get stuck. Next track (album) ha...   Dec 22 2009, 23:07
- - fraganator   The plugin should skip over any tracks that alread...   Dec 23 2009, 15:04
- - grimes   analyzing smaller portions (per album) works, so i...   Dec 23 2009, 15:30
- - fraganator   OK, thanks for the feedback. Sounds like a bug whe...   Dec 23 2009, 17:14
- - Case   I scanned over 3000 tracks at once yesterday witho...   Dec 23 2009, 18:20
- - Sylph   Reason unknown, but by right-clicking on a track i...   Dec 23 2009, 18:31
- - fraganator   QUOTE (Case @ Dec 24 2009, 01:20) I scann...   Dec 23 2009, 18:35
|- - Sylph   QUOTE (fraganator @ Dec 23 2009, 18:35) I...   Dec 23 2009, 20:46
- - Case   All my files were 44.1 kHz 16 bit stereo FLACs.   Dec 23 2009, 18:38
- - grimes   44100/16/Stereo In my opinion the mix of bpm-tagge...   Dec 23 2009, 18:42
- - fraganator   Perhaps the component didn't load at all. Does...   Dec 24 2009, 02:41
- - fraganator   QUOTE (grimes @ Dec 24 2009, 01:42) 44100...   Dec 24 2009, 14:18
- - fraganator   Version 0.1.1 has been released. See the first pos...   Dec 24 2009, 15:45
- - Jack Schmaltz   thanks for the update   Dec 24 2009, 16:44
- - neothe0ne   Would it be possible to have this component behave...   Dec 25 2009, 02:25
- - fraganator   QUOTE (fraganator @ Dec 21 2009, 23:33) F...   Dec 25 2009, 03:26
- - 2E7AH   I posted about bpm and some other tags here, and w...   Dec 30 2009, 07:42
- - fraganator   Thanks for the info 2E7AH, and doing up that nifty...   Dec 30 2009, 16:57
- - 2E7AH   Yeah, I should have tapped them before posting suc...   Dec 30 2009, 17:33
- - Jack Schmaltz   looking forward to the features in the next update...   Dec 30 2009, 18:23
- - fraganator   Version 0.2.0 is out. Please let me know if you ha...   Dec 30 2009, 19:55
- - 2E7AH   some major improvements, it really looks great now...   Dec 31 2009, 08:05
- - fraganator   QUOTE (2E7AH @ Dec 31 2009, 15:05) about ...   Dec 31 2009, 18:54
- - 2E7AH   Nice about granularity I was thinking about beat...   Dec 31 2009, 20:18
- - Steve Forte Rio   Big thank you for your plugin. Happy New Year...   Jan 1 2010, 12:09
- - fraganator   Version 0.2.1 is out. It contains a number of fixe...   Jan 1 2010, 18:46
- - q-stankovic   You forgot one bug fix! In the "Manual...   Jan 1 2010, 19:09
- - fraganator   QUOTE (q-stankovic @ Jan 2 2010, 02...   Jan 1 2010, 19:29
- - q-stankovic   QUOTE (fraganator @ Jan 1 2010, 19:29) I ...   Jan 1 2010, 19:37
|- - MedO   Changing the BPM precision changes the result for ...   Jan 1 2010, 21:27
- - Nemphael   I tried converting some files to compare BPMs. Mos...   Jan 1 2010, 23:08
- - fraganator   QUOTE (MedO @ Jan 2 2010, 04:27) Changing...   Jan 2 2010, 16:52
|- - MedO   QUOTE (fraganator @ Jan 2 2010, 17:52) QU...   Jan 2 2010, 18:29
- - robin75   ... finally one of my christmas wishes came true.....   Jan 3 2010, 18:51
- - soundberg   Just when I needed a BPM analyzer someone had just...   Jan 4 2010, 12:20
|- - Yirkha   QUOTE (soundberg @ Jan 4 2010, 12:20) Req...   Jan 4 2010, 15:13
- - fraganator   foo_bpm 0.2.2 has been uploaded. I've changed...   Jan 7 2010, 08:22
|- - MedO   I did some testing with the new version and got ve...   Jan 7 2010, 12:26
- - fraganator   Awesome work Thanks for taking the time to play a...   Jan 7 2010, 15:49
- - Spirit_of_the_ocean   I think the results are strange: This song: Dragon...   Jan 9 2010, 21:22
|- - odyssey   QUOTE (Spirit_of_the_ocean @ Jan 9 2010, 21...   Jan 9 2010, 21:33
|- - Spirit_of_the_ocean   Thanks for your advice. I will see what changes...   Jan 9 2010, 22:09
|- - Jose_Mancera   Has anybody been able to install this component un...   Jan 10 2010, 12:08
- - fbuser   You probably didn't put libfftw.dll in your ap...   Jan 10 2010, 12:46
|- - Jose_Mancera   QUOTE (fbuser @ Jan 10 2010, 12:46) You p...   Jan 10 2010, 13:19
- - fraganator   QUOTE (Jose_Mancera @ Jan 10 2010, 19:08)...   Jan 10 2010, 15:35
|- - Jose_Mancera   [/quote] You may need to install the Visual C++ 20...   Jan 10 2010, 16:16
- - ledge   Awesome plugin! Nice work. One thing though, ...   Jan 11 2010, 00:15
- - fraganator   Version 0.2.3 has been released. It was built usin...   Jan 11 2010, 07:57
- - fraganator   Version 0.2.4 is out. It contains only a minor bug...   Jan 12 2010, 15:45
- - Dj kourampies   Trying to find the correct settings to make it acc...   Jan 13 2010, 20:58
- - FunkyBrewster   Thank you for this awesome plugin! It's a...   Jan 16 2010, 18:57
- - fraganator   Thanks for the feedback I'm glad people are b...   Jan 17 2010, 03:37
- - tedgo   Thanks for this settings It really works (as well...   Jan 17 2010, 10:07
- - Squeller   Thanks for your plugin, well done AFAICS! As I...   Jan 17 2010, 11:49
- - Nemphael   I agree with Squeller, it would be nice if the com...   Jan 17 2010, 12:52
- - q-stankovic   QUOTE (Squeller @ Jan 17 2010, 11:49) Ano...   Jan 17 2010, 14:40
- - Dj kourampies   QUOTE (fraganator @ Jan 17 2010, 05:37) T...   Jan 17 2010, 21:24
- - Hengest   Crash report: trying to analyse an mp3 that has th...   Jan 18 2010, 02:45
|- - MedO   Attempting to detect BPM on a stream also causes f...   Jan 18 2010, 21:45
- - gpglang   THIS IS GREAT! I Have looked for this (and as ...   Jan 18 2010, 22:05
- - robin75   thanks for the double/halve button, love it!   Jan 19 2010, 09:08
- - sti3   Love this plugin. Thanks for your work! Noob...   Jan 24 2010, 20:52
|- - MedO   QUOTE (sti3 @ Jan 24 2010, 20:52) Also, f...   Jan 24 2010, 21:18
|- - sti3   QUOTE (MedO @ Jan 24 2010, 14:18) QUOTE (...   Jan 24 2010, 21:26
- - robin75   hi there, i have some problem with my portable ver...   Feb 1 2010, 11:58
- - fraganator   I suspect the other notebook has a different visua...   Feb 1 2010, 14:10
|- - robin75   QUOTE (fraganator @ Feb 1 2010, 14:10) I ...   Feb 1 2010, 14:25
- - fraganator   OK, I've recompiled it as a statically linked ...   Feb 1 2010, 14:30
|- - robin75   QUOTE (fraganator @ Feb 1 2010, 14:30) OK...   Feb 1 2010, 17:06
- - fraganator   QUOTE (robin75 @ Feb 2 2010, 00:06) it go...   Feb 2 2010, 06:23
- - Keesface   It would be nice to be able to load presets, so co...   Feb 2 2010, 16:57
- - fraganator   It's definitely planned for a future version. ...   Feb 2 2010, 17:01
- - odyssey   Have you considered making a component to scan for...   Feb 17 2010, 16:17
- - fraganator   Estimating the key wouldn't be too much of a s...   Feb 17 2010, 16:23
- - odyssey   I'm speechless! Thanks for your work, it...   Feb 17 2010, 16:29
- - megapeng09   I have a suggestion regarding the layout of the co...   Feb 22 2010, 18:59
- - --pv--   I do also love this component. Please consider the...   Feb 22 2010, 22:11
- - fraganator   Thanks for the feedback guys It's great to kn...   Feb 23 2010, 03:16
- - blargblarg   Thank you!!! Very nice!!!...   Mar 27 2010, 17:31
- - blargblarg   Here's my small suggestion: Option to auto-wri...   Mar 27 2010, 18:45
- - blargblarg   Could you explain what these settings do a bit? O...   Mar 28 2010, 01:09
2 Pages V   1 2 >


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 30th August 2014 - 07:55