在MATLAB中分析WAV文件 [英] Analyzing wav files in MATLAB

查看:170
本文介绍了在MATLAB中分析WAV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这架钢琴录音(.wav格式).我可以对整个录音进行FFT并确定频率.

So I have this piano recording (in .wav format). I am able to do an FFT on the whole recording and identify frequencies.

但是,根据我读过的一些文章,最好是将wav文件分解为多个窗口,其中每个窗口都包含一个特定的注释.

However, according to some articles I read, its best if the wav file is broken down into windows, where each window would include one particular note.

为此,我首先需要绘制我的时域信号的功率包络"(考虑音符平均能量的概念),因此每个音符都会有一个增加和一个减少,并且可以通过检查局部极小值.

For this I need to initially plot a "power envelope" of my time domain signal (considering the note average energy concept) therefore there'll be one increase and one decrease for each note and note onsets can be determined by checking the local minima.

这是引入窗口"的地方,其中每个窗口仅包含一个起点,然后在每个窗口上执行FFT.

This is where 'windows' are introduced, where each window consists of only one onset and then FFT is performed on each window.

我在绘制功率包络并将其分解成窗户方面遇到困难.希望在Matlab编码方面对此有所帮助.

Im having difficulty in plotting the power envelope and moving onto breaking it down into windows. Would appreciate some help with the Matlab coding for this.

我使用的代码非常简单:

The code I've used is pretty straightforward:

[wave,fs] = wavread('c scale fast.wav'); %将文件读入内存*/

[wave,fs] = wavread ('c scale fast.wav'); % read file into memory */

%sound(wave,fs); %看到听起来像*/

%sound(wave,fs); % see what it sounds like */

wave = wave.* hamming(length(wave));

wave = wave.*hamming(length(wave));

t = 0:1/fs :(长度(波)-1)/fs; %并获得采样频率*/

t = 0:1/fs:(length(wave)-1)/fs; % and get sampling frequency */

图(2);

      subplot(2,1,1);
      plot(t,wave);
      title('Wave File');
      ylabel('Amplitude');
      xlabel('Length (in seconds)');

L =长度(波);

L = length(wave);

NFFT = 2 ^ nextpow2(L); %y的下一个2的次方幂

NFFT = 2^nextpow2(L); % Next power of 2 from length of y

Y = fft(wave,NFFT)/L;

Y = fft(wave,NFFT)/L;

f = fs/2 * linspace(0,1,NFFT/2 + 1);

f = fs/2*linspace(0,1,NFFT/2+1);

%绘制单侧振幅谱.

   subplot(2,1,2);
   plot(f,2*abs(Y(1:NFFT/2+1))) 
   title('Single-Sided Amplitude Spectrum of y(t)')
   xlabel('Frequency (Hz)')
   ylabel('|Y(f)|')

在我的信号(wav文件的绝对值)与高斯滤波器卷积之后,我尝试采用一阶和二阶导数,但是当我对其进行绘图时却没有输出.

After my signal (abs value of my wav file) is convolved with the Gaussian filter i try taking the 1st and 2nd derivatives, but i don't get an output when i try to plot it.

edges = fconv(abs(song),detect);

edges=fconv(abs(song),detect);

tedges = edges(P/2:N + P/2-1);

tedges=edges(P/2:N+P/2-1);

tedges =鞋数/最大值(abs(tedges));

tedges=tedges/max(abs(tedges));

W = diff(tedge);

W= diff(tedge);

Z = diff(W);

Z= diff(W);

当我尝试绘制W和Z时,没有得到所需的输出.换句话说,我的图是空的.我无法弄清楚我在做什么错...

It is when i try to plot W and Z that I don't get the output I need. My graph is empty in other words. I can't figure out what I'm doing wrong here...

推荐答案

有用:基本流量:

for v=1:window_length:length(data)
    data_subsection=data(v:v+window_length);
    subsection_fft = fft(data_subsection);
    plot(...);
end

这篇关于在MATLAB中分析WAV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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