⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amf_fir_ds.c

📁 ADI SHARC DSP 音频算法标准模块库
💻 C
字号:
// Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved.
// This software is proprietary and confidential to Analog Devices, Inc. and its licensors.

// File    : $Id: //depot/development/visualaudio/modules/2.5.0/SHARC/Source/AMF_FIR_DS.c#3 $ 
// Part of : VisualAudio V2.5.0 
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $



#include "AMF_FIR_DS.h"
#include "VA_GeneralHelperFunctions.h"


void AMF_FIR_DS_Render(AMF_FIR_DS * restrict instance,float * restrict * buffers,int tickSize);

// NOTE: The C version of this function is for reference only (it is
//       intended just to show the general algorithm that the module
//       uses), and it may not have been fully tested
#if 0        // example C code

SEG_MOD_FAST_CODE  void AMF_FIR_DS_Render(AMF_FIR_DS * restrict instance,float * restrict * buffers,int tickSize) {
    int i, j, k;
    int filterSize = instance->filterSize;                // filter size
    int stateIndex = instance->stateIndex;                // current state buffer index
    float pm *stateBuffer = &instance->stateBuffer[0];    // state buffer, interleaved
    float *coefs = &instance->coefs[0];                    // filter coefs, 2 interleaved coeff sets
    float tmp[2];
    float *in = buffers[0];
    float *out = buffers[1];

    for (i=0; i<tickSize*2; i+=2) {
        
        stateBuffer[stateIndex] = in[i];        // update the state
        stateBuffer[stateIndex+1] = in[i+1];    // state array is interleaved
        tmp[0] = 0;                                // reset tmp
        tmp[1] = 0;
        
        for (j = 0; j < 2*(filterSize-1); j+=2) {
            k = j + stateIndex;            // circular buffer
            if (k > 2*(filterSize-1))
                k -= 2*filterSize;
            tmp[0] += coefs[j] * stateBuffer[k];
            tmp[1] += coefs[j+1] * stateBuffer[k+1];
        }

        stateIndex -= 2;
        if (stateIndex < 0)             // decr state index and check for wrap
            stateIndex = 2*(filterSize-1);// the filter delay is updated
                                        // 'backwards' so memory reads for
                                        // the filter are then 'forward'
        out[i] = tmp[0];                // output
        out[i+1] = tmp[1];
    }
    instance->stateIndex = stateIndex;
}
#endif

SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassFIR_DS = {

    /* Flags */
    0,
     
    /* Render function */
    (AMF_RenderFunction)AMF_FIR_DS_Render,  // render function 
    
    /* Default bypass */
    (void *)0,

    /* Input descriptor - 1 input, and it is stereo. */
    1, AMF_StereoPin(0),

    /* Output descriptor - 1 output, and it is stereo. */
    1, AMF_StereoPin(0)
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -