Go Down

Topic: Sound file and voltage on audio line. (Read 675 times) previous topic - next topic


Apr 18, 2015, 06:10 pm Last Edit: Apr 18, 2015, 08:00 pm by roineust
Hello there Arduino & audio mavin people!

I have this primitive hobby project, where an Arduino micro-controller board communicates with a smartphone, via the phone audio jack. The phone plays these Audio files and the Arduino samples the voltage on the audio line, in order to discern between high voltage, low voltage and no voltage. It's a simple project and it already works OK without any amplification and that is how i want it to stay, for this project (without amplification). 

But i have a suspicion that it could work even better, if i had a bit more knowledge about the types of sounds, that produce various levels of voltage on an audio line. What i am using now is a sound of a siren, that i recorded with such a gain, that it is full of distortion. i think distortion is good for my case, since it seems to be decoded by the Arduino, as a high voltage signal, most of the time.

But when i installed a sound editor software on my computer and set the graphic view of the sound file in a certain way, i saw that actually only small portions of that sound file, raise the sound magnitude to the maximum possible gain. My conclusion was that it must be surly possible to create a sound file, that produces a higher and/or constant voltage on the audio line. The sound file runs for 5-10 seconds.

So my question is what kind of sound sample would produce the highest constant voltage on an audio line?



Apr 19, 2015, 05:34 am Last Edit: Apr 19, 2015, 05:45 am by CommonRodent Reason: add warning
The general answer is that you can't make a 'constant voltage' with audio outputs, due to the way audio systems are designed, but this will depend on your phone. Sound equipment works with AC voltage levels which are analysed by their frequency. DC voltages and very low frequencies are generally unwanted.

The simplest case for your application would be a sine wave output. If you search for an audio test tone, at say 400Hz or 1kHz, this will be selected to have the maximum amplitude sine wave.

But when you read from the ADC you will be reading a random point on the sine wave, so you could see either a small voltage or a large voltage. To see what's going on you can try the following loop to capture successive samples (at a rate of ~10000 samples per second) and then send them back.

Code: [Select]
for (int i = 0; i < 200; i++)
 tempStore[i] = AnalogRead(0);

for (int i = 0; i < 200; i++)

Note, it's probably worth checking how you are connecting the audio to the arduino, which might require biasing to Vs/2. A negative voltage on the analogue input could damage it, if you are seeing any ADC readings of '0' something is wrong!

Go Up