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

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



#include "AMF_VolumeFletcherMunson_S.h"
#include "VA_GeneralHelperFunctions.h"

void AMF_VolumeFletcherMunson_S_Render(AMF_VolumeFletcherMunson_S * 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_VolumeFletcherMunson_S_Render(AMF_VolumeFletcherMunson_S * restrict instance,float * restrict * buffers,int tickSize) {
    int i;
    float amp = instance->amp;
    float ampTarget = instance->ampTarget;
    float lowAmp = instance->lowAmp;
    float lowAmpTarget = instance->lowAmpTarget;
    float pm *state1 = &instance->aux->state1[0];
    float pm *state2 = &instance->aux->state2[0];
    float ampSmoothing = instance->ampSmoothing;
    float b0 = instance->b0;
    float b1 = instance->b1;

    float oneMinusRate = 1.0 - ampSmoothing;
    float tmp[2];
    float allPass[2];
    float *in = buffers[0]; // Don't use restrict because we say they can alias (see .h file)
    float *out = buffers[1];
    float *t = out;

        // the allpass filter, in -> out
    for (i=0; i<tickSize*2; i+=2) {
        tmp[0] =  in[i]   - b1 * state1[0] - b0 * state2[0];
        tmp[1] =  in[i+1] - b1 * state1[1] - b0 * state2[1];
        t[i]   = b0 * tmp[0] + b1 * state1[0] + state2[0];
        t[i+1] = b0 * tmp[1] + b1 * state1[1] + state2[1];
        state2[0] = state1[0];
        state2[1] = state1[1];
        state1[0] = tmp[0];
        state1[1] = tmp[1];
    }

        // smothing and Regalia-Mitra boost, out->out
    for (i=0; i<tickSize*2; i+=2) {
        // the smoothed amplitude and 'peaking' amplitude
        amp = amp * oneMinusRate + ampTarget * ampSmoothing;
        lowAmp = lowAmp * oneMinusRate + lowAmpTarget * ampSmoothing;
        
        // the Regalia-Mitra low boost
        //out[i] = 0.5 * ( (amp + lowAmp) * in[i] + (amp - lowAmp) * t[i] );
        //out[i+1] = 0.5 * ( (amp + lowAmp) * in[i+1] + (amp - lowAmp) * t[i+1] );
        // or...
        out[i] = 0.5 * (amp * (in[i] + t[i]) + lowAmp * (in[i] - t[i]) );
        out[i+1] = 0.5 * (amp * (in[i+1] + t[i+1]) + lowAmp * (in[i+1] - t[i+1]) );
    }
    instance->amp = amp;
    instance->lowAmp = lowAmp;
}
#endif

SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassVolumeFletcherMunson_S = {
        
    /* Flags */
    0,

    /** Reference to render function. */
    (AMF_RenderFunction)AMF_VolumeFletcherMunson_S_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)
};

// Class-specific helper functions

// see AMF_SetFMGain() in VA_GeneralHelperFunctions.c
// also macro in AMF_VolumeFletcherMunson_S.h
//    AMF_VolumeFletcherMunson_S_SetGain()
// Function to set Volume VolumeFletcherMunson and VolumeFletcherMunson_S in dB (-192.0 - 0.0)
// Bass Boost calculated via 2nd order polynomial

⌨️ 快捷键说明

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