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

📄 amf_delay.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_Delay.c#3 $ 
// Part of : VisualAudio V2.5.0 
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $



#include "AMF_Delay.h"

void AMF_Delay_Render(AMF_Delay * 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

SEG_MOD_FAST_CODE  void AMF_Delay_Render(AMF_Delay * restrict instance,float * restrict * buffers,int tickSize) {
    int delay = instance->delay;                            // delay in samples
    float *delayBuffer = &instance->delayBuffer[0];            // delay buffer
    int delayBufferLen = instance->delaySize;                // delay index
    int writeIndex = instance->delayWritePtr-delayBuffer;    // delay index
    int i;
    float tmp;
    float *in = buffers[0]; 
    float *out = buffers[1];
    float *readPtr;
    float *writePtr;
    int readIndex;

    readIndex = writeIndex-delay;
    while (readIndex<0) readIndex += delayBufferLen;
    
    // weird kludge to get the compiler to actually set the B0, B1 registers...
    writePtr = delayBuffer;
    readPtr = delayBuffer;
    writePtr = __builtin_circptr(writePtr, writeIndex, delayBuffer, delayBufferLen);        
    readPtr = __builtin_circptr(readPtr, readIndex, delayBuffer, delayBufferLen);        

    // the asm version does this loop in SIMD
    // also, there is some logic to work around an interaction between SIMD reads
    //    and circular buffering (see comments in asm file)
    for (i=0; i<tickSize; i++) {
        tmp = *readPtr;
        *writePtr = in[i];
         writePtr = __builtin_circptr(writePtr, 1, delayBuffer, delayBufferLen);        
         readPtr = __builtin_circptr(readPtr, 1, delayBuffer, delayBufferLen);        
         out[i] = tmp;
    }    
       instance->delayWritePtr = writePtr;
}


#endif



SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassDelay = {

    /* Flags */
    0,

    /** Reference to render function. */
    (AMF_RenderFunction)AMF_Delay_Render,  // render function 

    /* Default bypass */
    (void *)0,
    
    /* Input descriptor - 1 input, and it is mono. */
    1, 0,

    /* Output descriptor - 1 output, and it is mono. */
    1, 0,
};

⌨️ 快捷键说明

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