I am aware of at least two separate ways to retrieve the amplitude envelope from a signal.
The key equation is:
E(t)^2 = S(t)^2 + Q(S(t))^2
Where Q represents a π/2 phase shift (also known as quadrature signal).
Simplest way I am aware of is to get Q would be to decompose S(t) into a bunch of sinusoidal components using FFT, rotate each component a quarter turn anticlockwise ( remember each component is going to be a complex number so a particular component x + iy -> -y + ix ) and then recombine.
This approach works pretty well, although requires a bit of tuning (I don't yet understand the maths well enough to explain this in any better way)
There are a couple of key terms here, namely ' Hilbert transform ' and ' analytic signal '
I'm avoiding using these terms because I'm pretty sure I have witnessed considerable ambiguity in their use.
One document describes the (complex) analytic signal of an original real signal f(t) as:
Analytic(f(t)) = f(t) + i.H(f(t))
where H(f(t)) represents the 'π/2 phase shift' of f(t)
in which case the amplitude envelope is simply |Analytic(f(t))|, which brings us back to the original Pythagorean equation
NB: I have recently come across a more advanced technique involving frequency shifting and a lowpass digital filter. The theory is that we can construct the analytic signal by different means; we decompose f(t) into positive and negative sinusoidal frequency components and then simply remove the negative components and double the positive components. and it is possible to do this ' negative frequency component removal ' by a combination of frequency shifting and lowpass filtering. this can be done extremely fast using digital filters. I haven't yet explored this approach, so this is as much as I can say at the moment.