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
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.
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