根据频率响应计算 FIR 系数

发布于 2024-12-08 16:21:35 字数 1205 浏览 3 评论 0原文

我有一个幅频响应点列表。振幅以分贝为单位。

任务是将此 AFR 列表导出为某些硬件 DSP 设备的一组系数。我知道该设备的文件格式。该设备的规格表明它需要 12288 个系数,并且 DSP 有 2 个 FIR 滤波器块(每个块 6144 个抽头)。这个想法是,在加载这些系数之后,该设备应该充当均衡器,根据初始幅频点列表来转换信号。

我发现 FIR 滤波器的系数可以通过对所需频率响应进行傅里叶逆变换并使用一些加窗函数(最好不是矩形)来计算。

问题是我不擅长信号处理,我对 FIR 不太了解,我已经使用 FFT 从音频数据中获取频率响应,但我对 FFT 和相关内容的工作原理仍然有一个相当模糊的想法。

点的计算应该在 C# 或 C++ 中完成(我擅长创建 C++/CLI 包装器),这样我就可以将其集成到现有的应用程序中。 导出过程对时间要求不高,因此我可以使用简单而缓慢的算法,但无论如何在中型计算机上花费的时间不会超过一分钟。

是否有任何免费的库或代码可以从幅频响应数据中获取 FIR 系数?

最好的解决方案类似于“黑匣子”,这样我只需输入 AFR 点列表即可获得12288 个系数,但如果可以轻松地将其组合在一起,我也会感激多个库/代码段。

附加信息:

  • 将通过此 FIR 的音频采样频率为 44100 Hz

  • 信号的整体特性可以被宽泛地定义为“音乐”,FIR将用于均衡高质量音频,因此如果高端音频系统上受过训练的耳朵无法听到任何错误和信号失真,那么任何错误和信号失真都是可以接受的

  • 之间的差异理论上,初始 AFR 点中的相邻幅度可能在 [0 dB .. 80 dB] 范围内,但在实际测试中,它们通常在 [0 dB ... 2 dB] 范围内

  • AFR 点之间的距离越来越大,第一个点是 20.17246114 20.68984457 和最后两个 21632.14039 21754.41533

积分使用以下公式计算:

       float x;
       for(int i = 0; i<bandPoints; i++){
               x = (((float)i + 1) / ((float)(bandPoints + 2)));
               bandsHz[i] = ((x*x)*(22000-20))+20; // 20...22000
       }

I have a list of amplitude frequency response points. The amplitudes are given in decibels.

The task is to export this AFR list to a set of coefficients for some hardware DSP device. I know the file format for this device. The specification for the device says that it needs 12288 coefficients and the DSP has 2 FIR filter blocks (6144 taps each). The idea is that after loading those coefficients, this device should work as an equalizer which transforms the signal according to the initial amplitue-frequency point list.

I have found out that the coefficients for a FIR filter can be calculated by taking the inverse Fourier transform of the desired frequency response and also using some windowing function (preferably not rectangle).

The problem is that I am not good at signal processing, I do not know much about FIRs, I have used FFT to get the frequency response from audio data, but I still have a pretty vague idea about how FFT and related stuff works.

The calculation of points should be done in C# or C++ (I am good at creating C++/CLI wrappers) so I can integrate it into already existing application.
The exporting process is not time critical, so I can use simple and slow algorithms, but anyway it should not take more than a minute on a mid-range computer.

Is there any free library or code to get FIR coefficients from the amplitude-frequency response data?

The best solution would be something like a "black box" so I can just feed the list of AFR points and get out 12288 coefficients, but I would be grateful also for multiple libraries/pieces of code if only it can be put together easily.

Additional info:

  • sampling frequency for audio which will be passed through this FIR, is 44100 Hz

  • the overall characteristics of the signal can be loosely defined as "musical", FIR will be used for equalizing high quality audio, so any errors and signal distortions are acceptable if they cannot be heard by a trained ear on a high-end audio systems

  • diffrences between adjacent amplitudes in initial AFR points theoretically may be in range [0 dB .. 80 dB], but in real life tests they usually were in range [0 dB ... 2 dB]

  • AFR points are with growing distance between them, the first points are
    20.17246114
    20.68984457
    and the last two
    21632.14039
    21754.41533

the points were calculated using the following formula:

       float x;
       for(int i = 0; i<bandPoints; i++){
               x = (((float)i + 1) / ((float)(bandPoints + 2)));
               bandsHz[i] = ((x*x)*(22000-20))+20; // 20...22000
       }

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

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

发布评论

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

评论(1

玉环 2024-12-15 16:21:35

寻找良好 FIR 系数的标准方法是使用“Remez 交换”算法。我找到了一些代码的链接(我自己没有尝试过),您可能会觉得有用: http://www.janovetz.com/jake/remez/remez-19980711.zip。另一个要搜索的关键词是“Parks-McClellan”。

算法的输入是幅度与频率的描述以及一组权重因子与频率的关系,描述了满足该频率下幅度要求的相对重要性。然后,该算法找到最小-最大意义上的最佳滤波器(最小化最大误差)。

The standard way of finding good FIR coefficients is using the "Remez exchange" algorithm. I found a link to some code (haven't tried it myself) that you may find useful: http://www.janovetz.com/jake/remez/remez-19980711.zip. Another key word to search for is "Parks-McClellan".

Input to the algorithm is a description of the amplitude versus frequency and a set of weight factors versus frequency that describes the relative importance of meeting the amplitude requirement at that frequency. The algorithm then finds the optimum filter in the mini-max sense (minimizing the maximum error).

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