Simple BPM counter

Share your Audacity/Nyquist plug-ins here, or test drive the latest plug-ins submitted by Audacity users.

After testing a plug-in from this forum, please post feedback for the plug-in author.

Simple BPM counter

Permanent link to this post Posted by steve » Sun Jul 24, 2011 4:24 pm

An Analyze plug-in to count the BPM of the selected audio.
Beats are detected based on amplitude, so it should work well with a simple drum track (though it may give a multiple of the musical tempo, depending on the drum rhythm).
I would not expect this to work well with complex music as beats are detected only by whether there is a pulse of higher amplitude than the "threshold" level.

Installation instructions for Nyquist plug-ins: http://audacityteam.org/download/plugins

This plug-in requires Audacity 1.3.8 or later.

bpm-count.ny
(1.27 KiB) Downloaded 7597 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Simple BPM counter

Permanent link to this post Posted by Gale Andrews » Mon Jul 25, 2011 1:18 am

Found I had to lower the threshold to detect compound time more accurately but I guess that's expected.

Would I assume this could not be combined with a labelling function e.g. after labelling (if requested) it throws its message box?

I understand the BPM detection is only done done on the first minute, though in fact setting:

Code: Select all
(setq tlen (min (get-duration 1) 360.0)); 


seemed to give better results on 3 to 6 minute pop tracks than the (setq tlen (min (get-duration 1) 60.0)); as shipped. It took about a couple of seconds longer with the higher value but that was a price well worth paying.



Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Gale Andrews
Quality Assurance
 
Posts: 26089
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: Simple BPM counter

Permanent link to this post Posted by steve » Mon Jul 25, 2011 9:49 am

This plug-in was written in response to a request for counting heartbeats. I'm waiting to hear back from that user, but I think it should work quite well for that purpose.

For use with music this plug-in is extremely limited as it currently is. To be really useful it would need to have much more sophisticated beat detection. Currently it detects a beat when the amplitude exceeds the threshold value. A long sustained high amplitude sound would be counted as one beat. It takes no account of rhythm so a rhythm of "beat-rest-rest-beat" would be counted as 2 beats rather than 4. If the selection includes silence before or after the actual recording, then this will throw the BPM calculation way out.

When testing on a click track, a 60 second sample was sufficient to provide accuracy of +/- 1 BPM. I think it is necessary to have some limit on the maximum duration that is analysed, and this will be particularly true if a more sophisticated (much slower and heavier on RAM) beat detection algorithm is used, but for now I've increased the max up to 10 minutes which still completes in a reasonable time.

Gale Andrews wrote:Would I assume this could not be combined with a labelling function e.g. after labelling (if requested) it throws its message box?

Nyquist plug-ins can only return 1 result, so a label track OR text in a dialogue box may be returned.
However, a Nyquist plug-in can return a label track (or sound) AND output text into the debug window (requires that the Debug button is pressed).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Simple BPM counter

Permanent link to this post Posted by Gale Andrews » Tue Jul 26, 2011 3:11 am

As I'm sure you figured, I'd be happy to replace the beat.ny shipped in Audacity with something "better". More accurate detection would be just part of the aim. Could you make user-intelligible debug output that just said "BPM was detected as x", then labelled the detected beats?


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Gale Andrews
Quality Assurance
 
Posts: 26089
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: Simple BPM counter

Permanent link to this post Posted by steve » Tue Jul 26, 2011 12:18 pm

Accurate beat detection is very tricky.

I could quite easily add a "beat count" to the Debug window of beat.ny, or adapt this BPM counter so that it outputs labels and shows the BPM in the Debug window.
The main problem with both of these ideas is that beat detection for music is very poor with both of these plug-ins. The number of missed beats and additional false beats will make the BPM count hopelessly inaccurate.

I think that what is required is:
a) Much more accurate beat detection (very tricky).
b) Analysis of the detected beats that will reject false beats and calculate probable missing beats (very tricky).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Simple BPM counter

Permanent link to this post Posted by steve » Tue Jul 26, 2011 12:30 pm

steve wrote:I think that what is required is:
a) Much more accurate beat detection (very tricky).

This code pulls out beats pretty well in some music (mono track only):

Code: Select all
(defun filter (s-in)
  (highpass8 (lp s-in 2000) 40))

(defun track (s-in)
  (mult 100.0
  (snd-avg (filter s-in) 100 100 op-average)))

(force-srate *sound-srate*
  (hp (snd-chase (track s) 0.001 0.5) 20))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Simple BPM counter

Permanent link to this post Posted by steve » Tue Jul 26, 2011 1:21 pm

Using a tweaked version of the code in my last post:

tracks000.png
tracks000.png (20.38 KiB) Viewed 43239 times


Track1. Detected beats with the new code.
Track 2. A click track at the same tempo as the music.
Track 3. The music being analysed.
Track 4. Output from beat.ny.

The new code has picked out the beats pretty well, but has included a half-beat and a couple of "phantom" beats.
beat.ny has missed the first couple of beats entirely, but then added lots of phantom beats toward the end of the selection.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Simple BPM counter

Permanent link to this post Posted by Gale Andrews » Wed Jul 27, 2011 2:20 am

Thanks, Steve. It looks quite promising. Any plug-in that output BPM count (in a debug window) and labels, and was even slightly more accurate than beat.ny would be an improvement.

How much of the detection problem is with setting the threshold correctly? Would a "pre-analysis" of the peaks and RMS help in suggesting a threshold value?

Most users I guess would select the whole track, but on the assumption tempo in pop songs rarely changes, should they be encouraged in the "help" to select a small part of the track with a cleanly defined and loud solo pulse?



Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Gale Andrews
Quality Assurance
 
Posts: 26089
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: Simple BPM counter

Permanent link to this post Posted by whbjr » Thu Jul 28, 2011 12:21 am

steve wrote:I could quite easily add a "beat count" to the Debug window of beat.ny, or adapt this BPM counter so that it outputs labels and shows the BPM in the Debug window.

How about putting the BPM in the labels? (Disclaimer: I haven't looked at how this plugin works, so I don't know if the following is possible or reasonable) Thus, the *current* BPM could be shown - for example, it might be an increasing number if the selected audio is speeding up.

Edit: Punctuation.
whbjr
 
Posts: 73
Joined: Thu Apr 14, 2011 4:20 pm
Operating System: Please select

Re: Simple BPM counter

Permanent link to this post Posted by steve » Thu Jul 28, 2011 9:57 am

whbjr wrote:How about putting the BPM in the labels? (Disclaimer: I haven't looked at how this plugin works, so I don't know if the following is possible or reasonable) Thus, the *current* BPM could be shown - for example, it might be an increasing number if the selected audio is speeding up.

I think it would make the labels rather cluttered. Even with just the number (eg, "140") that would put 1680 characters into the label text for a 4 minute track if every beat was detected. It might be better to output a rolling average every 15 seconds or so. However the main problem at the moment is that for most music the bpm count is hopelessly inaccurate.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Next

Return to New Plug-Ins



Who is online

Users browsing this forum: No registered users and 2 guests