There's no need to build an analog peak detector if you're going to use a MCU.
Just use the internal ADC to sample the audio, then you can easily compute the peak inside. Computing the RMS value would be a nice addition too.
..
I considered this, as many MCUs have ADCs more than fast enough for audio - especially as one would only require 8-bits. I guess I could prototype a fast peak detector and compare the results side by side.
There IS a standard for Line/AUX levels (or rather two, plus an old one), which is what's should be expected for AUX inputs or outputs.
Manufacturers that do not stick to those standards should earn them a place in the "Audio Hall of Shame".
....
Volume control has no place in a Line/AUX signal, it is always at full amplitude.
Yes, this is the problem. I'm adding Aux inputs to devices that have not made any provision for them (we're talking cheap, but reasonable sounding stereos, two of them portable, being upgraded to run on Lithium batteries). But also the ones that do have Aux inputs, seem to vary in the level required, with some requiring significant amplification before, and one that actually requires attenuation, because it clips - using a bluetooth dongle, with its volume on max. I don't plan on inserting any volume control, although the devices that don't have Aux, I'll be putting Aux before the volume control in the unit, which seems to be the last thing before the main power amp - that way there's at least some consistency between Aux input and say, CD input.
So, it's a mishmash of different levels for each one, and the only real way of getting any kind of consistency is to add a preamp to the Aux in, with a fixed gain for that particular unit. I could just knock up a few boards with a stereo pot for setting the level, but it would be nice to have some actual measurements.
I'll admit a simple MCU + LCD is probably the cheapest and easiest way, I tend to over-complicate things, even though precision isn't really the goal here. What I was worried about was missing the peak amplitude.
A second aspect to your approach is the musical one. I mean, classical music has an immense dynamic range. "Nothing Else Matters" from Metallica as well.
Which peak do you want to store? And do you want to store it forever? What if an audio track starts at a very low level, would you then amplify it?
That's called a "Compandor".
I think the only time your peak level detector would give the desired result is at a Techno Rave where all OOMPH-OOMPH-OOMPH-OOMPH peaks are at saturation level already.
Well, I'm assuming here that the designers of these units made sure that the audio from the CD doesn't clip anything pre-power amp. Thats fixed amplitude, before the volume control. I'm not trying to add a compressor here, simply finding the max possible p-p voltage that these units have on their CD outputs (that goes to power amp) so I can set a similar level for the bluetooth dongle. As I said, usually this requires amplification, but sometimes attentuation, it all depends on what I find.
RMS is fine, but as you alluded to - RMS value.. when? The entire song/album? I figured finding the peak amplitude would be the best reference. Play the same track, (albeit one from bluetooth stream, and one from CD) and check the peak amplitude after the same song.