在 MATLAB 中计算音频音高?

发布于 2024-09-13 18:25:51 字数 1011 浏览 4 评论 0原文

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

然而,我还想要一种可以检测随时间显示的曲目音调的方法,因此我有两个选项作为我的研究基础。

[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

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

我认为这个过程就像修改代码的最后几行以包含用于计算离散傅里叶变换的“fft”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.

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2024-09-20 18:25:51

确定音高比仅仅应用 DFT 复杂很多。它还取决于源的性质 - 例如,不同的算法适用于语音和乐器。如果这是一首音乐曲目,正如您的问题似乎暗示的那样,那么您可能不走运,因为没有明显的方法来确定一起演奏的多个乐器的单个音高值(您甚至如何定义音高) 在这种情况下?)。也许您可以更具体地说明您想要做什么 - 也许功率谱比尝试确定任意音调更有用?

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 ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文