In Sound Forge (Sony), there is an option under the Normalize function to normalize on RMS. You can choose a desired peak RMS value and it will bring the gain up as necessary to cause that value to be the approximate RMS.
Sound Forge has an option that I haven't seen anywhere else, or maybe it does exist under other names. There's an option that specifies "When clipping occurs..." The default option is "Apply dynamic compression."
It looks like what the plugin is basically doing is computing a gain required to bring the RMS up, and then dealing with any points where clipping occurs by applying compression to only those parts. Some testing on some deliberately tweaked audio samples backed up this theory. Example: I took an entire piece of music and reduced its volume to -24db, and then added a single loud crash cymbal to the end which peaks at a full 0db. The normalizer brought the gain up on the entire music sequence without performing any compression, and then (significantly) compressed the crash cymbal. With the right setting, I was able to all but reproduce the original volume of the music, leaving only the cymbal compressed.
I would like to be able to approximate an effect like this using free tools. SoX has a compand function, but it will apply compression to the entire audio sample - not what I'm looking for. I basically want to be able to take a piece of audio that is largely quiet but has some very short bursts or segments of loud audio, and have those and only those segments compressed. While compression certainly distorts the audio a bit, it's a lot better than clipping!
Any ideas as to how an effect like this can be at least approximated if not actually produced using free tools, preferably Sox but open to other options?