Audio input and waveform analysis

Hi, firstly I'm very new to the arduino so forgive me if something I say doesn't make sense.

What I'm trying to do is have sound input from a Ipod or mp3 player into the arduino which then will drive a set of motors to the waveform of the music. I know I can do this thorugh processing but I don't want to have the arduino attached to it. My arduino is the ATMEGA328 if that makes any difference. It doesn't need to be exact just so that people can see it's reacting to the music.

Any help on this would be great.

Well, basically you want to feed the sound output into one of the Arduino's analog input pins; once you've done that, you can use the analogRead() function to get a voltage level (corresponding to the waveform's voltage reading) as a value 0-1023 into an integer variable. Once you have it stored in the variable, then the tricky part (but code does exist out there for this - somewhere) would be to feed the values (as a small array of integers, I would imagine) into a FFT algorithm/function, in order to process the waveform sampled into whatever number of frequency bands you desire; from there you can use those levels to drive whatever other code you need.

Now, the audio input will be tricky - you are probably gonna want to measure it; it should be around 1V peak-to-peak for regular line-level outputs, but it can vary. This is an AC waveform, so you can't just feed it directly into the analog input (well, you can, but it will likely clip the negative voltage levels - giving you only half of the waveform); you must raise the level of it so that the signal is above 0 volts (called a DC offset); I am not sure, but this should be possible to do by just putting a bit of voltage on the pin itself, after your bypass capacitor (inline with your source, between the source and the pin):

+V offset
audio |
source ----||-----+-----------> to Arduino Analog Pin
bypass
cap

The offset should be 1-2 volts. Measure the signal before and after the bypass cap with an o-scope to verify that the waveform is completely above 0 volts.

Hope this helps!

:slight_smile:

The Shifty VU Shield is a simple way to make the Arduino react to music. It listens to audio from a 3.5mm stereo jack and rectifies/smooths the audio, making an envelope voltage level available on analog inputs 2 and 3.

Thanks for the replies

Cr0sh - Thanks, thats seems easy enough to get the signal in properly

Macegr - Thanks, although I'd really would prefer to do this all through software since I know it can be done.

I found this (http://elm-chan.org/works/akilcd/report_e.html) Which aparently will work on my arduino however I can't get it to compile.

Did you manage to compile the code on an arduino?