📄 amf_peakhold.c
字号:
// Copyright(c) 2003 Analog Devices, Inc. All Rights Reserved. ADI Confidential.
// File : $Id: //depot/development/visualaudio/modules/2.5.0/SHARC/Source/AMF_PeakHold.c#3 $
// Part of : VisualAudio V2.5.0
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $
#include "AMF_PeakHold.h"
#include "math.h"
void AMF_PeakHold_Render(AMF_PeakHold * restrict instance,AMF_Signal * restrict * buffers,int tickSize);
SEG_MOD_FAST_CODE void AMF_PeakHold_Render(AMF_PeakHold * restrict instance,AMF_Signal * restrict * buffers,int tickSize) {
int i;
AMF_Signal *in = buffers[0];
// parameters
float attackCoef = instance->attackCoef;
float decayCoef = instance->decayCoef;
// states
float *state = &instance->state[0];
// local variables
float maxInput, envCoef;
// find maximum input value in tick
maxInput = 0;
for(i=0;i<tickSize;i++)
maxInput = fmaxf(maxInput, in[i]);
// determine if envelope detector is in attack or release
if(state[0] < maxInput)
envCoef = attackCoef;
else
envCoef = decayCoef;
// move value of state into part of array that can be
// modified by inspector
state[1] = fmaxf(state[0],state[1]);
// one pole filter for envelope detector,
// where filter coef is determined above
state[0] = envCoef*maxInput + (1.0-envCoef)*state[0];
}
SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassPeakHold = {
/* Flags */
0,
/* Render function */
(AMF_RenderFunction)AMF_PeakHold_Render, // render function
/* Default bypass */
(void *)0,
/* Input descriptor - one input. */
1, 0,
/* Output descriptor - no ouputs, and control rate if there was one. */
0, AMF_ControlPin(1)
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -