If you want to work in the audio domain, consider calculating the RMS by simply squaring, low-passing, and taking the sqrt of the signal. The cutoff determines your averaging window.
You can implement relational operators in the audio domain by using [/~], as the same signal connected to both of its inputs will give 0 when the signal is 0, and 1 otherwise. There was a nice conversation on the PD facebook group on this. Thanks to Matt Barber.
For example:
[inlet~] [inlet~]
| \ |
| \ |
| \ |
| [max~]
| /
[-~ ]
| \
[/~ ]
|
[outlet~]
is [<~].
You can then use a lowpass to slow down the transitions between true or false. The impulse response of [rpole~] will decrease of ~60dB (1/1024) in a desired time by setting the feedback coefficient B with B = .001^t/T60. t is the feedback period N/Fc and T60 is the decay time in sec. [rpole~] is an IIR but it will truncate to 0 when its output gets very small. Approximately, using the formula above, it will get to 0 after a desired time if you multiply the decay time by .158065.
Cheers,
D