Oh, well, I've never done anything like that... I gather fft is a (computationally heavy?) of getting autocorrelation.
Have you seen JS: FFT Peak-Following Filter?
As far as a simple moving average goes, I've got something like this, which was for a jsfx compressor that I never finished.
the circular buffer (array) remembers scaled values. It has LENGTH slots.
Code:
@sample
new_value = abs(spl0);
sample_count += 1;
idx = sample_count % LENGTH;
avg -= array[idx];
avg += new_value / LENGTH;
array[idx] = new_value / LENGTH;