foo_bpm, Automatic song BPM analysis
foo_bpm, Automatic song BPM analysis
Dec 21 2009, 16:33
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:
- 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
- Recompiled to include static link the Visual Studio 2008 Runtime. Download the static version if you're having runtime problems.
- Crash report fix (component about info)
- 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)
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 the above 7zip file.
- Unzip foo_bpm.dll to the foobar2000 components directory
- Unzip libfftw.dll to the foobar2000 directory (NOT the components directory)
- 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.
- 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.
- 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!
This post has been edited by fraganator: Apr 20 2010, 14:17
|Lo-Fi Version||Time is now: 30th August 2014 - 07:55|