fft on samples of an audio file in matlab

ⅰ亾dé卋堺 提交于 2019-12-13 02:16:22

问题


I'm trying to extract information from a sound file in order to use it in a video classification algorithm I'm working on.

My problem is that I don't know how to work exactly with audio files in Matlab.

Below is what I need to accomplish:

  • open the audio file and get the sampling rate/frequency
  • I need to work on a window of 2 seconds so I have to loop over the file and get each 2 seconds as a window and then do the ftt (Fast-Fourier-Transform) on each window.

After that it is my turn to use these values to do what I want

any help would be appreciated

Thanks.


回答1:


Following code may only give you some idea. You may need to determine another fft size, a windowing function like hamming etc.

To read a wav file:

[data, Fs] = wavread('path.wav');

Splitting to 2 sec windows and getting fft:

frameFFT = [];
timeStep = Fs*2;
for i=1:timeStep:length(data)-timeStep
   frameFFT = [frameFFT; fft(data(i:i+timeStep-1),1024)];
end


来源:https://stackoverflow.com/questions/16176534/fft-on-samples-of-an-audio-file-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!