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

📄 pitsyn.c

📁 lpc10-15为美军2400bps语音压缩标准的C语音源代码。
💻 C
📖 第 1 页 / 共 2 页
字号:
/*$Log: pitsyn.c,v $ * Revision 1.2  1996/08/20  20:40:12  jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1  1996/08/19  22:31:12  jaf * Initial revision **/#ifdef P_R_O_T_O_T_Y_P_E_Sextern int pitsyn_(integer *order, integer *voice, integer *pitch, real *rms, real *rc, integer *lframe, integer *ivuv, integer *ipiti, real *rmsi, real *rci, integer *nout, real *ratio, struct lpc10_decoder_state *st);#endif/*  -- translated by f2c (version 19951025).   You must link the resulting object file with the libraries:	-lf2c -lm   (in that order)*/#include "f2c.h"/* ***************************************************************** *//* 	PITSYN Version 53 *//* $Log: pitsyn.c,v $ * Revision 1.2  1996/08/20  20:40:12  jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1  1996/08/19  22:31:12  jaf * Initial revision * *//* Revision 1.2  1996/03/25  18:49:07  jaf *//* Added commments about which indices of array arguments are read or *//* written. *//* Rearranged local variable declarations to indicate which need to be *//* saved from one invocation to the next.  Added entry INITPITSYN to *//* reinitialize local state variables, if desired. *//* Added lots of comments about proving that the maximum number of pitch *//* periods (NOUT) that can be returned is 16.  The call to STOP that *//* could happen if NOUT got too large was removed as a result. *//* Also proved that the total number of samples returned from N calls, *//* each with identical values of LFRAME, will always be in the range *//* N*LFRAME-MAXPIT+1 to N*LFRAME. *//* Revision 1.1  1996/02/07 14:48:18  jaf *//* Initial revision *//* ***************************************************************** *//*   Synthesize a single pitch epoch *//* Input: *//*  ORDER  - Synthesis order (number of RC's) *//*  VOICE  - Half frame voicing decisions *//*           Indices 1 through 2 read. *//*  LFRAME - Length of speech buffer *//* Input/Output: *//*  PITCH  - Pitch *//*           This value should be in the range MINPIT (20) to MAXPIT *//*           (156), inclusive. *//*           PITCH can be modified under some conditions. *//*  RMS    - Energy  (can be modified) *//*           RMS is changed to 1 if the value passed in is less than 1. *//*  RC     - Reflection coefficients *//*           Indices 1 through ORDER can be temporarily overwritten with *//*           RCO, and then replaced with original values, under some *//*           conditions. *//* Output: *//*  IVUV   - Pitch epoch voicing decisions *//*           Indices (I) of IVUV, IPITI, and RMSI are written, *//*           and indices (J,I) of RCI are written, *//*           where I ranges from 1 to NOUT, and J ranges from 1 to ORDER. *//*  IPITI  - Pitch epoch length *//*  RMSI   - Pitch epoch energy *//*  RCI    - Pitch epoch RC's *//*  NOUT   - Number of pitch periods in this frame *//*           This is at least 0, at least 1 if MAXPIT .LT. LFRAME (this *//*           is currently true on every call), and can never be more than *//*           (LFRAME+MAXPIT-1)/PITCH, which is currently 16 with *//*           LFRAME=180, MAXPIT=156, and PITCH .GE. 20, as SYNTHS *//*           guarantees when it calls this subroutine. *//*  RATIO  - Previous to present energy ratio *//*           Always assigned a value. *//* Subroutine */ int pitsyn_(integer *order, integer *voice, 	integer *pitch, real *rms, real *rc, integer *lframe, integer *ivuv, 	integer *ipiti, real *rmsi, real *rci, integer *nout, real *ratio,			       struct lpc10_decoder_state *st){    /* Initialized data */    real *rmso;    logical *first;    /* System generated locals */    integer rci_dim1, rci_offset, i__1, i__2;    real r__1;    /* Builtin functions */    double log(doublereal), exp(doublereal);    /* Local variables */    real alrn, alro, yarc[10], prop;    integer i__, j, vflag, jused, lsamp;    integer *jsamp;    real slope;    integer *ipito;    real uvpit;    integer ip, nl, ivoice;    integer *ivoico;    integer istart;    real *rco;    real xxy;/*       Arguments *//* $Log: pitsyn.c,v $ * Revision 1.2  1996/08/20  20:40:12  jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1  1996/08/19  22:31:12  jaf * Initial revision * *//* Revision 1.3  1996/03/29  22:03:47  jaf *//* Removed definitions for any constants that were no longer used. *//* Revision 1.2  1996/03/26  19:34:33  jaf *//* Added comments indicating which constants are not needed in an *//* application that uses the LPC-10 coder. *//* Revision 1.1  1996/02/07  14:43:51  jaf *//* Initial revision *//*   LPC Configuration parameters: *//* Frame size, Prediction order, Pitch period *//*       Local variables that need not be saved *//*       LSAMP is initialized in the IF (FIRST) THEN clause, but it is *//*       not used the first time through, and it is given a value before *//*       use whenever FIRST is .FALSE., so it appears unnecessary to *//*       assign it a value when FIRST is .TRUE. *//*       Local state *//* FIRST  - .TRUE. only on first call to PITSYN. *//* IVOICO - Previous VOICE(2) value. *//* IPITO  - Previous PITCH value. *//* RMSO   - Previous RMS value. *//* RCO    - Previous RC values. *//* JSAMP  - If this routine is called N times with identical values of *//*          LFRAME, then the total length of all pitch periods returned *//*          is always N*LFRAME-JSAMP, and JSAMP is always in the range 0 *//*          to MAXPIT-1 (see below for why this is so).  Thus JSAMP is *//*          the number of samples "left over" from the previous call to *//*          PITSYN, that haven't been "used" in a pitch period returned *//*          from this subroutine.  Every time this subroutine is called, *//*          it returns pitch periods with a total length of at most *//*          LFRAME+JSAMP. *//* IVOICO, IPITO, RCO, and JSAMP need not be assigned an initial value *//* with a DATA statement, because they are always initialized on the *//* first call to PITSYN. *//* FIRST and RMSO should be initialized with DATA statements, because *//* even on the first call, they are used before being initialized. */    /* Parameter adjustments */    if (rc) {	--rc;	}    if (rci) {	rci_dim1 = *order;	rci_offset = rci_dim1 + 1;	rci -= rci_offset;	}    if (voice) {	--voice;	}    if (ivuv) {	--ivuv;	}    if (ipiti) {	--ipiti;	}    if (rmsi) {	--rmsi;	}    /* Function Body */    ivoico = &(st->ivoico);    ipito = &(st->ipito);    rmso = &(st->rmso);    rco = &(st->rco[0]);    jsamp = &(st->jsamp);    first = &(st->first_pitsyn);    if (*rms < 1.f) {	*rms = 1.f;    }    if (*rmso < 1.f) {	*rmso = 1.f;    }    uvpit = 0.f;    *ratio = *rms / (*rmso + 8.f);    if (*first) {	lsamp = 0;	ivoice = voice[2];	if (ivoice == 0) {	    *pitch = *lframe / 4;	}	*nout = *lframe / *pitch;	*jsamp = *lframe - *nout * *pitch;/*          SYNTHS only calls this subroutine with PITCH in the range 20 *//*          to 156.  LFRAME = MAXFRM = 180, so NOUT is somewhere in the *//*          range 1 to 9. *//*          JSAMP is "LFRAME mod PITCH", so it is in the range 0 to *//*          (PITCH-1), or 0 to MAXPIT-1=155, after the first call. */	i__1 = *nout;	for (i__ = 1; i__ <= i__1; ++i__) {	    i__2 = *order;	    for (j = 1; j <= i__2; ++j) {		rci[j + i__ * rci_dim1] = rc[j];	    }	    ivuv[i__] = ivoice;	    ipiti[i__] = *pitch;	    rmsi[i__] = *rms;	}	*first = FALSE_;    } else {	vflag = 0;	lsamp = *lframe + *jsamp;	slope = (*pitch - *ipito) / (real) lsamp;	*nout = 0;	jused = 0;	istart = 1;	if (voice[1] == *ivoico && voice[2] == voice[1]) {	    if (voice[2] == 0) {/* SSUV - -   0  ,  0  ,  0 */		*pitch = *lframe / 4;		*ipito = *pitch;		if (*ratio > 8.f) {		    *rmso = *rms;		}	    }

⌨️ 快捷键说明

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