Pages: [1]   Go Down
Author Topic: Smallest AVR that can handle FFT?  (Read 743 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I saw a project on Hackaday a long time ago which involved ATtiny85's flashing LED's in reaction to music. I don't know if that project used a MSGEQ7 or something, but I know it did definitely use an ATtiny85. Can it actually handle FFT, even if only to detect low-frequency sound (0-63Hzish) to flash an LED to a beat? If the '85 can't, what's the smallest AVR that can? Attiny84? '2313?
Logged

Montreal
Offline Offline
Edison Member
*
Karma: 23
Posts: 2485
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Depends on resolution / memory trade. With AtMega328 (2K) I have a project FFT-512. Basically, you can look on chips available memory size and divide by 4 to get approximate depth of fft.
OTOH, what you need is LPF, rather than fft. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So it is feasible to have an Attiny85 react to just the beat of music?
Logged

Montreal
Offline Offline
Edison Member
*
Karma: 23
Posts: 2485
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Piece of cake.
Logged

South England
Offline Offline
Full Member
***
Karma: 3
Posts: 205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If that's all you want it to do, you don't even need to use a microcontroller. A long time ago I built a circuit from some project book the name of which escapes me, that flashed LEDs according to the peaks of different frequencies using a few op-amps and some discrete components. As I recall, it wasn't all that complicated, and a piss-load easier than writing code. Of course if you need to do any intelligent decision-making other than just blinking lights, ignore what I just said :p but don't throw a micro at a project that doesn't need one.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Depends on resolution / memory trade. With AtMega328 (2K) I have a project FFT-512. Basically, you can look on chips available memory size and divide by 4 to get approximate depth of fft.
OTOH, what you need is LPF, rather than fft. 
Is a low-pass filter hardware or software?
Logged

Montreal
Offline Offline
Edison Member
*
Karma: 23
Posts: 2485
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Of course, you can filter in hardware, using simple RC circuits or active filters with transistors / operational amplifiers. But doing LPF in software, you 'd get more flexibility in changing parameters "on the go". Running average in Files/Examples/Analog/Smoothing of the Arduino IDE is LPF. What is important in music visualization, it's big dynamic range, to make LED flashing in quite and loud passages, you need a "compressor" or Automatic Gain Control (AGC) as well.
Logged

texas
Offline Offline
God Member
*****
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In case you all didn't already know, TI makes a really nice piece of active filter design software available for free.  I've used this and I was really impressed at how well it worked.  Looks like this is a new version, so I need to download it as well I suppose. 

http://www.ti.com/tool/FILTERPRO
Logged

Experience, it's what you get when you were expecting something else.

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, but I'm just looking for something that runs an the arduino. It sounds pretty cool from the description on the page.
Logged

Offline Offline
Edison Member
*
Karma: 22
Posts: 1162
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've never used FFT.   I've done some lighting effects, but everything I've done works off the volume (no frequency filtering and no true beat detection).

Accurate beat detection isn't that easy...   Detecting the bass isn't exactly the same as detecting the beat.  But IMO, a lighting effect that accurately pulses to the beat 1-2-3-4-1-2-3-4 is kind-of boring anyway! smiley-wink

Some people have done beat detection, so you might want to search the forum.  I think it requires two filters - One low-pass to filter-out everything except the bass, and a bandpass-filter tuned to the beat frequency (around 1/4 of a second or about 4Hz).   That 2nd filter is not to filter the signal (there should be no signal at 4Hz), it's used to filter the detected loudness envelope.   (If it was me, I'd probaly do the bass-filter in hardware and the beat-filter in software.)  Then if you wan to get really good, use some "fuzzy logic" to tune that 2nd filter and know when to expect the next beat...  That's how humans do it...  We don't wait 'till we hear the the beat and then tap our foot...  We know when that next beat is coming and we make tiny adjustments as we listen to keep our foot-tapping in-time with the music.

Something that's super-easy to do with just the volume (once you have the hardware setup so that you can read the loudness on an analog pin) is to compare the input to the average, and turn on the light/LED whenever the signal is louder than average.   That's more of a "flicker effect" than a beat effect, but its something simple to start with.

The Smoothing Example example shows you how to get a moving-average.   If you use a moving average, you won't need a sensitivity control, and your effect will automatically adjust itself to loud songs, quiet songs, and volume changes.  (In my application, I also switch automatically between the 1V and 5V analog references, depending on the signal level.)

I use a 20-second moving-average, updating the average-array once a second.  (Of course, I use the "blink without delay" style timing, so it can uns and flash the lights in-between updating the average.)


For some of my effects, I find the peak value in the average-array, and use that as my trigger threshold.  (For example, a chase effect that changes direction only when it hits a new peak.)  For other effects, I use the halfway point between the peak and average.   If you want to use the peak to detect the beat, you might pick a threshold that's something like 90% of the peak value in your array.   You don't want one big peak to throw everything off...

For my very-crude beat detection, I just delay (or ignore peaks) for about 1/5th of a second, so that I don't get to many beats/flashes close-together.   That's nothing like accurate beat detection, but you do get the feeling the that the lights are being triggered with the beat, and it's easy to do!  ...Actually, there's one more "tweek" I'm using.  I increase the sensitivity while waiting for the next beat.     So... I'm unlikely to get a beat trigger exactly when 1/5th of a second is up, but after 1/2 second the sensitivity is going up and I'm very-likely to detect a beat.   
Logged

Pages: [1]   Go Up
Jump to: