I'm looking at building a BPM (beats per minute) counter for a friend.
Yes, I'd probably build one for myself too. It's a device that
displays the number of beats per minute of a given music piece. I'm
guessing that in theory it should be fairly simple - the audio is
filtered to provide a trigger signal, and then use a PIC to measure
between beats and do a little math.
I'm a little unsure on the audio filter portion, or how to deal with
songs with complex beats. Does anyone have any links to similar
projects? I've tried googling, and haven't come up with anything yet.
Any help or ideas would be appreciated.
Thanks!
Josh
--
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
-Douglas Adams
____________________________________________
This is deceptively hard. It wouldn't be trivial even if all songs had
straight 1/4 notes, but taking into account that many songs have off-beats,
8th, 16th, triplets, or any myriad of combination of musical mixes, it
becomes nearly impossible to do this with any degree of certainty.
One of my previous directors had a "tap pad" that would display the BPM that
a person tapped on it. It still has the 'human' factor, but considering the
complexity of even beginner music, I really don't see any other way to do
it.
Now, if you want a "tap pad", it would be easy to do on an 8-pin PIC with a
simple spst switch and a small LCD display.
Have a look around for "sound-to-light" or "colour organs"
Often these have 3 filters (bass, middle, top), the outputs of which
go on to drive coloured lights. Guitar bass or bass drum is generally
the tempo. If you make a variable low-end bandpass filter you could
tune it to whichever you think is the representative BPM. It would
depend on the instrumentation of the piece. Picking the tempo out
of something like Beethoven's Pastoral could be tricky - not a lot of
percussive notes. Dave Brubeck or Return To Forever - too much
percussion and syncopated too. You might have to log times between
triggers and look for a pattern. Then try it on a piece in 13:12 time
and see what result you get ;-)
Thanks for the link Jinx, and thanks for the reply Robert. I agree,
the task isn't as simple as it seems. I wish I could get a peek at
schematics for some of the DJ mixers that have this included. I'm
fairly sure theirs aren't that complex. There is a company (whose name
eludes me at the moment...Red Box, or something similar) that make a
unit capable of dealing with complex beats. It's also a bit more
expensive that I'd like.
I've considered a manual "tap box". It's not ideal when DJing as you'd
need to re-tap as you adjust the speed of the music. Also, getting
down to 0.1 beat accuracy might be a bit harder. That said, I'm game
to try it. At least if I get that working, I'll have something to
start with when I play with audio filters. Any ideas on debouncing a
switch? I can't have too much lag on it (ie a large RC) or it'll skew
the BPM measurement...right?
Josh
--
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
-Douglas Adams
On Thu, 23 Dec 2004 17:03:19 +1300, Jinx <spam_OUTjoecolquittTakeThisOuTclear.net.nz> wrote:
> www.elektor-electronics.co.uk/miniproj/download/030019uk.pdf
>
> Try this simple little circuit Josh (383kB)
> It's not ideal when DJing as you'd need to re-tap as you adjust
> the speed of the music. Also, getting down to 0.1 beat accuracy
> might be a bit harder
Is this for mostly Drum'n'Bass / Techno type music ? That should
be pretty easy to filter down to a beat. If this was for personal use
I think I'd characterise the track beforehand with a particular filter.
With two BPM units you could synchronise the two tracks. Then
you'd not have to worry about the absolute value of the count.
Punters are amazed not by an ultra-accurate LED display, they are
by seamless music
> Any ideas on debouncing a switch? I can't have too much lag
> on it (ie a large RC) or it'll skew the BPM measurement...right?
For something long-lasting and bounce-free I'd look at either
a magnet and Schmitt trigger Hall switch or a blade and opto-
interrupter. Anything that doesn't have mechanical contacts
> Thanks for the link Jinx, and thanks for the reply Robert. I agree,
> the task isn't as simple as it seems. I wish I could get a peek at
> schematics for some of the DJ mixers that have this included. I'm
> fairly sure theirs aren't that complex. There is a company (whose name
> eludes me at the moment...Red Box, or something similar) that make a
> unit capable of dealing with complex beats. It's also a bit more
> expensive that I'd like.
>
> I've considered a manual "tap box". It's not ideal when DJing as you'd
> need to re-tap as you adjust the speed of the music. Also, getting
> down to 0.1 beat accuracy might be a bit harder. That said, I'm game
> to try it. At least if I get that working, I'll have something to
> start with when I play with audio filters. Any ideas on debouncing a
> switch? I can't have too much lag on it (ie a large RC) or it'll skew
> the BPM measurement...right?
>
> Josh
> Any ideas on debouncing a switch? I can't have too much lag on it
> (ie a large RC) or it'll skew the BPM measurement...right?
Do your debounce in software. Trigger as soon as you see the
switch change state, then do your debouncing AFTER the trigger.
-Andy
=== Andrew Warren -- aiwKILLspamcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation
Ok, I'll wrap a few replies into this email. Andrew, thanks for the
interesting debouncing suggestion. I was hoping to use the CCP module,
so I'm not sure software debouncing will work. I'll have to check into
this though, I haven't studied up on the CCP module in awhile.
Dave, thanks for the advice about the Behringer stuff.
Jinx, good suggestion on the alternative switching methods. I'm not
sure I'd be able to get a hall effect or opto setup to "feel" right
though. How about a piezo disc with a rubber pad on top that can be
tapped? I might run into problems with levels though, what if one
person hits it hard while another hits it soft? I also need to sit
down and do the math for the fastest BPM I want to be able to measure,
then how much time to allow for switch bounce, and if I can use an RC
or something similar. Perhaps a mechanical switch will work (provided
the math works). We'll see. I figure that if I can get a manual
version working, I can then start playing with filters and measuring
the audio directly.
Ok, much to think about...thanks all!
Josh
--
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
-Douglas Adams
> > It's not ideal when DJing as you'd need to re-tap as you adjust
> > the speed of the music. Also, getting down to 0.1 beat accuracy
> > might be a bit harder
>
> Is this for mostly Drum'n'Bass / Techno type music ? That should
> be pretty easy to filter down to a beat. If this was for personal use
> I think I'd characterise the track beforehand with a particular filter.
> With two BPM units you could synchronise the two tracks. Then
> you'd not have to worry about the absolute value of the count.
>
> > Any ideas on debouncing a switch? I can't have too much lag
> > on it (ie a large RC) or it'll skew the BPM measurement...right?
>
> For something long-lasting and bounce-free I'd look at either
> a magnet and Schmitt trigger Hall switch or a blade and opto-
> interrupter. Anything that doesn't have mechanical contacts
>How about a piezo disc with a rubber pad on
>top that can be tapped?
I had been thinking in terms of an old crystal microphone. I used to have a
couple which were about 1.5" dia, and had soem largish holes in the front
shield. Glue a suitable plastic standoff onto that and then a small circular
sheet of Perspex on that as the "drum face", and even with fairly light taps
I suspect you would get enough output that you would need clamping diodes to
clip the level to prevent damage feeding straight into a pin.
Merry non-denominational time of festivities everyone
> Jinx, good suggestion on the alternative switching methods. I'm not
> sure I'd be able to get a hall effect or opto setup to "feel" right
> though
I was thinking an arrangement something along the lines of a Morse
tapper. Pretty easy to engineer, leaving just the button itself above
the panel. With either a magnetic or optical switch you need only a
few mm travel. Add notches and springs to get any tactile feedback
you want
> How about a piezo disc with a rubber pad on top that can be
> tapped? I might run into problems with levels though, what if one
> person hits it hard while another hits it soft?
Hitting hard wouldn't be a problem (there have been recent threads
about driving piezos and protecting the PIC against the piezo as an
accidental input device). Hitting it softly would be a problem. Even
electronic drum pads have a minimum whack
> down and do the math for the fastest BPM I want to be able to
> measure, then how much time to allow for switch bounce, and if I
> can use an RC or something similar
For this application I sincerely believe a conventional mechanical
switch should be avoided. For one thing, look at the environment
it'll be in. I can imagine after 6 months hot sweaty use a mechanical
switch would get very cruddy and have more bounce than a Linkin
Park mosh pit
> Andrew, thanks for the interesting debouncing suggestion. I was hoping
> to use the CCP module, so I'm not sure software debouncing will work.
> I'll have to check into this though, I haven't studied up on the CCP
> module in awhile.
Although my personal inclination would be to do the debouncing/BPM
timing with timing loops, you could use the CCP module: To debounce,
just ignore any capture times that are shorter than whatever debounce
threshold you choose.
-Andy
=== Andrew Warren - aiwspam_OUTcypress.com
===
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
> > I was hoping
> > to use the CCP module, so I'm not sure software debouncing will work.
> > I'll have to check into this though, I haven't studied up on the CCP
> > module in awhile.
You'll have to use a fairly low crystal frequency if you plan to use
capture(unless the music you listen to is extremely hyper).
I was looking idly at such things last week. They are are doing
another batch of the bpm units that output midi in the next couple of
weeks, but they are more than I hoped to spend too - that always
suggests its more complicated than it seems.
Merry Xmas
Nick
>There is a company (whose name
>eludes me at the moment...Red Box, or something similar) that make a
>unit capable of dealing with complex beats. It's also a bit more
>expensive that I'd like.