📄 amf_tonecontrolbass.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_ToneControlBass.c#3 $
// Part of : VisualAudio V2.5.0
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $
#include "AMF_ToneControlBass.h"
#include "VA_GeneralHelperFunctions.h"
void AMF_ToneControlBass_Render(AMF_ToneControlBass * 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 // C example code
#pragma optimize_for_speed
SEG_MOD_FAST_CODE void AMF_ToneControlBass_Render(AMF_ToneControlBass * restrict instance,float * restrict * buffers,int tickSize) {
int i;
float amp = instance->amp;
float amp2;
float ampTarget = instance->ampTarget;
float state = instance->state;
float ampSmoothing = instance->ampSmoothing;
float b0 = instance->b0;
float oneMinusRate = 1.0 - ampSmoothing;
float tmp;
float allPass;
float *in = buffers[0]; // Don't use restrict because we say they can alias (see .h file)
float *out = buffers[1];
float *t=out;
// These coefs are used in a modified version of the smoothing calculation
// which computes two samples at a time, and is thus good for SIMD
float c1 = oneMinusRate * oneMinusRate;
float c2 = 1 - c1;
// compute the allpass into a temp buffer (the output in this case)
for (i=0; i<tickSize; i++) {
tmp = in[i] - b0 * state;
allPass = b0 * tmp + state;
state = tmp;
t[i] = allPass;
}
instance->state = state;
amp2 = amp * oneMinusRate + ampTarget * ampSmoothing;
// the Regalia-Mitra low shelf with smoothed Amp
// This loop is layed out as what gets done in the SIMD optimization in the asm version
for (i=0; i<tickSize; i+=2) {
amp = c1*amp + c2*ampTarget;
amp2 = c1*amp2 + c2*ampTarget;
out[i] = 0.5 * ( amp * (in[i] + t[i]) + (in[i] - t[i]) );
out[i+1] = 0.5 * ( amp2 * (in[i+1] + t[i+1]) + (in[i+1] - t[i+1]) );
}
instance->amp = amp;
}
#endif
SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassToneControlBass = {
/* Flags */
0,
/** Reference to render function. */
(AMF_RenderFunction)AMF_ToneControlBass_Render,
/* 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 + -