如何使用倒谱?

发布于 2024-10-16 10:05:17 字数 863 浏览 8 评论 0原文

最近我问了这个问题:如何从FFT获取基频?< /a> (你实际上并不需要阅读它)

我现在的疑问是:如何使用倒谱算法?

我只是不知道如何使用它,因为我唯一使用的语言我知道的是 ActionScript 3,因此我对 C、Java 等中的本机函数以及如何在 AS 上实现它们的参考资料很少。大多数文章都是关于这些语言的 =/ (不过,欢迎使用除 AS 之外的其他语言的答案,请解释一下脚本是如何工作的)

我找到的关于倒谱来查找 FFT 结果基频的文章告诉我应该这样做:

信号→FT→abs()→平方→log→FT→abs()→平方→功率倒谱

数学上: |F{log(|F{f(t)}|²)}|²

重要信息:

  • 我正在闪存中开发吉他调音器
  • 这是我第一次处理高级声音
  • 我正在使用 FFT 来提取频率箱来自到达用户麦克风的信号,但我陷入了从中获取基频的困境,

我不知道:

  • 如何在数组中应用正方形(我的意思是,我的 FFT 给我的数据是一个数组。我应该吗?当我尝试 fftResults * fftResults 时,ActionScript 的调试会抛出错误)
  • 如何应用“日志”。即使我有一个号码,我也不知道如何应用它。
  • 复倒谱和幂倒谱有什么区别。另外,我应该使用它们中的哪些?我正在尝试开发一个吉他调音器。

谢谢!

Recently I asked this question: How to get the fundamental frequency from FFT? (you don't actually need to read it)

My doubt right now it: how to use the cepstral algorithm?

I just don't know how to use it because the only language that I know is ActionScript 3, and for this reason I have few references about the native functions found in C, Java and so on, and how I should implement them on AS. Most articles are about these languages =/
(althought, answers in other languages than AS are welcome, just explain how the script works please)

The articles I found about cepstral to find the fundamental frequency of a FFT result told me that I should do this:

signal → FT → abs() → square → log → FT → abs() → square → power cepstrum

mathematically:
|F{log(|F{f(t)}|²)}|²

Important info:

  • I am developing a GUITAR TUNER in flash
  • This is the first time I am dealing with advanced sound
  • I am using an FFT to extract frequency bins from the signal that reaches user's microphone, but I got stuck in getting the fundamental frequency from it

I don't know:

  • How to apply a square in an ARRAY (I mean, the data that my FFT gives me is an array. Should I multiply it by itself? ActionScript's debug throws errors when I try to fftResults * fftResults)
  • How to apply the "log". I would not know how to apply it even if I had a single number.
  • What is the difference between complex cepstral and power cepstral. Also, what of them should I use? I am trying to develop a guitar tuner.

Thanks!

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

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

发布评论

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

评论(3

凡尘雨 2024-10-23 10:05:17

请注意,FFT 的输出是复数值数组,即每个 bin = re + j*im。我认为你可以结合abs和square运算并计算每个bin的re*re + im*im。这为每个 bin 提供了一个正值,显然您可以很容易地计算每个 bin 的对数值。然后,您需要对此对数平方数据执行第二次 FFT,并再次使用第二次 FFT 的输出,为每个 bin 计算 re*re + im*im。然后,您将得到一组正值,其中有一个或多个代表输入的基频或频率的峰值。

Note that the output of an FFT is an array of complex values, i.e. each bin = re + j*im. I think you can just combine the abs and square operations and calculate re*re + im*im for each bin. This gives you a single positive value for each bin, and obviously you can calculate the log value for each bin quite easily. You then need to do a second FFT on this log squared data and again using the output of this second FFT you will calculate re*re + im*im for each bin. You will then have an array of postive values which will have one or more peaks representing the fundamental frequency or frequencies of your input.

栀子花开つ 2024-10-23 10:05:17

自相关是最简单、最合乎逻辑的方法,也是最好的起点。

要实现此目的,从简单的自相关开始,然后,如有必要,按照 YIN 提供的概要进行改进。 (YIN 基于与细化的自相关。但是您是否需要这些细化取决于您具体情况的细节。)这样,您也可以边学习边学习,而不是试图一次性理解整个事情。

尽管 FFT 方法也可以工作,但它们有点令人困惑。问题是你真正想要的是周期,而 FFT 并不能很好地代表这一点。缺失的基波就是一个很好的例子,如果你有 2Hz 和 3Hz,基波就是 1Hz,但在 FFT 中却找不到,而 1Hz 在基于时间的表示中很明显(例如自相关)。除此之外,泛音不一定是谐波,还有噪音等等……所有这些问题使得通常最好从直接解决问题的方法开始。

The autocorrelation is the easiest and most logical approach, and the best place to start.

To get this working, start with a simple autocorrelation, and then, if necessary, improve it following the outline provided by YIN. (YIN is based on the autocorrelation with refinements. But whether or not you'll need these refinements depends on details of your situation.) This way also, you can learn as you go rather than trying to understand the whole thing in one shot.

Although FFT approaches can also work, they are a bit more confusing. The issue is that what you are really after is the period, and this isn't well represented by the FFT. The missing fundamental is a good example of this, where if you have 2Hz and 3Hz, the fundamental is 1Hz, but is nowhere in the FFT, while 1Hz is obvious in a time based representation (e.g. the autocorrelation). Add to this that overtones aren't necessarily harmonic, and noise, etc... and all of these issues make it usually best to start with a direct approach to the problem.

温暖的光 2024-10-23 10:05:17

寻找基频 (F0) 的方法有很多。

对于 Java 等语言,有许多库已经实现了这些类型的算法(您可以研究它们的源代码)。

  • MFCC(基于倒谱)在 Comirva(开源)。
  • Audacity(测试版!)(开源)提出了倒谱、自相关、增强自相关、
  • 基于自相关的 Yin (示例
  • 在 FFT 后查找最大信号值

所有这些算法可能对您非常有帮助。然而,获得 F0(以 Hz 为单位的一个值)的最简单方法是使用 Yin。

There are many ways of finding fundamental frequency (F0).

For languages like Java etc there are many libraries with those type of algorithms already implemented (you can study their sources).

  • MFCC (based on cepstral) implemented in Comirva (Open source).
  • Audacity (beta version!) (Open source) presents cepstrum, autocorellation, enhanced autocorellation,
  • Yin based on autocorrelation (example )
  • Finding max signal values after FFT

All these algorithms may be be very helpful for you. However easiest way to get F0 (one value in Hz) would be to use Yin.

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