Help on implementing an IIR filter
The spectrum NewSpectrum appears to be the output of the FFT of the current data block, and FilteredSpectrum on the right-hand side of the equation is the filtered spectrum of the previous block. The index i is the frequency index, so you use this recursion for each frequency point. Note that the value of gain is crucial. It should be in the range $(0,1)$, where a value of $1$ means no filtering at all, and $0$ means no update at all.