Reading Audio Singals from a Headphone Jack

So I've been looking a little bit and I don't know what to look for.

But if you connected a headphone jack to an analog input(or 2 for stereo), would it be fairly easy to read signal and then make leds flash with the music. If there is a article or project about this already, a link would be great.

Look at this for the way to interface the audio into the arduino:-
http://interface.khm.de/index.php/labor/experimente/arduino-realtime-audio-processing/

It also contains code about sampling the sound, after that you can do what you want with it.

I realize now I put this in the wrong forum.

But anyways, what is the purpose of putting a capacitor in series with the audio in?

To make the input biased at 2.5V so the audio signal can swing both above and below this point. It is like putting a DC offset onto the input. That is why the potential divider is there at the other side of the capacitor. The capacitor also blocks this DC from getting into the audio output stage of your amplifier. (not good).

So with the offset, is it supposed to swing from 0-5v? instead of going -V? i've never worked with a DC offset before.

An audio signal will swing positive and negative, an Arduino can only measure positive signals. The DC off set is to allow these two systems to work together. Your audio output should be set to +/- 2.5v to get the full output range from the arduino.
With no signal you will see a value of 512 read from the analogue input. As the audio volume increases the readings will peak at a higher and lower value to this. At the maximum volume you get readings of 0 and 1023.

So if The arduino can only read positive. And then you said:

"Your audio output should be set to +/- 2.5v to get the full output range from the arduino."

Is that after the offset? If so I'm confused because it would still be a - value, so how will it read it?

Or am I looking at it wrong. Base is 2.5 so a +2.5 would actually be 5v and a -2.5 would be 0 v?

The audio side should be measured as a AC voltage on the audio device's side of the coupling capacitor. With a steady sine wave tone you should set the amplitude volume at 1.77 vac rms. That should keep any audio signal within the Arduino 0-5vdc range if using the 2.5vdc offset. Don't forget that the device and Arduino need to have their grounds wired together.

Lefty

Is that after the offset?

No it is before the offset.

Or am I looking at it wrong.

Making very heavy weather of a capacitor and voltage divider.

Base is 2.5 so a +2.5 would actually be 5v and a -2.5 would be 0 v?

Yes but don't worry you are not going to get an absolute reading anyway, just a number between 0 and 1023.
So an instantaneous audio voltage of +2.5 would present 5V to the arduino (2.5 audio + 2.5 DC offset).
Likewise an instantaneous audio voltage of -2.5 would present 0V to the arduino (-2.5 audio + 2.5 DC offset).

Once you get it wired in, it might be more clear to you if you then in your software map the signals range of 0-1023 to -2.5 to +2.5. Or to -100 to +100 and treat it as a percentage of signal.

Lefty

Looking at the schematic I am a little confused.

Between the 100k resistor and the pot, is it connected to the right side of the cap?

Same question for between the 4.7nf cap and the wiper on the pot?

The reason it's confusing is because one has a block dot and one doesnt.

Here is the schem

If lines cross then, No dot = no connection, dot = connection.

Lefty

Thats what I thought, but when I looked at the audio out section there was not dots. But I guess the wires aren't really crossing there.

It's only a dot when the wires cross, not when there is a T junction. There are no crossing wires in the audio out section.

In fact some people say it is bad practice to have crossing wires that join and that all joins should be done with T sections, but it is not universally adhered to.

Ok I figured it out. I was using a circuit simulator and it didn't the voltage just stayed at -2.5 and +2.5 but I didn't wait long enough for the cap to charge. Makes more sense now, the offset just adds it's voltage to the ac voltage correct?

the offset just adds it's voltage to the ac voltage correct?

Yep, you got it now. :sunglasses:
I think the pro engineers call it a summing junction.

Lefty