g722main.c

来自「dsp AD公司ADSP21的代码,里面有FFT FIR IIR EQULIZE」· C语言 代码 · 共 79 行

C
79
字号
#include <math.h>
#include "rtdspc.h"

/* Main program for g722 encode and decode demo for DSP32C */

    extern int encode();
    extern void decode();
    extern void reset();

/* outputs of the decode function */
    extern float xout1,xout2;

#define BUF_SIZE 15000

    extern short int chkl[];
    short int buffer[BUF_SIZE];

/* this code tests the routines but does not run in real-time
on most DSP32C boards because the compiler/processor combination
is not efficient enough for this G722 encode and decode algorithm
(decode does run in real-time as implemented here) */

void main()
{
    int i,j;
    float t1,t2;

/* reset, initialize required memory */
    reset();

/* code the speech, interpolate because it was recorded at 8000 Hz */
    for(i = 0 ; i < 5999 ; i++) {
        t1=64.0*(float)chkl[i];
        t2=32.0*(float)(chkl[i]+chkl[i+1]);
        chkl[i]=encode(t1,t2);
    }

/* output sample rate is 16 kHz */
    for(i = 0 ; i < 6000 ; i++) {
        decode(chkl[i]);
        sendout(xout1);
        sendout(xout2);
    }

/* note: the g722 standard calls for 16 KHz for voice operation */
    while(1) {
/* used for non-realtime test:
*/
      for(i = 0 ; i < BUF_SIZE ; i++) {
        buffer[i] = (int)getinput();
        sendout(0.0);
      }
      for(i = 0 ; i < BUF_SIZE ; i+=2) {
        buffer[i/2]=encode((float)buffer[i],(float)buffer[i+1]);
      }
/* this is realtime for encode:
      for(i = 0 ; i < BUF_SIZE ; i++) {
        t1 = getinput();
        t2 = getinput();
        buffer[i]=encode(t1,t2);
        sendout(0.0);
        sendout(0.0);
      }
*/
/* used for pass test:
      for(i = 0 ; i < BUF_SIZE ; i++) sendout((float)buffer[i]);
*/
      int_disable();
      out_int_enable();
      for(i = 0 ; i < BUF_SIZE/2 ; i++) {
        decode((int)buffer[i]);
        sendout(xout1);
        sendout(xout2);
      }
      flush();
      in_int_enable();
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?