Beat Detector..... again

Hey all.
First off, I understand that this topic has had the HELL beat out of it already.

I understand two approaches. Either and external chip like MSGEQ7 or a FFT on the arduino itself outputting to MOFSETS via PWM and an external 9-12V power source. Inputs are typically Microphones or a 3.5 mm jack for L & R channels.

What I cant seem to locate is a single pre-existing code/DIY approach that ACTUALLY performs beat analysis vs just being triggered via bass frequency threshold. Ive already spent 2 days worth of free time searching these forums and the web. Any thought? and GO! :smiley:

Is there pre exisitng code that "looks" for common beat patterns such as 1/2, 1/4, 1/8, 1/16's and performs analysis as to whether a bass spike is actually a beat that falls on a set interval or ignores it if it falls outside of the interval?

I don't know how this is done "properly", but I've made a crude beat detector. It is crude and don't really want to publish the code, but I'll give you the basic concept.

  1. I read and save the peak value (presumably the beat).

  2. I delay about 1/4 second (maybe 200mS, I don't remember for sure) to prevent a false trigger.

  3. Then I look for another peak equal to (or greater than) the previous peak and over then next several milliseconds the trigger threshold drifts down in case the next beat isn't quite as strong as the last one.

  4. When a beat is triggered, I save that as the new threshold and start the loop over.

This is NOT perfect and it's NOT triggered by every beat. But that's OK for my sound activated lighting effects because I don't really want a boring-constant 1-2-3-4-1-2-3-4...

I don't do any bass filtering. I don't know if that would make it better or not. Sometimes there is a snare drum that emphasizes the beat.

What I think WOULD really help would be something that calculates and "remembers" the timing... For example, when you dance or tap your foot to the beat you don't wait 'til you hear the beat... You "get in rhythm" and you anticipate the next beat.

...outputting to MOFSETS via PWM and an external 9-12V power source.

Finding the beat and whatever you do at the output are two different things, related only by whatever you want to do in software.... There are DJ controllers that show the beat in BPM on 7-segment displays.

So your program records the inital highest amplitude. Delays then sees if a >= amplitude presents itself over the next few seconds. The time between these beats would be revorded as the anticipatory time? Then take that anticipatory time as a value and set an if statement to only be true if both the anticipatory time and the expected allmplitude are met? The thing about beats though, i can take a 1/16 beat track and tap my foot at 1/16, 1/8, 1/4 and 1/2... Any division under 1/16. Maybe have a potentiometer tell the program to utilize the highest value or lowest denominator it "finds" in the audio? This would account for different peoples preference.