📄 volume.c
字号:
/******************************************************************************/
/* 作者:艾岩 */
/* 版本:1.0 */
/* 日期:06.8.22 */
/******************************************************************************/
#include <stdio.h>
#include "volume.h"
/* Global declarations */
int in1_buffer[BUFSIZE];
int in2_buffer[BUFSIZE]; /* processing data buffers */
int out1_buffer[BUFSIZE];
int out2_buffer[BUFSIZE];
int out3_buffer[BUFSIZE];
int out4_buffer[BUFSIZE*2];
int size = BUFSIZE;
int ain = MINGAIN;
int zhy=0;
int sk=64; /*sk代表所开的bufsize的大小.输入文件sine.dat为32点,sine11.dat,
sin22.dat,sin33.dat,sin44.dat为64点的输入波形.*/
/* Functions */
static int step1(int *output1, int *output2);
static int step2(int *output2, int *output3);
static int step3(int *input1,int *output2,int *output4);
static int step4(int *input2, int *output1);
static void dataIO1(void);
static void dataIO2(void);
/******************************************************************/
/*main */
/******************************************************************/
void main()
{
int *input1 = &in1_buffer[0];
int *input2 = &in2_buffer[0];
int *output1 = &out1_buffer[0];
int *output2 = &out2_buffer[0];
int *output3 = &out3_buffer[0];
int *output4 = &out4_buffer[0];
puts("volume example started\n");
/* loop forever */
while(TRUE)
{
/*
* Read input data using a probe-point connected to a host file.
* Write output data to a graph connected through a probe-point.
*/
dataIO1(); // break point
dataIO2(); // break point
step4(input2,output1);
step1(output1, output2);
step2(output2, output3);
step3(input1,output2,output4) ;
}
}
/******************************************************************/
/* 函数声明:卷积的四个步骤 */
/* */
/* FUNCTION: apply signal processing transform to input signal. */
/* */
/* PARAMETERS: address of input and output buffers. */
/* */
/* RETURN VALUE: TRUE. */
/******************************************************************/
/******************************************************************/
/* step4 对输出的input2 buffer波形截取m,然后把生成的波形上的各点 */
/* 的值存入以output1指针开始的一段地址空间中 */
/******************************************************************/
static int step4(int *input2,int *output1)
{
int m=sk;
for(;m>=0;m--)
{
*output1++ = *input2++ * ain;
}
for(;(size-m)>0;m++)
{
output1[m]=0;
}
return(TRUE);
}
/******************************************************************/
/* step1 对输入的output1 buffer波形进行截取m点,再以零点的Y轴为对 */
/* 称轴进行翻褶,把生成的波形上的值存入以output2指针开始的 */
/* 一段地址空间中 */
/******************************************************************/
static int step1(int *output1,int *output2)
{
int m=sk-1;
for(;m>0;m--)
{
*output2++ = *output1++ * ain;
}
return(TRUE);
}
/******************************************************************/
/* step2 对输出的output2 buffer波形进行作n点移位,然后把生成的波形 */
/* 上的值存入以output3指针开始的一段地址空间中 */
/******************************************************************/
static int step2(int *output2, int *output3)
{
int n=zhy;
size=BUFSIZE;
for(;(size-n)>0;n++)
{
*output3++ = output2[n];
}
return(TRUE);
}
/******************************************************************/
/* step3 对输入的output2 buffer波形和输入的input1 buffer作卷积运算*/
/* 然后把生成的波形上的各点的值存入以output4指针开始的一段 */
/* 地址空间中 */
/******************************************************************/
static int step3(int *input1,int *output2,int *output4)
{
int m=sk;
int y=zhy;
int z,x,w,i,f,g;
for(;(m-y)>0;)
{
i=y;
x=0;
z=0;
f=y;
for(;i>=0;i--)
{
g=input1[z]*output2[f];
x=x+g;
z++;
f--;
}
*output4++ = x;
y++;
}
m=sk;
y=sk-1;
w=m-zhy-1;
for(;m>0;m--)
{
y--;
i=y;
z=sk-1;
x=0;
f=sk-y;
for(;i>0;i--,z--,f++)
{
g=input1[z]*output2[f];
x=x+g;
}
out4_buffer[w]=x;
w++;
}
return(TRUE);
}
/******************************************************************/
/* 函数声明:dataIO */
/* */
/* FUNCTION: read input signal and write processed output signal. */
/* */
/* PARAMETERS: address of input and output buffers. */
/******************************************************************/
static void dataIO1()
{
/* do data I/O */
return;
}
static void dataIO2()
{
/* do data I/O */
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -