📄 amf_testgensinesweep.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_TestGenSineSweep.c#3 $
// Part of : VisualAudio V2.5.0
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $
#include "AMF_TestGenSineSweep.h"
#include <math.h>
void AMF_TestGenSineSweep_Render(AMF_TestGenSineSweep * restrict instance,float * restrict * buffers,int tickSize);
SEG_MOD_FAST_CODE void AMF_TestGenSineSweep_Render(AMF_TestGenSineSweep * restrict instance,float * restrict * buffers,int tickSize) {
int i;
float *out = buffers[0];
float phaseInc, phase, startInc, endInc, incRatio;
int repeatPeriod, repeatCounter;
phase = instance->phase;
phaseInc = instance->phaseInc;
startInc = instance->startInc;
endInc = instance->endInc;
incRatio = instance->incRatio;
repeatCounter = instance->repeatCounter;
repeatPeriod = instance->repeatPeriod;
if (phaseInc == 0) phaseInc = startInc;
for (i=0; i<tickSize; i++) {
// if we cross past endinc, the sweep is finished, get ready to repeat
if ((incRatio > 1.0 && phaseInc > endInc) || (incRatio < 1.0 && phaseInc < endInc))
{
out[i] = 0.0;
if (repeatPeriod == 0)
{
repeatCounter = repeatPeriod;
phase = 0;
phaseInc = startInc;
}
} else
{
if (phase > (2*3.141592653589793)) phase -= (2*3.141592653589793);
if (phase < 0) phase += (2*3.141592653589793);
out[i]=sinf(phase);
phase += phaseInc;
}
phaseInc *= incRatio;
if (repeatPeriod > 0)
repeatCounter--;
if (repeatCounter <= 0)
{
repeatCounter = repeatPeriod;
phase = 0;
phaseInc = startInc;
}
}
instance->phase = phase;
instance->phaseInc = phaseInc;
instance->repeatCounter = repeatCounter;
}
SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassTestGenSineSweep = {
/* Flags */
0,
/* Render function */
(AMF_RenderFunction)AMF_TestGenSineSweep_Render,
/* Default bypass */
(void *)0,
/* Input descriptor - no inputs. */
0, 0,
/* Output descriptor - 1 output, and it is mono. */
1, 0,
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -