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

📄 amf_volumecontrol.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_VolumeControl.c#3 $ 
// Part of : VisualAudio V2.5.0 
// Updated : $Date: 2007-08-08 12:37:19 +0530 (Wed, 08 Aug 2007) $ by $Author: kdasari2 $



#include "AMF_VolumeControl.h"
void AMF_VolumeControl_Render(AMF_VolumeControl * instance, float * * buffers, int tickSize);

#if 0
//This is non optimized c function to understand logic of assembly only
void AMF_VolumeControl_Render(AMF_VolumeControl * instance, float * * buffers, int tickSize)
{
    int i;
    float *coefsTarget_low = &instance->coefsTarget_low[0];
    float *coefsTarget_high = &instance->coefsTarget_high[0];
    float *coefs_low = &instance->coefs_low[0];
    float *coefs_high = &instance->coefs_high[0];
    float *state_low = instance->state_low;
    float *state_high = instance->state_high;
       
    float *input = buffers[0];
    float *output = buffers[1];
    
    float Rate = instance->coefsSmoothing;
    float oneMinusRate = 1.0f - Rate;
    float tmp, x, t, y;
    
    int ind1 = 1;
    int ind2 = 0;

    
    // smooth the coefs
    for (i=0; i<4; i++)
    {
        coefs_low[i] = Rate * coefsTarget_low[i] + oneMinusRate * coefs_low[i];
        coefs_high[i] = Rate * coefsTarget_high[i] + oneMinusRate * coefs_high[i];
    }

    // DF2
    for (i=0; i<tickSize; i++) {
        
        x = coefs_low[1] * state_low[ind2];
        t = input[i] - x;
        x = coefs_low[0] * state_low[ind1];
        tmp = t - x;
        
        y = coefs_low[3] * state_low[ind2];
        x = y + x;
        y = coefs_low[2] * tmp;
        y = y + x; // tmp_out_low
        
        state_low[ind2] = tmp;
        
        x = coefs_high[1] * state_high[ind2];
        t = input[i] - x;
        x = coefs_high[0] * state_high[ind1];
        tmp = t - x;
        
        y = y + x;
        x = coefs_high[3] * state_high[ind2];
        y = y + x;
        x = coefs_high[2] * tmp;
        output[i] = y + x;
        
        state_high[ind2] = tmp;
        
        /*
        tmp = input[i] - coefs_low[0] * state_low[ind1] - coefs_low[1] * state_low[ind2];
        output[i] = coefs_low[2] * tmp + coefs_low[0] * state_low[ind1] + coefs_low[3] * state_low[ind2];
        state_low[ind2] = tmp;
        
        tmp = input[i] - coefs_high[0] * state_high[ind1] - coefs_high[1] * state_high[ind2];
        output[i] += coefs_high[2] * tmp + coefs_high[0] * state_high[ind1] + coefs_high[3] * state_high[ind2];
        state_high[ind2] = tmp;
        */
        ind1 = (ind1 ^ 1);
        ind2 = (ind2 ^ 1) ;
    }
}

#endif

SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassVolumeControl = {
    
    /* Flags */
    0,
     
    /* Render function */
    (AMF_RenderFunction)AMF_VolumeControl_Render,

    /* Default bypass */
    (void *)0,
    
    /* Input descriptor - 2 inputs, and they are mono. */
    1, 0,

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



⌨️ 快捷键说明

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