I haven't done it...* A million years ago (back in the analog days) I made an analog expander** with an NE570 chip, but I didn't really know enough and it didn't work too well... Actually it "worked" fine, but it was too strong (it's a 2:1 ratio) and I didn't know about setting thresholds, etc.
It's not "hard" to do digitally, but it can be a little tricky to make a good-sounding one (getting the attack, release, threshold, etc., all set to the "right" parameters). And, maintaining good audio quality can be tricky too, especially the analog inputs/outputs. (And since compression boosts the quiet parts, it boosts any existing noise.)
If you can accept a little latency (delay) you may want to "look ahead". That is, start analyzing the audio immediately, and delay it a few milliseconds so you can do the "right" processing.
[u]Audacity[/u] is open source so if you want to see how they do compression & limiting you can look at the code. (Copying the code won't be of any use, since it's written for a computer and it's not optimized for real-time processing.)
too many movies and such think we can all hear whispers and love being inside of rooms that blow up.
If you are watching DVD/Blu-Ray movies with Dolby, your receiver (or software) should have a "DRC" or "Midnight" setting. Different manufacturers use different terminology so check the owner's manual for your receiver. See the bottom of page 6 of [u]The Dolby Metadata Guide[/u].
- Personally, I wouldn't do it. I'm not saying you shouldn't do it... This is just me... For a couple hundred dollars I could buy one. It would probably cost me at least half that much to build one, once you add-up the cost of a nice enclosure, a power supply, connectors, switches & controls, etc. And, it would take me a couple of months.
** Even back in the vinyl days, a lot of music was over compressed. Expansion (in theory) can recover some of the dynamics and more importantly it can push-down the surface noise during quiet & silent parts.