如何从FFT获取低音,中音和高音数据 [英] How to get Bass, Mid, Treble data from FFT

查看:185
本文介绍了如何从FFT获取低音,中音和高音数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是整个音频处理领域的新手,我想知道如何从FFT输出中提取低音,中音和高音.我目前正在使用它来获取数据: https://stackoverflow.com/a/20414331/2714577 Naudio.

I'm new to this whole audio processing area and I'm wondering how to extract Bass, Mid and treble from an FFT output. I'm currently using this to get the data: https://stackoverflow.com/a/20414331/2714577 which uses Naudio.

但是我使用的fftlength为1024(要求速度).我正在尝试以0-255之类的格式来获取这3个部分,以用于彩色显示.

But I'm using a fftlength of 1024 (require speed). I'm trying to get these 3 sections in a format such as 0-255 for colour purposes.

我目前有这个:

    double[] data = new double[512];

    void FftCalculated(object sender, FftEventArgs e)
    {

        for (int j = 0; j < e.Result.Length / 2; j++)
        {
            double magnitude = Math.Sqrt(e.Result[j].X * e.Result[j].X + e.Result[j].Y * e.Result[j].Y);
            double dbValue = 20 * Math.Log10(magnitude);

            data[j] = dbValue;
        }

        double d = 0;

        for (int i = 20; i < 89; i++)
        {

            d += data[i];
        }

        double m = 0;

        for (int i = 150; i < 255; i++)
        {

            m += data[i];
        }

        double t = 0;

        for (int i = 300; i < 512; i++)
        {

            t += data[i];
        }

        Debug.Message(""+d+" |||| "+m+" |||| "+t);
    }

哪个返回:

这是对的吗?如何使这些数据更有用?

Is this right? How do I get this data to something more usable?

推荐答案

您的dbValue已经是一个非常不错的数字,可以确保相对于1.0的分贝级别变为0.0 dB

Your dbValue is already a very good number, maesuring the level in decibel relative to 1.0 which becomes 0.0 dB

您应该平均,而不是求和(各个频率下的dB值).

You should average instead of sum the individual (dB-Values at various) frequencies.

然后将大约-80db .. 0.0dB的dB范围映射到您的颜色范围.

Then map the dB Range of about -80db .. 0.0dB to your color range.

还请注意:语音和音乐倾向于具有平均的粉红噪声频谱.这意味着低频往往比高频具有更高的dB. 您应该对此效果进行补偿(可能在平均频率之前),以得到更好"的显示.

Also note: Speach and music tend to have an average pink noise spectrum. This means that low frequencies tend to have higher dB than high frequencies. You should compensate for this effect (probably before averaging the frequencies) to get a "better" display.

这篇关于如何从FFT获取低音,中音和高音数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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