在Matlab中对音频文件的样本进行fft [英] fft on samples of an audio file in matlab

查看:751
本文介绍了在Matlab中对音频文件的样本进行fft的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从声音文件中提取信息,以便在我正在研究的视频分类算法中使用它.

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

我的问题是我不知道如何在Matlab中精确处理音频文件.

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

以下是我需要完成的工作:

Below is what I need to accomplish:

  • 打开音频文件并获取采样率/频率
  • 我需要在2秒钟的窗口上工作,因此我必须遍历文件并每2秒钟作为一个窗口,然后在每个窗口上执行ftt(快速傅立叶变换).

此后,该轮到我使用这些值做我想要的

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

任何帮助将不胜感激

谢谢.

推荐答案

下面的代码可能只会给您一些想法.您可能需要确定其他fft大小,例如汉明(hamming)等开窗函数.

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

要读取wav文件,请执行以下操作:

To read a wav file:

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

拆分到2秒的窗口并获取fft:

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

这篇关于在Matlab中对音频文件的样本进行fft的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆