I have been messing around with @nathan s negative compression code, really cool stuff. Read more here. I was happy to read the explanation of why Compander doesn’t really work for short attack and release time (downsampling the input for detection) as this has been my own experience too, without knowing why.
Usually when I work with compression in a DAW context I don’t use autogain, instead I prefer setting the makeup gain manually. However, there are a couple of situations where autogain would be a nice feature to implement. First one is expansion (corresponding to slope > 1 in Nathan’s code, where slope is the reciprocal of ratio), since expansion has the potential for making the output extremely loud. Another case would be an ‘intelligent’ compressor which compresses the input material based on the loudness of the signal so that even very dynamic material will receive (close to) the same amount of compression - there are commercial plugins doing this already, can’t think of the names right now. This is useful for applying compression as an ‘envelope shaper’ on very dynamic material rather than just a way of controlling dynamics.
So how do you best implement autogain? I suppose you need to calculate the RMS which will either introduce latency or mean than the detection of sudden changes in the dynamics of the input signal will be delayed by the RMS window size. Is there a way to implement autogain (maybe not in a ‘perfect’ way) without introducing additional latency in the signal chain?