Author Topic: Music BPM detector circuit.  (Read 3462 times)

0 Members and 1 Guest are viewing this topic.

Offline Pine landTopic starter

  • Newbie
  • Posts: 2
  • Country: no
Music BPM detector circuit.
« on: December 21, 2019, 12:18:40 am »
Hello!

I want to make a beats per minute (BPM) detection circuit for a music signal to control LED lights. I have made a music box from scratch and now i want to make it pretty with fancy lights.

The requirements i want:
Digital output that can be used on a arduino nano as a "pulse" input
A system that behaves pretty much the same regardless of input signal amplitude (audio level)
Detection up to 400 BPM.
when this is connected i want as little noise as possible to get to the speakers.
variable threshold for the detection (for testing)

I have looked at peak detectors with diodes and op amps but i dont know if something like that will work. If we assume that the signal we want to detect the peaks of have the same max amplitude for a while (nobody changes the volume level) and its not periodic. how can we make it in hardware?



Some facts:
Voltage levels of 240Vac, 5V and 19,5V are already in the system.
No space or weight limit
 

Thanks for reading
Best regards
Eirik
 

Offline John B

  • Frequent Contributor
  • **
  • Posts: 800
  • Country: au
Re: Music BPM detector circuit.
« Reply #1 on: December 21, 2019, 02:28:37 am »
Essentially not possible unless the music is predictable and repetitive, like doof-doof rave or club stuff where there is a bass drum every beat. You need to choose something to trigger off.

If you want to trigger on transients, where it MIGHT be on the beat or a different rhythm then you'd be looking at a low-pass or maybe band-pass filter in the 40-120Hz region, then perhaps some automatic gain control before feeding that through a diode as a threshold detector. Then a comparator could trigger something like a monostable 555 which outputs a defined length output pulse.
 

Offline alanambrose

  • Frequent Contributor
  • **
  • Posts: 377
  • Country: gb
Re: Music BPM detector circuit.
« Reply #2 on: December 21, 2019, 06:40:46 pm »
Actually I think this might be possible.

I'm thinking a microphone and small amp circuit plus peak detector to pick out the amplitude envelope. Then a low pass or notch filter on the amplitude signal below ~10Hz (400bpm is 6.7Hz). Then an adc and a simple (low frequency) fft. Average the fft results over a few seconds. And then pick out the highest peak in the fft. That will give you the overall 'pulse' frequency, which will be the bpm.

I'm sure there are some fancier methods I can think of using the whole fft spectrum, but I'm guessing that the above will work OK. It won't be a perfect algorithm - for instance, if there's a pause (duh) or a free form time shift (e.g. during a cadenza) or maybe a jazz solo where the soloist deliberately plays outside the beat. But, if you think about it, if you listen to a short segment of some pieces of music, it's sometimes possible that you can't pick out the beat yourself anyway.

You may even be able to pick out the time signature by looking at where the emphasis re-occurs.

Of course, you will find it difficult to separate 3/4 time from 6/8 time (unless the emphasis thing above works ok) - but depending on your application that may not matter.

Alan
“A foolish consistency is the hobgoblin of little minds"
 

Offline ebastler

  • Super Contributor
  • ***
  • Posts: 6510
  • Country: de
Re: Music BPM detector circuit.
« Reply #3 on: December 22, 2019, 09:10:17 am »
It's possible, of course, but a robust solution probably requires enough signal processing to justify a software solution. Doesn't necessarily need an actual DSP, but you will be in the realm of digital signal processing (filtering, peak detection etc.).

This solution claims to work with a very simple audio interface and an Arduino to do the computation:
https://damian.pecke.tt/2015/03/02/beat-detection-on-the-arduino.html
https://www.hackster.io/Joao_Claro/arduino-beat-detector-d0a21f

A few more ideas:
https://github.com/chrvadala/music-beat-detector
http://mziccard.me/2015/05/28/beats-detection-algorithms-1/




« Last Edit: December 22, 2019, 09:19:18 am by ebastler »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf