# How to calculate energy of a signal whose frequency is varying with time (like chirp signal or any audio signal) using Fourier coefficients

If I have two audio signals, say $$A_{1}$$ (music) and $$A_{2}$$ (Speech), I want to calculate the energy of the two signals for their relative comparisons. One method I can use is by adding the square of audio samples over its length as follows:

$$E = \sum_{n = 0}^{N} A \left[ n \right]^{2} \tag{1} \label{1}$$

My doubt is: how do I find the energy of the same signals using the Fourier coefficients? Does Parseval's theorem hold for such signals? Because Fourier coefficients are continuously changing with time. So, what is an alternative way to compute the energy of the signal using the frequency representation? Can STFT help in it? If yes, then how?

• Parseval's theorem holds and you can actually do the same operation in frequency (Fourier) domain, just make sure you use the complex conjugate for the calculation, or take the magnitude and square it (pretty much the same thing and efficiency depends on which environment you are working in). STFT would be needed if you work in real time or you want to see how energy changes with time. Do take care with windowing though if you use overlap as it may require some specific calculations to acquire the correct energy (windows do change the amplitude of the signal). Jun 24 at 7:53
• Are you open to accepting another answer? Jun 27 at 8:46
• No, after watching the NPTEL lectures, I have no more doubt about this. Jun 28 at 10:09

$$X[k] = \frac{1}{\sqrt{N}} \sum_{n=0}^{N-1} x[n] e^{-j2\pi\frac{kn}{N}} \leftrightarrow x[n] = \frac{1}{\sqrt{N}} \sum_{k=0}^{N-1} X[k] e^{j2\pi\frac{nk}{N}}$$
$$\sum_{n=0}^{N-1} |x[n]|^2 = \sum_{k=0}^{N-1} |X[k]|^2$$