# fft function in R vs spec function from 'seewave' package? They don't give a similar frequency spectra

I understand that spec will give me the frequency and the corresponding amplitude of that component, whereas fft will compute the DFT of the signal and throw the complex numbers for each component which I have to plot as per the physical frequencies.

y is the time-series signal Fs is the sampling freq.

N = length(y);
f1=fft(y)
fa = seq(0,N-1,by=1)*(Fs/N)
plot(fa,abs(f1),type='l',xlim = c(0,3),ylim = c(0,50))
s1=spec(y,f=1000,plot = FALSE)
s1$$x<-s1$$x*1000   (KHz to Hz)
plot(s1$$x,s1$$y,type='l',xlim = c(0,3))


Red one is from spec function and blue is from fft function.

• FFT is a low level function to compute the raw complex valued DFT of the given data untouched. SPEC function seems to pre and post-process the FFT results (as @Florian indicated). Hence they would produce different (but nevertheless related) outputs. – Fat32 Jul 26 at 12:12