Smallest AVR that can handle FFT?

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?

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.

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

Piece of cake.

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 :stuck_out_tongue: but don’t throw a micro at a project that doesn’t need one.

Magician: 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?

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.

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.

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

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! ;)

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 [u]Smoothing Example[/u] 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.

I thought I would add a bit to this…

I am in the process of writing/adapting some fft software for a ATTiny45/85, hopefully running at 16mhz and using 64 or 128 samples. I have a few theories about how I can grab the bass drum beat and have written the code but not tested it yet. I have also created an averager based on the volume of the incoming audio (using the same pre-fft array data), this average will be used to create a trigger threshold, which will end up being an output pulse of about 50ms which will react to 0-80hz signals, with no re-triggering possible for a further 200ms period.

I have written some other FFT/bassBeat/sequence/crossfading code, which is not that great, which also outputs 512channels of DMX. I needs some serious work with the filtering, but most of the rest of it works ok…

I shall keep working and post my results…

Regards Bob