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

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



#include "AMF_ScalerSmoothed_DS.h"
#include "VA_GeneralHelperFunctions.h"

void AMF_ScalerSmoothed_DS_Render(AMF_ScalerSmoothed_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

#pragma optimize_for_speed
SEG_MOD_FAST_CODE  void AMF_ScalerSmoothed_DS_Render(AMF_ScalerSmoothed_DS * restrict instance,float * restrict * buffers,int tickSize) {
    int i;
    float amp0 = instance->amp0;
    float amp1 = instance->amp1;
    float amp0Target = instance->amp0Target;
    float amp1Target = instance->amp1Target;
    float ampsSmoothing = instance->ampsSmoothing;
    float oneMinusRate = 1.0 - ampsSmoothing;
    float *in = buffers[0]; 
    float *out = buffers[1];

    // In assembly version, this should use SIMD

    //#pragma SIMD_for    //MAW SIMD only save 1 cycle inside main loop here. Total cycles saved=128 
    for (i=0; i<tickSize*2; i+=2) {
        amp0 = amp0 * oneMinusRate + amp0Target * ampsSmoothing;
        amp1 = amp1 * oneMinusRate + amp1Target * ampsSmoothing;
        out[i] = in[i] * amp0;
        out[i+1] = in[i+1] * amp1;
    }
    instance->amp0 = amp0;
    instance->amp1 = amp1;
}
#endif

// Helper to set Balance, -1.0 = full left, 0.0 = center, 1.0 = full right
// cos/sin balance control--note, when set to center, l/r reduced by -3dB
#pragma optimize_for_space
SEG_MOD_SLOW_CODE void AMF_ScalerSmoothed_DS_SetBalance(AMF_ScalerSmoothed_DS * restrict instance,float balance) {
    float theta = 0.25 * PI * (1.0 + balance);
    int rtn;
    float cosTheta,sinTheta;
    
    cosTheta = cos(theta);
    sinTheta = sin(theta);
    instance->amp0Target = cosTheta;
    instance->amp1Target = sinTheta;
}


SEG_MOD_SLOW_CONST AMF_ModuleClass AMFClassScalerSmoothed_DS =
{
    /** Flags. */
    0,

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

    /* 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 + -