⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 melp_s.c

📁 It is source code for Melp2.4kps vocoder using dsp tms320vc55x of ti
💻 C
字号:

/*								    */
/*  melp.c: Mixed Excitation LPC speech coder			    */
/*								    */


/* Note:  This main is set up to read the channel files from the host and
   run synthesis only.  The output of the synthesizer is sent back to the
   PC for verification.
*/


/*  compiler include files  */
#include	<c50regs.h>

#include "melp.h"
#include "spbstd.h"
#include "mat.h"


/* Globals */
int saturation = 0;

/*  compiler constants */
#define ANA_SYN 0
#define ANALYSIS 1
#define SYNTHESIS 2

/* note: CHSIZE is shortest integer number of words in channel packet */
#define CHSIZE 9
#define NUM_CH_BITS 54

/*  external memory */
Shortword melpmode = SYNTHESIS;     /* **** Run Synthesis ONLY *** */
char in_name[80], out_name[80];

/* Used for timing code */
volatile unsigned int	 TCount = 0;
/* For timing analysis */
/* For timing synthsis */
/* General purpose timer */
volatile unsigned int tArray[3];

volatile unsigned int command;
extern void c_int0();
#define RESET	0x5555

/* Routine to initialize the DSP */

void main(int argc, char **argv)

{

    Shortword i;
    Longword length, frame;
    Shortword eof_reached;
    Longword num_frames = 0;
    Shortword speech_in[FRAME];
    Shortword speech_out[FRAME];
    static struct melp_param melp_par;	    /* melp parameters */
    UShortword chbuf[CHSIZE];
    unsigned int tempbuf[CHSIZE];

    /* Initialze the DSP */
    DSP_Init();

    /* Initialize MELP analysis and synthesis */
    melp_ana_init();
    melp_syn_init();

    /* Run MELP coder on input signal */
    frame = 0;
    melp_par.chptr = chbuf;
    melp_par.chbit = 0;
    eof_reached = 0;

    while (eof_reached == 0) {

        /* Get the command, process or reset */
        getFrame(&command, 1);
        if (command == RESET)
            c_int0();


	/* Clear general purpose timer */
	TCount = 0;


	/* Perform MELP synthesis (skip first frame) */
	if (melpmode != ANALYSIS) {

            /* reset pointers to short channel buffer */
            melp_par.chptr = chbuf;
            melp_par.chbit = 0;


            /* Get bit stream to the PC */
            getFrame(chbuf, CHSIZE);


	    tArray[1] = TCount;
	    melp_syn(&melp_par,speech_out);
	    tArray[1] = TCount - tArray[1];


	    /* Send Data from PC */
	    sendFrame(speech_out, FRAME);

	}

	/* Now send run times to PC */
	sendFrame(&tArray, 3);

        /* Increment frame counter */
	frame++;

    }

}




/* Get a variable amount of data from the PC host */
int getFrame(Shortword *buf, int size) {

    int i;
    volatile int temp;

    for (i=0;i<size;i++) {
	while (1) {
	     temp =  *(volatile int *)0x52;

	     if ( (temp & 1) == 0) break;
	}

	temp = *(volatile int *)0x50;
	*buf++ = (Shortword)temp;

    }
}

/* Send a variable amount of data to the PC host */
int sendFrame(Shortword *buf, int size) {

    int i;
    volatile int temp;

    for (i=0;i<size;i++) {

	while (1) {
	   temp =  *(volatile int *)0x52;

	   if ( (temp & 2) == 0) break;
	}

	*(volatile int *)0x50 = (volatile int)*buf++;

    }
}

⌨️ 快捷键说明

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