简体   繁体   English

根据频率响应计算FIR系数

[英]Calculating FIR coefficients from frequency response

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. 任务是将该AFR列表导出到一些硬件DSP器件的一组系数中。 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). 该器件的规格说它需要12288个系数,DSP有2个FIR滤波器模块(每个6144抽头)。 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. 想法是,在加载这些系数之后,该设备应作为均衡器工作,该均衡器根据初始amplitue-frequency点列表来转换信号。

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). 我发现,可以通过对所需频率响应进行傅立叶逆变换并使用某些开窗函数(最好不是矩形)来计算FIR滤波器的系数。

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. 问题是我不擅长信号处理,对FIR不太了解,我使用FFT来获取音频数据的频率响应,但是我对FFT和相关内容的工作原理仍然含糊不清。

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. 点的计算应在C#或C ++中完成(我擅长创建C ++ / CLI包装器),以便可以将其集成到现有的应用程序中。 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? 是否有免费的库或代码可从幅频响应数据中获取FIR系数?

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. 最好的解决方案是像“黑匣子”这样的东西,这样我就可以输入AFR点列表并得出12288个系数,但是如果多个库/代码段可以轻松组合,我将不胜感激。

Additional info: 附加信息:

  • sampling frequency for audio which will be passed through this FIR, is 44100 Hz 通过此FIR的音频的采样频率为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 信号的总体特征可以粗略地定义为“音乐”,FIR将用于均衡高质量音频,因此,如果高端音频系统上训练有素的耳朵听不到任何错误和信号失真,则可以接受

  • 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点中相邻幅度之间的差异可能在[0 dB .... 80 dB]范围内,但在实际测试中,它们通常在[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 AFR点之间的距离越来越大,第一个点是20.17246114 20.68984457,最后两个点是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
       }

The standard way of finding good FIR coefficients is using the "Remez exchange" algorithm. 查找良好FIR系数的标准方法是使用“ Remez交换”算法。 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 . 我找到了一些可能有用的代码链接(我自己尚未尝试过): http : //www.janovetz.com/jake/remez/remez-19980711.zip Another key word to search for is "Parks-McClellan". 另一个要搜索的关键词是“ 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). 然后,算法在最小-最大意义上找到最佳滤波器(最小化最大误差)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM