A common and very efficient technique for envelope detection is based on the Hilbert Transform, (a 90 degree phase shifter) and summing the phase shifted and original signals. The Hilbert transform is typically implemented as an FIR filter so the original signal must be delayed to match the group delay of the Hilbert transform. This process can be followed by absolute and then peak hold functions, the latter is often implemented as a one pole IIR filter.
The following diagrams give an idea of how this envelope approximation process works.
The following equation shows how the coefficients of the FIR filter implementation of the Hilbert transform are calculated.
The one pole IIR filter is defined by the following equation :
y(n) = x(n) + a * y(n-1), where 0 < a < 1.0
Another option for detecting the envelope is to use the square root of the energies of the original and the Hilbert transformed signals, as follows :
Envelope = sqrt(Hilbert^2 + signal^2)
In general, this will give similar results to the absolute value technique but can be more run-time efficient.
This algorithm is included in the SigLib DSP Library.