📄 g722main.c
字号:
#include <stdlib.h>
#include "rtdspc.h"
/* Main program for g722 encode and decode demo for 210X0 */
extern int encode(int,int);
extern void decode(int);
extern void reset();
/* outputs of the decode function */
extern int xout1,xout2;
int chkl_coded[6000];
extern int pm chkl[];
void main()
{
int i,j,t1,t2;
float xf1 = 0.0;
float xf2 = 0.0;
/* reset, initialize required memory */
reset();
/* code the speech, interpolate because it was recorded at 8000 Hz */
for(i = 0 ; i < 6000 ; i++) {
t1=64*chkl[i];
t2=32*(chkl[i]+chkl[i+1]);
chkl_coded[i]=encode(t1,t2);
}
/* interpolate output to 32 KHz */
for(i = 0 ; i < 6000 ; i++) {
decode(chkl_coded[i]);
xf1 = (float)xout1;
sendout(0.5*xf2+0.5*xf1);
sendout(xf1);
xf2 = (float)xout2;
sendout(0.5*xf2+0.5*xf1);
sendout(xf2);
}
/* simulate a 16 KHz sampling rate (actual is 32 KHz) */
/* note: the g722 standard calls for 16 KHz for voice operation */
while(1) {
t1=0.5*(getinput()+getinput());
t2=0.5*(getinput()+getinput());
j=encode(t1,t2);
decode(j);
xf1 = (float)xout1;
sendout(0.5*(xf1+xf2));
sendout(xf1);
xf2 = (float)xout2;
sendout(0.5*(xf2+xf1));
sendout(xf2);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -