📄 amf_testgensinequadrature.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_TestGenSineQuadrature.c#3 $
// Part of : VisualAudio V2.5.0
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $
#include "AMF_TestGenSineQuadrature.h"
#include <math.h>
void AMF_TestGenSineQuadrature_Render(AMF_TestGenSineQuadrature * restrict instance,float * restrict * buffers,int tickSize);
SEG_MOD_FAST_CODE void AMF_TestGenSineQuadrature_Render(AMF_TestGenSineQuadrature * restrict instance,float * restrict * buffers,int tickSize) {
int i;
float *out1 = buffers[0];
float *out2 = buffers[1];
float phaseInc, phase, phaseDiff;
phase = instance->phase;
phaseInc = instance->phaseInc;
phaseDiff = instance->phaseDiff;
for (i=0; i<tickSize; i++) {
phase += phaseInc;
if (phase > (2*3.141592653589793)) phase -= (2*3.141592653589793);
if (phase < 0) phase += (2*3.141592653589793);
out1[i]=sinf(phase);
out2[i]=sinf(phase+phaseDiff);
}
// In a module intended for speed, we might pull the wraparound out
// here after the main loop (they would have to be turned into while loops,
// probably), but since a high frequency might make for a "large" phase
// later on in the tick, that could cause slight errors in the
// (phase = "large value" + phaseInc) calculation (due to how floating-
// point addition works). So, since this is a module intended more for
// accuracy than speed, we'll put the wraparound inside the loop.
instance->phase = phase;
}
SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassTestGenSineQuadrature = {
/* Flags */
0,
/* Render function */
(AMF_RenderFunction)AMF_TestGenSineQuadrature_Render,
/* Default bypass */
(void *)0,
/* Input descriptor - no inputs. */
0, 0,
/* Output descriptor - 2 output, and they are mono. */
2, 0,
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -