How do I measure loudness?
Loudness is roughly correlated to RMS amplitude, not to peak amplitude, so you need to


sample the input regularly, recording the samples to memory 
take a chunk of samples and square each
take the average of all the resulting values 
square root


You can probably simplify this depending on how much accuracy you need.



Oh wait, you want analog output.  You can put the wave through a precision rectifier (schematics) to get the absolute value, and then filter with an RC filter to get its envelope, as in the circuitry leading to pin 5 of this schematic.  Instead of that IC, pin 5 would be your micro's ADC.  It's not RMS, but it will show you approximate loudness.  This is how most VU meters work.