首页 > 其他 > 详细

fir滤波器

时间:2018-05-03 10:19:07      阅读:320      评论:0      收藏:0      [点我收藏+]
 // reference implementation of an FIR     template <typename SampleType, typename NumericType>     static void reference (const NumericType* firCoefficients, size_t numCoefficients,                            const SampleType* input, SampleType* output, size_t n) noexcept     {         if (numCoefficients == 0)         {//输出清零             zeromem (output, sizeof (SampleType) * n);             return;         } //分配内存         HeapBlock<SampleType> scratchBuffer (numCoefficients                                             #if JUCE_USE_SIMD                                              + (SIMDRegister<NumericType>::SIMDRegisterSize / sizeof (SampleType))                                             #endif                                              );        #if JUCE_USE_SIMD         SampleType* buffer = reinterpret_cast<SampleType*>  (SIMDRegister<NumericType>::getNextSIMDAlignedPtr  (reinterpret_cast<NumericType*> (scratchBuffer.getData())));        #else         SampleType* buffer = scratchBuffer.getData();        #endif //内存清零         zeromem (buffer, sizeof (SampleType) * numCoefficients);         for (size_t i = 0; i < n; ++i)         { //滑动,将数据向左移动一个位置             for (size_t j = (numCoefficients - 1); j >= 1; --j)                 buffer[j] = buffer[j-1];             buffer[0] = input[i];//最新数据             SampleType sum (0);//累加和             for (size_t j = 0; j < numCoefficients; ++j)                 sum += buffer[j] * firCoefficients[j];             output[i] = sum;         }     }


fir滤波器

原文:http://blog.51cto.com/9233403/2111978

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!