First, here is a standard audio limiter. which clamps output on signals over unity gain. it has 100ms sampling response, and a 5ms integrator on the gain control signal to prevent clicks when it adjusts the output volume.
It's not possible to sample the maximum signal value over periods of less than 50ms when limiting audio-rate signals, otherwise low-frequency audio signals cause the limiter to rise and fall repeatedly on every sample (a distortion sometimes referred to as 'pumping'). Hence, to attain faster response to transient peaks, the ideal may be 20 sampling stages, with a rolling sample window, but that technique introduces a CPU load that could well be considered excessive in virtually all cases.
My enhanced design for a limiter halves response time, while maintaining CPU efficiency, by running two max-value accumulators with a 20Hz period from a single pulse train on a 50% duty cycle. The pulse train resets the max-value samplers on rising and falling edges alternately, thus creating a 50% sample window overlap and doubling response time to transient peaks, while sharing a single pulse train generator. This attains a 25ms response time to any transient peaks without introducing distortion in frequency fundamentals below 40Hz, as would occur without the overlapping sample windows.
This limiter design is available for download, as a Max file with gen~ object, at the link below.