I don't think this is trivial, and this question should probably be moved to stackoverflow.
There is as far as I know no
procfs interface for accessing the final (ALSA) [audio] mix; there's not even a guarantee that there is such a thing in software, as some hardware (such as
emu10k1) performs its own mixing, although I admittedly have no idea how that works.
There's also the matter of multiple audio outputs (digital(like SPDIF), analog, headphons or speakers, etc) and multiple speaker configurations on the same card, not to mention the possibility of multiple cards.
The best bet is presumably to try to tap into whichever ALSA device is used (Presumably
hw0 if mixing is occurring in a sound subsystem like pulseaudio, or
dmix if no sound subsystem is used), since this is the "last step" before the audio reaches hardware. That being said, I have no idea if this is possible; probably not.
If you can assume that the user is using something like pulseaudio, then the task becomes much easier. Software such as pavucontrol implements this already, as seen under the Playback tab, as well as pre-final-mix stages under Output devices. Technically, this involves getting the audio stream itself, then converting it to the frequency domain (eg by performing StFt) in order to visualize it in some fashion; all you really need for this is access to the audio stream, and pulseaudio can provide this (like pavucontrol does) via a sink.
I'm not being of much help, am I? If I were you and just wanted this for my desktop, and if I were using pulseaudio(which I myself happen to use), my first goal would be to attempt to obtain the final mix stream. The guys in this thread seem to have figured out an eloquent method of doing that using only
pacmd, which could quite easily be done programmatically as well.
When you've got ahold of the audio stream, only the math remains :-)