Just in case anyone is interested, here is the source code to the AGC program (see previous post).
It is written in delphi, it is 20-odd years old; the Delphi version is outdated, the code, is probably not pretty and buggy.
You might be able to get it to compile - you might be able to make a half decent program using bits of it. If so, that's great. Crediting me would be nice, if you feel that way inclined.
Obviously, there is no warranty, and don't come to me crying if it blows your computer up. Or something.
Grab the source archive here