How to find the Fourier coefficients of an audiofile
1 view (last 30 days)
Show older comments
I have an audiofile of a bell sound that I want to find the Fourier coefficients of. I have already plotted my data, as well as a spectrogram and a magnitude vs frequency plot but I am not sure how I can use these plots to find the coefficients.
Here is the code:
file = 'Bjall2.m4a';
[x,fs] = audioread(file);
tt = (0:(length(x)-1))/fs;
figure(1); clf;
plot(tt,x);
wz=round(0.05*fs);
hop=round(0,025*fs)
figure(2); clf;
spectrogram(x,wz,hop,1024,fs,'yaxis')
nstart=70000;
xseg=x(nstart:(nstart+wz-1));
X=fft(xseg);
ffn=1:ceil(wz/2);
ff=(ffn-1)/(wz/2);
figure(3); clf;
plot(ff,abs(X(ffn)));
xlabel('Frequency [Hz]')
ylabel('Mag. Spectrum')
figure(4); clf;
data_fft = fft(x);
plot(abs(data_fft(:,1)))
1 Comment
Mathieu NOE
on 4 Mar 2021
hello
what do you mean by Fourier coefficients ? you have already computed the fft values (bins)
do you mean you want to extract the dominant frequencies from the fft / spectrogram ?
Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!