【问题标题】:What can I use to take frequencies from a song? [closed]我可以用什么来从歌曲中获取频率? [关闭]
【发布时间】:2022-01-20 06:52:12
【问题描述】:

我编写了一个 VB.NET WinForms 应用程序,它允许我执行傅立叶变换以找到离散频率的幅度,以将“强度”表示为条形图。这方面的代码已经准备好并经过测试。

由于没有人可以帮助解决我的最后一个问题How do I get the wave (band) of the soundcard?,我现在有了分析一段音乐的频率的想法。

我必须查看 .mp3 文件的哪个位置? Visual Studio Nuget 包管理器中是否有用于此的库?

【问题讨论】:

  • 我认为这个问题太宽泛了,无法在这里回答,但我建议您以能够处理波形音频数据为起点。 MSDN 中有一些文档,但我不确定在那里查看的最佳位置是什么。

标签: vb.net audio-processing


【解决方案1】:

首先将 mp3 转换为 PCM 格式(每种语言都有许多这样的库),然后将 PCM 数组(原始音频格式)输入到您的 FFT 调用中,这将返回一个新的复数数组...遍历这个新数组并进行计算以确定幅度,给定格式为 A + Bi(实数 A 和虚数 B)对的复数,对新数组的每个元素执行此操作...这是我编写的 golang 代码它计算新数组的每个元素的大小(从 FFT 调用生成)

number_of_samples := size of original PCM array 
nyquist_limit_index := int(number_of_samples / 2)

for index_fft, curr_complex := range complex_fft { // we really only use half this range + 1

    if index_fft <= nyquist_limit_index && curr_freq >= min_freq && curr_freq < max_freq {

        curr_real = real(curr_complex) // pluck out real portion of imaginary number
        curr_imag = imag(curr_complex) // ditto for im

        curr_mag = 2.0 * math.Sqrt(curr_real*curr_real+curr_imag*curr_imag) / number_of_samples  // magnitude of this freq

        curr_theta = math.Atan2(curr_imag, curr_real)  //  phase of this frequency

        curr_dftt := discrete_fft{

            real:      2.0 * curr_real,
            imaginary: 2.0 * curr_imag,
            magnitude: curr_mag,
            theta:     curr_theta,
        }

        *all_dft = append(*all_dft, curr_dftt)

        all_magnitudes = append(all_magnitudes, curr_mag)
    }
    curr_freq += incr_freq
}

【讨论】:

  • 嗨@Scott,非常感谢。我没有足够的声望给 +1,但我真的很感激。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-05
  • 2010-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多