Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: foo_bpm (Read 159885 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

foo_bpm

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!

foo_bpm

Reply #1
Very nice! I need to test it out first, but I'm not sure I'd have been able to come up with a better algorithm. I'm excited for the source-code release of this.

foo_bpm

Reply #2
Very cool!  Looking forward to trying this.  Thanks!

foo_bpm

Reply #3
I'm gonna try this, sounds very cool!

Will it also be possible to use the bpm value in title formatting? (something like %BPM%)

foo_bpm

Reply #4
Will it also be possible to use the bpm value in title formatting? (something like %BPM%)

Since the results are written to the file tags, it should be possible to use %bpm% for any file which has already been scanned.

foo_bpm

Reply #5
Yep, that's not a problem. I have a column in my playlist to display %BPM% and it works just fine, so it should be available anywhere in foobar2000 you can use % style formatting.

Edit: What kode54 said

foo_bpm

Reply #6
I just found out, it's awesome!


p.s. The command in my context menu is still under legacy commands, could you make a separate context group for it?

foo_bpm

Reply #7
thanks for this, just having a play with it now by throwing it at various styles of music.

one suggestion so far, would it be possible to have a Results Window open displaying the results once the analysis is complete?

thanks again

foo_bpm

Reply #8
p.s. The command in my context menu is still under legacy commands, could you make a separate context group for it?

Are you using one of the fb2k 1.0 betas? The 1.0 SDK might need to be made available before I can change the context menu like that. Can anyone confirm this? I was thinking of just moving it under Utils or something anyways.

Quote from: Jack Schmaltz link=msg=0 date=
one suggestion so far, would it be possible to have a Results Window open displaying the results once the analysis is complete?

Yep, it's on my do to list

foo_bpm

Reply #9
p.s. The command in my context menu is still under legacy commands, could you make a separate context group for it?

Are you using one of the fb2k 1.0 betas? The 1.0 SDK might need to be made available before I can change the context menu like that. Can anyone confirm this? I was thinking of just moving it under Utils or something anyways.

Yes I'm using 1.0 beta 5. I forgot about the SDK, i think you're right there. Utils would be a good group i guess

foo_bpm

Reply #10
Yep, it's on my do to list


ah, my apologies. i did read the to do list but obviously didn't sink in.

so far the results are very accurate with styles like Psy-Trance & Hardcore Techno, a bit off with some Breakcore/Hardcore Techno i have but the beats on the inaccurate results are fairly inconsistant anyway so isn't a fault of the component in my opinion.

looking forward to the development of this, thanks again

foo_bpm

Reply #11
Autechre, Aphex Twin and Squarepusher were the yard sticks for the more extreme BPM tests and the component doesn't do too badly. You're right though that the results can be fairly inaccurate when it comes to genres like that. Hopefully things will improve!

foo_bpm

Reply #12
if i can help in anyway with regards to testing & sending results etc. please let me know as i'd be more than happy to help, as like yourself i like to know the bpm's for dj'ing purposes & currently do it manually with a bpm counter.

regarding testing again, some Drum & Bass i have doesn't appear to perform greatly, with it either being spot on or very off. the off results having pretty consistant beats also.

i can see this component being my new fave

foo_bpm

Reply #13
Alright, that'd be cool. I'll PM you if I need some more testing done. What are the artists/names of some of the songs where the component gives poor results? I may have them in my collection.

foo_bpm

Reply #14
some of the inaccurate ones so far:

I:gor - Icebreaker (foo_bpm:157.3 / manual bpm:200)
I:gor - God Left This Place (foo_bpm:171.0 / manual bpm:185)
I:gor - A Man With A Gun (foo_bpm:167.3 / manual bpm:185)
Nanotek - Better Place (foo_bpm: 116.1 / manual bpm:174)
Current Value - The Edge Of The Cliff (foo_bpm:132.4 / manual bpm:174)
Throttler - Overbrewed (foo_bpm:122.8 / manual bpm:184)
DJ G-I-S - Savage (Technical Itch Remix) (foo_bpm:119.9 / manual bpm:179)

i'm startled by this plugin, half the tracks i scan to try & catch it out work brilliantly, great work.
some come through at half bpm, but as you have already pointed this out & i have noticed the same behaviour previously with other auto bpm counters i won't add them as inaccurate.

foo_bpm

Reply #15
If the BPMs were simply normalized to between 100 and 200 it would be fine, I think. Doubled/halved BPMs are basically identical anyhow.

foo_bpm

Reply #16
Thanks!

Any chance the written tag-field could be customized in the future?
Can't wait for a HD-AAC encoder :P

foo_bpm

Reply #17
Thanks everyone for the encouraging comments. I'm just in the process of cleaning up the code, then will get stuck into the requests raised so far.

some of the inaccurate ones so far:

<tracklist>

Thanks for the feedback. I'll look into the results when I have a chance.


Any chance the written tag-field could be customized in the future?

I shall add it to my to do list


foo_bpm

Reply #19
The plugin should skip over any tracks that already have the BPM tag.. so perhaps it's getting stuck not because the track already has a BPM tag, but for some other reason.

If you analyse each track in the album individually, does it still get stuck?

foo_bpm

Reply #20
analyzing smaller portions (per album) works, so it seems not to be a problem of the individual track. problem happens at track 668 of 11715. analyzing this amount was a little bit optimistic

EDIT: Happens again with smaller portions (about 1000 tracks). Here whole portion hangs but analyzing individual album works. It stops at last track of an album (a Jethro Tull bootleg) next album again already bpm-tagged. (Thick as a brick (studio))

foo_bpm

Reply #21
OK, thanks for the feedback. Sounds like a bug when analysing large lists. The biggest I tested with was ~500 tracks, so I'll try out some 1000+ file lists to try reproduce the problem.

foo_bpm

Reply #22
I scanned over 3000 tracks at once yesterday without trouble, so it's not about list size. Unrelated question: Is it intentional that you decode entire track and not just short snippet from it?

foo_bpm

Reply #23
Reason unknown, but by right-clicking on a track in playlist, it won't show up. In beta 5.

 

foo_bpm

Reply #24
I scanned over 3000 tracks at once yesterday without trouble, so it's not about list size. Unrelated question: Is it intentional that you decode entire track and not just short snippet from it?

That's interesting about the playlist size. What file formats are your songs in grimes and Case? Also what are the sample rates, bit depth, number of channels, etc?

Only a short audio snippet (10 seconds) is used for a single BPM estimate, but that BPM estimate may be inaccurate. So to help ensure the correct BPM estimate is made, multiple 10 second snippets are taken from the song at different points and the BPMs calculated. So it may seem like the whole file is being decoded, but in reality it is multiple 10 second chunks of the file that are being decoded. So yes, it is by design

Reason unknown, but by right-clicking on a track in playlist, it won't show up. In beta 5.

It's probably under Legacy Commands. I'll fix things up once the 1.0 SDK is out.