0
votes

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.

2

2 Answers

0
votes

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.

0
votes

If I understand your question correctly, you can find what you want by taking the inner product of the time domain signal with a complex sinusoid at the frequency of interest. For example, using the information from your post we would something like the following:

% graph 1 time domain
song2 = song(1:size(song));
fs = 44100;
dt = 1/fs;
t = 0:dt:(length(song2)*dt)-dt;
x_164 = exp(-1j * 2*pi * 164 * t);
f_164 = x_164(:).' * song2(:);       % Spectral content of the signal at 164(Hz).

If you think about what a DFT is, you'll see it's just the above process but with the frequencies chosen such that they from an orthogonal basis. However, you can use the same process to estimate the spectral content at any frequency you want.