Pages: [1] 2   Go Down
Author Topic: Reading Audio Singals from a Headphone Jack  (Read 5900 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31382
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31382
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31382
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: December 14, 2009, 12:08:16 pm by vindicate » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  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
« Last Edit: December 14, 2009, 06:12:18 pm by retrolefty » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31382
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is that after the offset?

No it is before the offset.

Quote
Or am I looking at it wrong.

Making very heavy weather of a capacitor and voltage divider.

Quote
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).
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

« Last Edit: December 15, 2009, 10:20:35 am by vindicate » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Lefty
« Last Edit: December 15, 2009, 10:24:58 am by retrolefty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31382
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1] 2   Go Up
Jump to: