使用 FFT 检测小号的音调

发布于 2024-08-21 07:41:28 字数 33 浏览 12 评论 0原文

如何使用 FFT 获得频率?正确的程序和代码是什么?

How do i get frequency using FFT? What's the right procedure and codes?

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

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

发布评论

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

评论(5

不奢求什么 2024-08-28 07:41:28

音调检测通常涉及测量功率谱中谐波之间的间隔。功率谱是通过 FFT 获取前 N/2 个 bin 的幅度 (sqrt(re^2 + im^2)) 获得的。然而,还有更复杂的音调检测技术,例如倒谱分析,我们在其中采用 FFT功率谱的对数,以便识别谱峰的周期性。

Pitch detection typically involves measuring the interval between harmonics in the power spectrum. The power spectrum is obtained form the FFT by taking the magnitude of the first N/2 bins (sqrt(re^2 + im^2)). However there are more sophisticated techniques for pitch detection, such as cepstral analysis, where we take the FFT of the log of the power spectrum, in order to identify periodicity in the spectral peaks.

汹涌人海 2024-08-28 07:41:28

乐器的持续音符是一个周期信号,我们的朋友傅里叶(“FFT”中的第二个“F”)告诉我们,任何周期信号都可以通过添加一组正弦波(通常具有不同的幅度、频率)来构造。 ,和阶段)。 基波是最低频率分量,它对应于音调;其余成分是泛音,并且是基频的倍数。基音和泛音的相对混合决定了音色或乐器的特性。单簧管和小号齐奏时听起来“调准”,因为它们具有相同的基频,但是,由于它们的音色(泛音混合)不同,因此它们可以单独识别。

对于您的问题,您可以在一个时间窗口内对喇叭进行采样,计算 FFT(将样本序列分解为其组成的数字频率),然后断言音调是幅度最大的 bin 的频率。如果您愿意,可以将其简单地量化为最接近的音乐半音,例如降E。 (如果您不了解采样频率与结果频率箱之间的关系,或者如果您不了解采样频率太低的危害,请在维基百科上查找 FFT。)这可能会满足您的需求,因为基本原理成分通常比任何其他成分具有更大的能量。窗口越长,音调精度就越高,因为箱中心的频率间隔会变得更紧密。然而,如果窗口太长,以至于小号在窗口持续时间内明显改变其音调,那么该技术的有效性将大大降低。

A sustained note of a musical instrument is a periodic signal, and our friend Fourier (the second "F" in "FFT") tells us that any periodic signal can be constructed by adding a set of sine waves (generally with different amplitudes, frequencies, and phases). The fundamental is the lowest frequency component and it corresponds to pitch; the remaining components are overtones and are multiples of the fundamental's frequency. It is the relative mixture of fundamental and overtones that determines timbre, or the character of an instrument. A clarinet and a trumpet playing in unison sound "in tune" because they share the same fundamental frequency, however, they are individually identifiable because of their differing timbre (overtone mixture).

For your problem, you could sample the trumpet over a time window, calculate the FFT (which decomposes the sequence of samples into its constituent digital frequencies), and then assert that the pitch is the frequency of the bin with the greatest magnitude. If you desire, this could then be trivially quantized to the nearest musical half step, like E flat. (Lookup FFT on Wikipedia if you don't understand the relationship between the sampling frequency and the resultant frequency bins, or if you don't understand the detriment of having too low a sampling frequency.) This will probably meet your needs because the fundamental component usually has greater energy than any other component. The longer the window, the greater the pitch accuracy because the bin centers will become more closely spaced in frequency. However, if the window is so long that the trumpet is changing its pitch appreciably over the duration of the window, then the technique's effectiveness will break down considerably.

御守 2024-08-28 07:41:28

DansTuner 是我解决这个问题的开源项目。事实上,我是一名小号手。它具有从 Audacity 中提取的音高检测代码。

DansTuner is my open source project to solve this problem. I am in fact a trumpet player. It has pitch detection code lifted from Audacity.

糖粟与秋泊 2024-08-28 07:41:28

ia 添加了这个 org.apache.commons。 math.transform.FastFourierTransforme 包到项目中并且它的工作完美

ia added this org.apache.commons.math.transform.FastFourierTransforme package to the project and its works perfectly

终难愈 2024-08-28 07:41:28

这里是一篇关于非参数技术估计的简短博客文章PSD(功率谱密度)以及一些更详细的链接。这可能会让您开始估计 PSD,然后找到音调。

Here is a short blog article on non-parametric techniques to estimating the PSD (power spectral density) along with some more detailed links. This might get you started in estimating the PSD - and then finding the pitch.

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