在MATLAB中计算音频音高? [英] Calculating audio pitch in MATLAB?

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

问题描述

昨天我完成了用于检测随时间推移显示的曲目的音频能量的代码,最终将其用作我的音频缩略图项目的一部分.

Yesterday I finalised the code for detecting the audio energy of a track displayed over time, which I will eventually use as part of my audio thumbnailing project.

但是,我还希望有一种方法可以检测随时间变化显示的音高,因此我有2个可供选择的研究基础.

However I would also like a method that can detect the pitch of a track displayed over time, so I have 2 options from which to base my research upon.

[y, fs, nb] = wavread('Three.wav');                  %# Load the signal into variable y

frameWidth = 441;                                    %# 10 msec
numSamples = length(y);                              %# Number of samples in y
numFrames = floor(numSamples/frameWidth);            %# Number of full frames in y
energy = zeros(1,numFrames);                         %# Initialize energy

for frame = 1:numFrames                              %# Loop over frames
  startSample = (frame-1)*frameWidth+1;              %# Starting index of frame
  endSample = startSample+frameWidth-1;              %# Ending index of frame
  energy(frame) = sum(y(startSample:endSample).^2);  %# Calculate frame energy
end

那是能量方法的正确代码,经过研究,我发现我需要使用离散时间傅立叶变换来找到循环中每帧的当前音高.

That is the correct code for the energy method, and after researching, I found that I would need to use a Discrete Time Fourier Transform to find the current pitch of each frame in the loop.

我认为该过程就像修改代码的最后几行一样容易,以包括用于计算离散傅立叶变换的"fft" MATLAB命令,但我得到的只是关于一个不平衡方程的错误.

I thought that the process would be as easy as modifying the final lines of the code to include the "fft" MATLAB command for calculating Discrete Fourier Transforms but all I am getting back is errors about an unbalanced equation.

非常感谢帮助,即使它只是朝着正确方向的一般指针.谢谢.

Help would be much appreciated, even if it's just a general pointer in the right direction. Thank you.

推荐答案

确定音高是很多,而不只是应用DFT.这也取决于信号源的性质-例如,语音和乐器适用不同的算法.正如您的问题似乎暗示的那样,如果这是一条音乐曲目,那么您可能很不走运,因为没有明显的方法可以确定多个乐器一起演奏的单个音高值(您甚至如何定义 pitch 在这种情况下?).也许您可能对要执行的操作更为具体-也许功率谱比尝试确定任意音高更有用?

Determining pitch is a lot more complicated than just applying a DFT. It also depends on the nature of the source - different algorithms are appropriate for speech versus a musical instrument, for example. If this is a music track, as your question seems to imply, then you're probably out of luck as there is no obvious way of determining a single pitch value for multiple musical instruments playing together (how would you even define pitch in this context ?). Maybe you could be more specific about what you are trying to do - perhaps a power spectrum would be more useful than trying to determine an arbitrary pitch ?

这篇关于在MATLAB中计算音频音高?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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