Umm, as was mentioned, this is a hard one. Didn't you ever wish your car radio would automatically adjust volume based on ambient cabin noise (going 65 with windows open vs parked in driveway)?? I also feel Perl is likely the wrong tool for this job. This sort of realtime stuff is usually done in C or assembly code (yikes!).
found something related....some winamp plug-ins that do exactly this...unfortunatelly, winamp doesn't control everything coming out the speakers, but only files/cd's it's playing