An automatic volume tracker by KA7OEI:
It occurred to me that I did have a reference on which I could base an outboard volume control: The internal speakers of the TV. I surmised that I could “listen” to the audio level coming out of the speakers and based on that, adjust the volume of an outboard amplifier. I figured that this could work if I could place a sense microphone very close to the speaker and in this way the sound level at the microphone would be very high as compared to the room volume of the external loudspeakers and I could make it so that not only would the TV’s internal speakers still be quite low for a fairly high volume from the outboard speakers, but also prevent sound from the outboard speakers from being picked up by the microphone and cause the volume to increase even more in a feedback loop.
To test this theory I hacked together a bit of code that did nothing but measure the audio level from two sources: A microphone and the audio line output and then dump those levels, in dB, to the serial port where I could see what was going on . It seemed to look pretty good as the two audio sources seemed to track fairly well.
Read more Here