您好,登錄后才能下訂單哦!
// 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; } //分配內(nèi)存 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 //內(nèi)存清零 zeromem (buffer, sizeof (SampleType) * numCoefficients); for (size_t i = 0; i < n; ++i) { //滑動,將數(shù)據(jù)向右移動一個位置 for (size_t j = (numCoefficients - 1); j >= 1; --j) buffer[j] = buffer[j-1]; buffer[0] = input[i];//最新采集的數(shù)據(jù) SampleType sum (0);//累加和清零 //重新相加 for (size_t j = 0; j < numCoefficients; ++j) sum += buffer[j] * firCoefficients[j]; output[i] = sum;//更新輸出 } }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。