audiogetavarage is a simple library you can use to interface with an audio input.
It reads data from an ADC pin and returns the RMS value of the input simply using rms avarage.
The root mean square (abbreviated RMS or rms), also known as the quadratic mean, is a statistical measure of the magnitude of a varying quantity.
Here is simply implemented by getting samples, for each of them making the root, then the mean for all the collected samples, and finally square the result.Atmega ADC can detect signal between 0 to 5v, when setup to 10bit, ADC has and accurancy of 1024 points.
The audio source is an AC input, when biased at is middle it has also negative voltage, thing about a sine wave with amplitude between 1 and -1.
The input should be biased such as the signal has it’s middle between the ADC max and mix, more or less at 2.5v, with a amplitude of 2.5v (max 5v, min 0v).
The most simple thing you can do to bias the input is putting a resistor in series with a DC decoupling capacitor in series with two bias resistor, one pull up, and one pull down. If you have a scope, you can check what’s the consequence of components above to the signal.
The above schematics (rev 02), provided as sample, is a simple microphone preamplifier. It is based on WM-61A panasonic capsule and TLC27L2 opamp.
This circuit is a derivation from John Conover WM-61A preamp. The reference is the schematic-6 found here: Using the Panasonic WM61A as a Measurement Microphone (John Conover).
An alternative and schematics is provided (rev 01), it implements some hardware low and high pass filter you may need in noise power environment.
For more detail: AVR Atmega audio input root mean square (RMS)