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

📄 melp.h

📁 It is source code for Melp2.4kps vocoder using dsp tms320vc55x of ti
💻 H
字号:
/*************************************************************************
*
* The following code was hand optimized for the Texas Instuments
* TMS320C5x DSP by DSPCon, Inc.  For information, please contact DSPCon
* at:
* 
*                       DSPCon, Inc.
*                       380 Foothill Road
*                       Bridgewater, New Jersey 08807
*                       (908) 722-5656
*                       info@dspcon.com
*                       www.dspcon.com
*
*************************************************************************/



/*								    */
/*  melp.h: include file for MELP coder 			    */
/*								    */

#ifndef _melp_h
#define _melp_h_

/*  compiler constants */
#define FRAME 180	    /* speech frame size */
#define LPC_ORD 10	    /* LPC order */
#define NUM_HARM 10	    /* number of Fourier magnitudes */
#define NUM_GAINFR 2	    /* number of gains per frame */
#define LPC_FRAME 200	    /* LPC window size */
#define PITCHMIN 20	    /* minimum pitch lag */
#define PITCHMAX 160	    /* maximum pitch lag */
#define PITCHMAX_X2 (PITCHMAX*2)   /* maximum pitch lag times 2 */
#define NUM_BANDS 5	    /* number of frequency bands */
#define LPF_ORD 6	    /* lowpass filter order */
#define DC_ORD 4	    /* DC removal filter order */
#define BPF_ORD 6	    /* bandpass analysis filter order */
#define ENV_ORD 2	    /* bandpass envelope filter order */
#define MIX_ORD 32	    /* mixed excitation filtering order */
#define DISP_ORD 64	    /* pulse dispersion filter order */
#define DEFAULT_PITCH 50	    /* default pitch value */
#define DEFAULT_PITCH_Q7 (50*(1<<7))  /* default pitch value in Q7 */
#define UV_PITCH 50	    /* unvoiced pitch value */
#define UV_PITCH_Q7 (50*(1<<7))       /* unvoiced pitch value in Q7 */
#define VMIN_Q14 (0.8*(1<<14))	      /* minimum strongly voiced correlation */
#define VJIT_Q14 (0.5*(1<<14))	/* jitter threshold for correlations */
#define BPTHRESH_Q14 (0.6*(1<<14))    /* bandpass voicing threshold */
#define MAX_JITTER_Q15 (Shortword)((0.25*((Longword)1<<15))) /* maximum jitter (as a fraction) */
#define ASE_NUM_BW_Q15 (Shortword)((0.5*((Longword)1<<15)))  /* adaptive spectral enhancement-numer */
#define ASE_DEN_BW_Q15 (Shortword)((0.8*((Longword)1<<15)))  /* adaptive spectral enhancement-denom */
#define GAINFR (FRAME/NUM_GAINFR)  /* size of gain frame */
#define MIN_GAINFR 120	    /* minimum gain analysis window */
#define GAIN_PITCH_Q7 ((1.33*GAINFR-0.5)*(1<<7)) /* pitch input for gain_ana */
#define MINLENGTH 160	    /* minimum correlation length */
#define PI		3.141592654
#define TWOPI		6.283185308
#define FSAMP 8000	    /* sampling frequency */
#define MSVQ_M 8	    /* M-best for MSVQ search */
#define MSVQ_MAXCNT 256     /* maximum inner loop counter for MSVQ search */
#define BWMIN_Q15 (Shortword)((50*2/FSAMP)*((Longword)1<<15))	/* minimum LSF separation */

/* Noise suppression/estimation parameters */
/* Up by 3 dB/sec (0.5*22.5 ms frame), down by 12 dB/sec */
#define UPCONST_Q19 (0.0337435*((Longword)1<<19))   /* noise estimation up time const */
#define DOWNCONST_Q17 (-0.135418*((Longword)1<<17)) /* noise estimation dn time const */
#define NFACT_Q8 (3.0*(1<<8))		 /* noise floor boost in dB */
#define MAX_NS_ATT_Q8 (6.0*(1<<8))	 /* maximum noise suppression */
#define MAX_NS_SUP_Q8 (20.0*(1<<8)) /* max noise level to use in suppression */
#define MIN_NOISE_Q8 (10.0*(1<<8))  /* min value allowed in noise estimation */
#define MAX_NOISE_Q8 (80.0*(1<<8))  /* max value allowed in noise estimation */

/* Channel I/O constants */
#define CHWORDSIZE 6	     /* number of bits per channel word */
#define ERASE_MASK 0x4000    /* erasure flag mask for channel word */

#define GN_QLO_Q8 (10.0*(1<<8)) 	/* minimum gain in dB */
#define GN_QUP_Q8 (77.0*(1<<8)) 	/* maximum gain in dB */
#define GN_QLEV_M1 (32-1)	      /* no. of 2nd gain quantization levels */
#define GN_QLEV_M1_Q10 ((32-1)*(1<<10)) /* GN_QLEV_M1 in Q10 */
#define PIT_BITS 7		      /* number of bits for pitch coding */
#define PIT_QLEV 99		      /* number of pitch levels minus 1 */
#define PIT_QLEV_M1 (99-1)	      /* number of pitch levels minus 1 */
#define PIT_QLEV_M1_Q8 ((99-1)*(1<<8))	/* number of pitch levels minus 1 */
#define PIT_QLO_Q12 (1.30103*(1<<12))  /* minimum log pitch for quantization */
#define PIT_QUP_Q12 (2.20412*(1<<12))  /* maximum log pitch for quantization */
#define FS_BITS 8	     /* number of bits for Fourier magnitudes */
#define FS_LEVELS (1<<FS_BITS) /* number of levels for Fourier magnitudes */

/* External function definitions */

#include "typedefs.h"
#include "dsp_sub.h"
#include "melp_sub.h"

/* Structure definitions */
struct melp_param {	    /* MELP parameters */
    Shortword pitch;			/* Q7 */
    Shortword lsf[LPC_ORD+1];		/* Q15 */
    Shortword gain[NUM_GAINFR]; 	/* Q8 */
    Shortword jitter;			/* Q15 */
    Shortword bpvc[NUM_BANDS];		/* Q14 */
    Shortword pitch_index;
    Shortword lsf_index[LPC_ORD];
    Shortword jit_index;
    Shortword bpvc_index;
    Shortword gain_index[NUM_GAINFR];
    UShortword *chptr;
    Shortword chbit;
    Shortword uv_flag;
    Shortword fs_mag[NUM_HARM]; 	/* Q13 */
    Shortword *fsvq_index;
    Shortword *msvq_index;
    Shortword msvq_stages;
    Shortword *msvq_bits;
    Shortword *msvq_levels;
};


void melp_ana(Shortword sp_in[],struct melp_param *par);
void melp_syn(struct melp_param *par, Shortword sp_out[]);
void melp_ana_init();
void melp_syn_init();
void melp_chn_write(struct melp_param *par);
Shortword melp_chn_read(struct melp_param *par, struct melp_param *prev_par);

void fec_code(struct melp_param *par);
Shortword fec_decode(struct melp_param *par, Shortword erase);


#endif

⌨️ 快捷键说明

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