RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
fir滤波器
 // reference implementation of an FIR
    template 
    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 scratchBuffer (numCoefficients
                #if JUCE_USE_SIMD
                + (SIMDRegister::SIMDRegisterSize / sizeof (SampleType))
                #endif
                   );
       #if JUCE_USE_SIMD
        SampleType* buffer = reinterpret_cast 
			(SIMDRegister::getNextSIMDAlignedPtr 
			(reinterpret_cast (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://scyingshan.cn/article/gssdih.html