|
特别说明:完整45期数字信号处理教程,原创高性能示波器代码全开源地址:链接
第22章 math_help中函数的使用
本期教程主要讲解math_help文件中函数的使用,这个文件也是ARM官方提供的,这些函数相对都比较容易,同时使用频率也很高。希望初学的同学学习并掌握。
22.1 函数讲解
22.3 总结
22.1 函数讲解
22.1.1 函数目录
在文件math_help文件中主要有以下函数:
- float arm_snr_f32(float *pRef, float *pTest, uint32_t buffSize);
- void arm_float_to_q12_20(float *pIn, q31_t * pOut, uint32_t numSamples);
- void arm_provide_guard_bits_q15(q15_t *input_buf, uint32_t blockSize, uint32_t guard_bits);
- void arm_provide_guard_bits_q31(q31_t *input_buf, uint32_t blockSize, uint32_t guard_bits);
- void arm_float_to_q14(float *pIn, q15_t *pOut, uint32_t numSamples);
- void arm_float_to_q30(float *pIn, q31_t *pOut, uint32_t numSamples);
- void arm_clip_f32(float *pIn, uint32_t numSamples);
- uint32_t arm_calc_guard_bits(uint32_t num_adds);
- void arm_apply_guard_bits (float32_t * pIn, uint32_t numSamples, uint32_t guard_bits);
- uint32_t arm_compare_fixed_q15(q15_t *pIn, q15_t * pOut, uint32_t numSamples);
- uint32_t arm_compare_fixed_q31(q31_t *pIn, q31_t *pOut, uint32_t numSamples);
- uint32_t arm_calc_2pow(uint32_t guard_bits);
复制代码
22.1.2 arm_snr_f32
这个函数用于求信噪比:
- /** (1)
- * @brief Caluclation of SNR
- * @param float* Pointer to the reference buffer
- * @param float* Pointer to the test buffer
- * @param uint32_t total number of samples
- * @return float SNR
- * The function Caluclates signal to noise ratio for the reference output
- * and test output
- */
-
- float arm_snr_f32(float *pRef, float *pTest, uint32_t buffSize)
- {
- float EnergySignal = 0.0, EnergyError = 0.0;
- uint32_t i;
- float SNR;
- int temp;
- int *test;
-
- for (i = 0; i < buffSize; i++)
- {
- /* Checking for a NAN value in pRef array */
- test = (int *)(&pRef[i]);
- temp = *test;
-
- if(temp == 0x7FC00000)
- {
- return(0);
- }
-
- /* Checking for a NAN value in pTest array */
- test = (int *)(&pTest[i]);
- temp = *test;
-
- if(temp == 0x7FC00000)
- {
- return(0);
- }
- EnergySignal += pRef[i] * pRef[i];
- EnergyError += (pRef[i] - pTest[i]) * (pRef[i] - pTest[i]);
- }
-
- /* Checking for a NAN value in EnergyError */
- test = (int *)(&EnergyError);
- temp = *test;
-
- if(temp == 0x7FC00000)
- {
- return(0);
- }
-
- SNR = 10 * log10 (EnergySignal / EnergyError); (2)
-
- return (SNR);
-
- }
复制代码
1. 这里先补充一些信噪比方面的基础知识:
信噪比,即SNR(Signal to Noise Ratio),又称为讯噪比。反映摄像机成像的抗干扰能力,反应在画质上就是画面是否干净无噪点;狭义来讲是指放大器的输出信号的功率与同时输出的噪声功率的比,常常用分贝数表示,设备的信噪比越高表明它产生的杂音越少。一般来说,信噪比越大,说明混在信号里的噪声越小,声音回放的音质量越高,否则相反。信噪比一般不应该低于70dB,高保真音箱的信噪比应达到110dB以上。公式如下:
关于信噪比更详细的知识,大家可以查阅相关资料进行了解。
2. 这里实现的就是上面所说的信噪比公式。
|
-
|