You can use a Hilbert transform to get the envelope. Technically, this returns the analytic signal. You get the envelope with the following line:
envelope = abs(hilbert(Song));
What the Hilbert transform does is to take the fft
of the input, zeroes out the negative frequencies, and then does an ifft
. The real part of the transform is the original signal, the imaginary part is the transformed signal. The absolute value of the real and imaginary part is the envelope, and the argument (angle(hilbert(Song))
) is the instantaneous phase.