matlabfftfrequencyamplitudemagnitude

How can i detect amplitude from FFT on Time-Domain signal


I have a signal of wave song and I have a problem with amplitudes.

%graph 1 time domain
song2 = song(1:size(song));
fs = 44100;
dt = 1/fs;
t = 0:dt:(length(song2)*dt)-dt;
figure(); 
plot(t,abs(song2)); xlabel('Seconds'); ylabel('Amplitude');

Then I put signal in FFT, because I want to get amplitude of detecting peaks(for example; 164Hz).

%graph 2 fft
L = length(song2); 
NFFT = 2^nextpow2(L);
f = fs/2*linspace(0,1,NFFT/2+1);
X = fft(song2,NFFT)/L; 
X = 2*abs(X(1:NFFT/2+1)); 
figure(); 
plot(f,X);  

The problem appear when I get the amplitude of the signal (for example; 0.0103) but if I compare with the amplitude of the (time domain) is not the same.

My question is How in the time domain(graph 1) I detect amplitude of the of a frequency(for example; 164 with amplitude 0.0103)?

EDIT:

Hm, I will rather ask in this way. I detect frequency in frequency domain spectrum as the graph link For example Let us take the the first signal (82hz)(amplitude:0.0075) And my question if is posible to detect position of this first signal in time-domain as the graph in link

Any help would be helpful.


Solution

  • Have you tried the code with a sinusoidal input?

    Make a sinusoid of length 512 (any reasonable length) with amplitude 1 and frequency equal to 164 Hz.

    When you run the program, I'm sure you'll see the gain at the frequency bin corresponding to 164 Hz close to one, as long as your frequency resolution isn't too bad (meaning you haven't used too few FFT points).

    If the above works, then your code should work for a song too. How you're judging/verifying time-domain amplitude in the case of a multi-tonal time domain signal like music is something I don't know.