f2c.h File Reference

#include "lpc10.h"

Include dependency graph for f2c.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  alist
struct  cilist
struct  cllist
struct  complex
struct  doublecomplex
struct  icilist
struct  inlist
union  Multitype
struct  Namelist
struct  olist
struct  Vardesc

Defines

#define abs(x)   ((x) >= 0 ? (x) : -(x))
#define dabs(x)   (doublereal)abs(x)
#define dmax(a, b)   (doublereal)max(a,b)
#define dmin(a, b)   (doublereal)min(a,b)
#define Extern   extern
#define F2C_proc_par_types   1
#define FALSE_   (0)
#define max(a, b)   ((a) >= (b) ? (a) : (b))
#define min(a, b)   ((a) <= (b) ? (a) : (b))
#define TRUE_   (1)
#define VOID   void

Typedefs

typedef char * address
typedef VOID C_f
typedef VOID(* C_fp )(VOID)
typedef doublereal(* D_fp )(VOID)
typedef double doublereal
typedef doublereal E_f
typedef doublereal(*)(* E_fp )(VOID)
typedef long int flag
typedef long int ftnint
typedef long int ftnlen
typedef VOID H_f
typedef VOID(* H_fp )(VOID)
typedef integer(* I_fp )(VOID)
typedef char integer1
typedef shortint(* J_fp )(VOID)
typedef shortlogical(* K_fp )(VOID)
typedef logical(* L_fp )(VOID)
typedef char logical1
typedef union Multitype Multitype
typedef struct Namelist Namelist
typedef real(* R_fp )(VOID)
typedef int(* S_fp )(VOID)
typedef short int shortlogical
typedef int(* U_fp )(VOID)
typedef struct Vardesc Vardesc
typedef VOID Z_f
typedef VOID(* Z_fp )(VOID)

Functions

int bsynz_ (real *coef, integer *ip, integer *iv, real *sout, real *rms, real *ratio, real *g2pass, struct lpc10_decoder_state *st)
int chanrd_ (integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits)
int chanwr_ (integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits, struct lpc10_encoder_state *st)
int chanwr_0_ (int n__, integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits, struct lpc10_encoder_state *st)
int dcbias_ (integer *len, real *speech, real *sigout)
int decode_ (integer *ipitv, integer *irms, integer *irc, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_decoder_state *st)
int deemp_ (real *x, integer *n, struct lpc10_decoder_state *st)
int difmag_ (real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr)
int dyptrk_ (real *amdf, integer *ltau, integer *minptr, integer *voice, integer *pitch, integer *midx, struct lpc10_encoder_state *st)
int encode_ (integer *voice, integer *pitch, real *rms, real *rc, integer *ipitch, integer *irms, integer *irc)
int energy_ (integer *len, real *speech, real *rms)
int ham84_ (integer *input, integer *output, integer *errcnt)
int hp100_ (real *speech, integer *start, integer *end, struct lpc10_encoder_state *st)
integer i_nint (real *x)
int inithp100_ (void)
int initlpcdec_ (void)
int initlpcenc_ (void)
int invert_ (integer *order, real *phi, real *psi, real *rc)
int irc2pc_ (real *rc, real *pc, integer *order, real *gprime, real *g2pass)
int ivfilt_ (real *lpbuf, real *ivbuf, integer *len, integer *nsamp, real *ivrc)
int lpcdec_ (integer *bits, real *speech)
int lpcenc_ (real *speech, integer *bits)
int lpfilt_ (real *inbuf, real *lpbuf, integer *len, integer *nsamp)
integer median_ (integer *d1, integer *d2, integer *d3)
int mload_ (integer *order, integer *awins, integer *awinf, real *speech, real *phi, real *psi)
int onset_ (real *pebuf, integer *osbuf, integer *osptr, integer *oslen, integer *sbufl, integer *sbufh, integer *lframe, struct lpc10_encoder_state *st)
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)
int placea_ (integer *ipitch, integer *voibuf, integer *obound, integer *af, integer *vwin, integer *awin, integer *ewin, integer *lframe, integer *maxwin)
int placev_ (integer *osbuf, integer *osptr, integer *oslen, integer *obound, integer *vwin, integer *af, integer *lframe, integer *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh)
integer pow_ii (integer *ap, integer *bp)
int preemp_ (real *inbuf, real *pebuf, integer *nsamp, real *coef, real *z__)
int prepro_ (real *speech, integer *length, struct lpc10_encoder_state *st)
double r_sign (real *a, real *b)
integer random_ (struct lpc10_decoder_state *st)
int rcchk_ (integer *order, real *rc1f, real *rc2f)
int synths_ (integer *voice, integer *pitch, real *rms, real *rc, real *speech, integer *k, struct lpc10_decoder_state *st)
int tbdm_ (real *speech, integer *lpita, integer *tau, integer *ltau, real *amdf, integer *minptr, integer *maxptr, integer *mintau)
int voicin_ (integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *minamd, real *maxamd, integer *mintau, real *ivrc, integer *obound, integer *voibuf, integer *af, struct lpc10_encoder_state *st)
int vparms_ (integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *dither, integer *mintau, integer *zc, integer *lbe, integer *fbe, real *qs, real *rc1, real *ar_b__, real *ar_f__)


Define Documentation

#define abs (  )     ((x) >= 0 ? (x) : -(x))

#define dabs (  )     (doublereal)abs(x)

Definition at line 196 of file f2c.h.

#define dmax ( a,
b   )     (doublereal)max(a,b)

Definition at line 200 of file f2c.h.

#define dmin ( a,
b   )     (doublereal)min(a,b)

Definition at line 199 of file f2c.h.

#define Extern   extern

Definition at line 72 of file f2c.h.

#define F2C_proc_par_types   1

Definition at line 204 of file f2c.h.

#define FALSE_   (0)

Definition at line 68 of file f2c.h.

Referenced by decode_(), init_lpc10_encoder_state(), onset_(), pitsyn_(), placea_(), and placev_().

#define max ( a,
b   )     ((a) >= (b) ? (a) : (b))

#define min ( a,
b   )     ((a) <= (b) ? (a) : (b))

#define TRUE_   (1)

Definition at line 67 of file f2c.h.

Referenced by init_lpc10_decoder_state(), lpcini_(), onset_(), pitsyn_(), placea_(), and placev_().

#define VOID   void

Definition at line 163 of file f2c.h.


Typedef Documentation

typedef char* address

Definition at line 59 of file f2c.h.

typedef VOID C_f

Definition at line 231 of file f2c.h.

typedef VOID(* C_fp)(VOID)

Definition at line 223 of file f2c.h.

typedef doublereal(* D_fp)(VOID)

typedef double doublereal

barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."

  • From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition)

Definition at line 50 of file f2c.h.

typedef doublereal E_f

Definition at line 234 of file f2c.h.

typedef doublereal(*)(* E_fp)(VOID)

Definition at line 222 of file f2c.h.

typedef long int flag

Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 83 of file f2c.h.

typedef long int ftnint

Definition at line 85 of file f2c.h.

typedef long int ftnlen

Definition at line 84 of file f2c.h.

typedef VOID H_f

Definition at line 232 of file f2c.h.

typedef VOID(* H_fp)(VOID)

Definition at line 227 of file f2c.h.

typedef integer(* I_fp)(VOID)

Definition at line 220 of file f2c.h.

typedef char integer1

Definition at line 64 of file f2c.h.

typedef shortint(* J_fp)(VOID)

Definition at line 219 of file f2c.h.

typedef shortlogical(* K_fp)(VOID)

Definition at line 226 of file f2c.h.

typedef logical(* L_fp)(VOID)

Definition at line 225 of file f2c.h.

typedef char logical1

Definition at line 63 of file f2c.h.

typedef union Multitype Multitype

Definition at line 176 of file f2c.h.

typedef struct Namelist Namelist

Definition at line 193 of file f2c.h.

typedef real(* R_fp)(VOID)

Definition at line 221 of file f2c.h.

typedef int(* S_fp)(VOID)

Definition at line 228 of file f2c.h.

typedef short int shortlogical

Definition at line 62 of file f2c.h.

typedef int(* U_fp)(VOID)

Definition at line 218 of file f2c.h.

typedef struct Vardesc Vardesc

Definition at line 186 of file f2c.h.

typedef VOID Z_f

Definition at line 233 of file f2c.h.

typedef VOID(* Z_fp)(VOID)

Definition at line 224 of file f2c.h.


Function Documentation

int bsynz_ ( real coef,
integer ip,
integer iv,
real sout,
real rms,
real ratio,
real g2pass,
struct lpc10_decoder_state st 
)

int chanrd_ ( integer order,
integer ipitv,
integer irms,
integer irc,
integer ibits 
)

Definition at line 229 of file chanwr.c.

References chanwr_0_(), and NULL.

Referenced by lpc10_decode().

00231 {
00232     return chanwr_0_(1, order, ipitv, irms, irc, ibits, NULL);
00233     }

int chanwr_ ( integer order,
integer ipitv,
integer irms,
integer irc,
integer ibits,
struct lpc10_encoder_state st 
)

Definition at line 223 of file chanwr.c.

References chanwr_0_().

Referenced by lpc10_encode().

00225 {
00226     return chanwr_0_(0, order, ipitv, irms, irc, ibits, st);
00227     }

int chanwr_0_ ( int  n__,
integer order,
integer ipitv,
integer irms,
integer irc,
integer ibits,
struct lpc10_encoder_state st 
)

Definition at line 132 of file chanwr.c.

References lpc10_encoder_state::isync.

Referenced by chanrd_(), and chanwr_().

00135 {
00136     /* Initialized data */
00137 
00138     integer *isync;
00139     static integer bit[10] = { 2,4,8,8,8,8,16,16,16,16 };
00140     static integer iblist[53] = { 13,12,11,1,2,13,12,11,1,2,13,10,11,2,1,10,
00141        13,12,11,10,2,13,12,11,10,2,1,12,7,6,1,10,9,8,7,4,6,9,8,7,5,1,9,8,
00142        4,6,1,5,9,8,7,5,6 };
00143 
00144     /* System generated locals */
00145     integer i__1;
00146 
00147     /* Local variables */
00148     integer itab[13], i__;
00149 
00150 /*       Arguments */
00151 /*       Parameters/constants */
00152 /*       These arrays are not Fortran PARAMETER's, but they are defined */
00153 /*       by DATA statements below, and their contents are never altered. 
00154 */
00155 /*       Local variables that need not be saved */
00156 /*       Local state */
00157 /*       ISYNC is only used by CHANWR, not by ENTRY CHANRD. */
00158 
00159     /* Parameter adjustments */
00160     --irc;
00161     --ibits;
00162 
00163     /* Function Body */
00164     switch(n__) {
00165    case 1: goto L_chanrd;
00166    }
00167 
00168     isync = &(st->isync);
00169 
00170 /* ***********************************************************************
00171  */
00172 /*    Place quantized parameters into bitstream */
00173 /* ***********************************************************************
00174  */
00175 /*   Place parameters into ITAB */
00176     itab[0] = *ipitv;
00177     itab[1] = *irms;
00178     itab[2] = 0;
00179     i__1 = *order;
00180     for (i__ = 1; i__ <= i__1; ++i__) {
00181    itab[i__ + 2] = irc[*order + 1 - i__] & 32767;
00182     }
00183 /*   Put 54 bits into IBITS array */
00184     for (i__ = 1; i__ <= 53; ++i__) {
00185    ibits[i__] = itab[iblist[i__ - 1] - 1] & 1;
00186    itab[iblist[i__ - 1] - 1] /= 2;
00187     }
00188     ibits[54] = *isync & 1;
00189     *isync = 1 - *isync;
00190     return 0;
00191 /* ***********************************************************************
00192  */
00193 /*    Reconstruct parameters from bitstream */
00194 /* ***********************************************************************
00195  */
00196 
00197 L_chanrd:
00198 /*   Reconstruct ITAB */
00199     for (i__ = 1; i__ <= 13; ++i__) {
00200    itab[i__ - 1] = 0;
00201     }
00202     for (i__ = 1; i__ <= 53; ++i__) {
00203    itab[iblist[54 - i__ - 1] - 1] = (itab[iblist[54 - i__ - 1] - 1] << 1)
00204        + ibits[54 - i__];
00205     }
00206 /*   Sign extend RC's */
00207     i__1 = *order;
00208     for (i__ = 1; i__ <= i__1; ++i__) {
00209    if ((itab[i__ + 2] & bit[i__ - 1]) != 0) {
00210        itab[i__ + 2] -= bit[i__ - 1] << 1;
00211    }
00212     }
00213 /*   Restore variables */
00214     *ipitv = itab[0];
00215     *irms = itab[1];
00216     i__1 = *order;
00217     for (i__ = 1; i__ <= i__1; ++i__) {
00218    irc[i__] = itab[*order + 4 - i__ - 1];
00219     }
00220     return 0;
00221 } /* chanwr_ */

int dcbias_ ( integer len,
real speech,
real sigout 
)

int decode_ ( integer ipitv,
integer irms,
integer irc,
integer voice,
integer pitch,
real rms,
real rc,
struct lpc10_decoder_state st 
)

int deemp_ ( real x,
integer n,
struct lpc10_decoder_state st 
)

int difmag_ ( real speech,
integer lpita,
integer tau,
integer ltau,
integer maxlag,
real amdf,
integer minptr,
integer maxptr 
)

int dyptrk_ ( real amdf,
integer ltau,
integer minptr,
integer voice,
integer pitch,
integer midx,
struct lpc10_encoder_state st 
)

int encode_ ( integer voice,
integer pitch,
real rms,
real rc,
integer ipitch,
integer irms,
integer irc 
)

int energy_ ( integer len,
real speech,
real rms 
)

int ham84_ ( integer input,
integer output,
integer errcnt 
)

Definition at line 85 of file ham84.c.

References gsm_state::j.

Referenced by decode_().

00086 {
00087     /* Initialized data */
00088 
00089     static integer dactab[128] = { 16,0,0,3,0,5,14,7,0,9,14,11,14,13,30,14,0,
00090        9,2,7,4,7,7,23,9,25,10,9,12,9,14,7,0,5,2,11,5,21,6,5,8,11,11,27,
00091        12,5,14,11,2,1,18,2,12,5,2,7,12,9,2,11,28,12,12,15,0,3,3,19,4,13,
00092        6,3,8,13,10,3,13,29,14,13,4,1,10,3,20,4,4,7,10,9,26,10,4,13,10,15,
00093        8,1,6,3,6,5,22,6,24,8,8,11,8,13,6,15,1,17,2,1,4,1,6,15,8,1,10,15,
00094        12,15,15,31 };
00095 
00096     integer i__, j, parity;
00097 
00098 /*       Arguments */
00099 /*       Parameters/constants */
00100 /*       Local variables that need not be saved */
00101 /*  Determine parity of input word */
00102     parity = *input & 255;
00103     parity ^= parity / 16;
00104     parity ^= parity / 4;
00105     parity ^= parity / 2;
00106     parity &= 1;
00107     i__ = dactab[*input & 127];
00108     *output = i__ & 15;
00109     j = i__ & 16;
00110     if (j != 0) {
00111 /*          No errors detected in seven bits */
00112    if (parity != 0) {
00113        ++(*errcnt);
00114    }
00115     } else {
00116 /*          One or two errors detected */
00117    ++(*errcnt);
00118    if (parity == 0) {
00119 /*             Two errors detected */
00120        ++(*errcnt);
00121        *output = -1;
00122    }
00123     }
00124     return 0;
00125 } /* ham84_ */

int hp100_ ( real speech,
integer start,
integer end,
struct lpc10_encoder_state st 
)

Definition at line 113 of file hp100.c.

References lpc10_encoder_state::z11, lpc10_encoder_state::z12, lpc10_encoder_state::z21, and lpc10_encoder_state::z22.

Referenced by prepro_().

00115 {
00116     /* Temporary local copies of variables in lpc10_encoder_state.
00117        I've only created these because it might cause the loop below
00118        to execute a bit faster to access local variables, rather than
00119        variables in the lpc10_encoder_state structure.  It is just a
00120        guess that it will be faster. */
00121 
00122     real z11;
00123     real z21;
00124     real z12;
00125     real z22;
00126 
00127     /* System generated locals */
00128     integer i__1;
00129 
00130     /* Local variables */
00131     integer i__;
00132     real si, err;
00133 
00134 /*       Arguments */
00135 /*       Local variables that need not be saved */
00136 /*       Local state */
00137     /* Parameter adjustments */
00138     if (speech) {
00139    --speech;
00140    }
00141 
00142     /* Function Body */
00143 
00144     z11 = st->z11;
00145     z21 = st->z21;
00146     z12 = st->z12;
00147     z22 = st->z22;
00148 
00149     i__1 = *end;
00150     for (i__ = *start; i__ <= i__1; ++i__) {
00151    si = speech[i__];
00152    err = si + z11 * 1.859076f - z21 * .8648249f;
00153    si = err - z11 * 2.f + z21;
00154    z21 = z11;
00155    z11 = err;
00156    err = si + z12 * 1.935715f - z22 * .9417004f;
00157    si = err - z12 * 2.f + z22;
00158    z22 = z12;
00159    z12 = err;
00160    speech[i__] = si * .902428f;
00161     }
00162 
00163     st->z11 = z11;
00164     st->z21 = z21;
00165     st->z12 = z12;
00166     st->z22 = z22;
00167 
00168     return 0;
00169 } /* hp100_ */

integer i_nint ( real x  ) 

Definition at line 80 of file f2clib.c.

Referenced by placea_(), voicin_(), and vparms_().

00082 {
00083 return( (integer)((*x)>=0 ?
00084    floor(*x + .5) : -floor(.5 - *x)) );
00085 }

int inithp100_ ( void   ) 

int initlpcdec_ ( void   ) 

int initlpcenc_ ( void   ) 

int invert_ ( integer order,
real phi,
real psi,
real rc 
)

Definition at line 93 of file invert.c.

References abs, e, f, max, and min.

Referenced by analys_().

00094 {
00095     /* System generated locals */
00096     integer phi_dim1, phi_offset, i__1, i__2, i__3;
00097     real r__1, r__2;
00098 
00099     /* Local variables */
00100     real save;
00101     integer i__, j, k;
00102     real v[100]   /* was [10][10] */;
00103 
00104 /*       Arguments */
00105 /* $Log$
00106  * Revision 1.15  2004/06/26 03:50:14  markster
00107  * Merge source cleanups (bug #1911)
00108  *
00109  * Revision 1.14  2003/02/12 13:59:15  matteo
00110  * mer feb 12 14:56:57 CET 2003
00111  *
00112  * Revision 1.1.1.1  2003/02/12 13:59:15  matteo
00113  * mer feb 12 14:56:57 CET 2003
00114  *
00115  * Revision 1.2  2000/01/05 08:20:39  markster
00116  * Some OSS fixes and a few lpc changes to make it actually work
00117  *
00118  * Revision 1.1  1996/08/19  22:32:00  jaf
00119  * Initial revision
00120  * */
00121 /* Revision 1.3  1996/03/29  22:03:47  jaf */
00122 /* Removed definitions for any constants that were no longer used. */
00123 
00124 /* Revision 1.2  1996/03/26  19:34:33  jaf */
00125 /* Added comments indicating which constants are not needed in an */
00126 /* application that uses the LPC-10 coder. */
00127 
00128 /* Revision 1.1  1996/02/07  14:43:51  jaf */
00129 /* Initial revision */
00130 
00131 /*   LPC Configuration parameters: */
00132 /* Frame size, Prediction order, Pitch period */
00133 /*    Parameters/constants */
00134 /*       Local variables that need not be saved */
00135 /*  Decompose PHI into V * D * V' where V is a triangular matrix whose */
00136 /*   main diagonal elements are all 1, V' is the transpose of V, and */
00137 /*   D is a vector.  Here D(n) is stored in location V(n,n). */
00138     /* Parameter adjustments */
00139     --rc;
00140     --psi;
00141     phi_dim1 = *order;
00142     phi_offset = phi_dim1 + 1;
00143     phi -= phi_offset;
00144 
00145     /* Function Body */
00146     i__1 = *order;
00147     for (j = 1; j <= i__1; ++j) {
00148    i__2 = *order;
00149    for (i__ = j; i__ <= i__2; ++i__) {
00150        v[i__ + j * 10 - 11] = phi[i__ + j * phi_dim1];
00151    }
00152    i__2 = j - 1;
00153    for (k = 1; k <= i__2; ++k) {
00154        save = v[j + k * 10 - 11] * v[k + k * 10 - 11];
00155        i__3 = *order;
00156        for (i__ = j; i__ <= i__3; ++i__) {
00157       v[i__ + j * 10 - 11] -= v[i__ + k * 10 - 11] * save;
00158        }
00159    }
00160 /*  Compute intermediate results, which are similar to RC's */
00161    if ((r__1 = v[j + j * 10 - 11], abs(r__1)) < 1e-10f) {
00162        goto L100;
00163    }
00164    rc[j] = psi[j];
00165    i__2 = j - 1;
00166    for (k = 1; k <= i__2; ++k) {
00167        rc[j] -= rc[k] * v[j + k * 10 - 11];
00168    }
00169    v[j + j * 10 - 11] = 1.f / v[j + j * 10 - 11];
00170    rc[j] *= v[j + j * 10 - 11];
00171 /* Computing MAX */
00172 /* Computing MIN */
00173    r__2 = rc[j];
00174    r__1 = min(r__2,.999f);
00175    rc[j] = max(r__1,-.999f);
00176     }
00177     return 0;
00178 /*  Zero out higher order RC's if algorithm terminated early */
00179 L100:
00180     i__1 = *order;
00181     for (i__ = j; i__ <= i__1; ++i__) {
00182    rc[i__] = 0.f;
00183     }
00184 /*  Back substitute for PC's (if needed) */
00185 /* 110   DO J = ORDER,1,-1 */
00186 /*       PC(J) = RC(J) */
00187 /*       DO I = 1,J-1 */
00188 /*          PC(J) = PC(J) - PC(I)*V(J,I) */
00189 /*       END DO */
00190 /*    END DO */
00191     return 0;
00192 } /* invert_ */

int irc2pc_ ( real rc,
real pc,
integer order,
real gprime,
real g2pass 
)

Definition at line 82 of file irc2pc.c.

Referenced by synths_().

00084 {
00085     /* System generated locals */
00086     integer i__1, i__2;
00087 
00088     /* Builtin functions */
00089     double sqrt(doublereal);
00090 
00091     /* Local variables */
00092     real temp[10];
00093     integer i__, j;
00094 
00095 /*    Arguments */
00096 /* $Log$
00097  * Revision 1.15  2004/06/26 03:50:14  markster
00098  * Merge source cleanups (bug #1911)
00099  *
00100  * Revision 1.14  2003/02/12 13:59:15  matteo
00101  * mer feb 12 14:56:57 CET 2003
00102  *
00103  * Revision 1.1.1.1  2003/02/12 13:59:15  matteo
00104  * mer feb 12 14:56:57 CET 2003
00105  *
00106  * Revision 1.2  2000/01/05 08:20:39  markster
00107  * Some OSS fixes and a few lpc changes to make it actually work
00108  *
00109  * Revision 1.1  1996/08/19  22:31:56  jaf
00110  * Initial revision
00111  * */
00112 /* Revision 1.3  1996/03/29  22:03:47  jaf */
00113 /* Removed definitions for any constants that were no longer used. */
00114 
00115 /* Revision 1.2  1996/03/26  19:34:33  jaf */
00116 /* Added comments indicating which constants are not needed in an */
00117 /* application that uses the LPC-10 coder. */
00118 
00119 /* Revision 1.1  1996/02/07  14:43:51  jaf */
00120 /* Initial revision */
00121 
00122 /*   LPC Configuration parameters: */
00123 /* Frame size, Prediction order, Pitch period */
00124 /*       Local variables that need not be saved */
00125     /* Parameter adjustments */
00126     --pc;
00127     --rc;
00128 
00129     /* Function Body */
00130     *g2pass = 1.f;
00131     i__1 = *order;
00132     for (i__ = 1; i__ <= i__1; ++i__) {
00133    *g2pass *= 1.f - rc[i__] * rc[i__];
00134     }
00135     *g2pass = *gprime * (real)sqrt(*g2pass);
00136     pc[1] = rc[1];
00137     i__1 = *order;
00138     for (i__ = 2; i__ <= i__1; ++i__) {
00139    i__2 = i__ - 1;
00140    for (j = 1; j <= i__2; ++j) {
00141        temp[j - 1] = pc[j] - rc[i__] * pc[i__ - j];
00142    }
00143    i__2 = i__ - 1;
00144    for (j = 1; j <= i__2; ++j) {
00145        pc[j] = temp[j - 1];
00146    }
00147    pc[i__] = rc[i__];
00148     }
00149     return 0;
00150 } /* irc2pc_ */

int ivfilt_ ( real lpbuf,
real ivbuf,
integer len,
integer nsamp,
real ivrc 
)

Definition at line 89 of file ivfilt.c.

References e, and f.

Referenced by analys_().

00091 {
00092     /* System generated locals */
00093     integer i__1;
00094 
00095     /* Local variables */
00096     integer i__, j, k;
00097     real r__[3], pc1, pc2;
00098 
00099 /*    Arguments */
00100 /*       Local variables that need not be saved */
00101 /*       Local state */
00102 /*       None */
00103 /*  Calculate Autocorrelations */
00104     /* Parameter adjustments */
00105     --ivbuf;
00106     --lpbuf;
00107     --ivrc;
00108 
00109     /* Function Body */
00110     for (i__ = 1; i__ <= 3; ++i__) {
00111    r__[i__ - 1] = 0.f;
00112    k = (i__ - 1) << 2;
00113    i__1 = *len;
00114    for (j = (i__ << 2) + *len - *nsamp; j <= i__1; j += 2) {
00115        r__[i__ - 1] += lpbuf[j] * lpbuf[j - k];
00116    }
00117     }
00118 /*  Calculate predictor coefficients */
00119     pc1 = 0.f;
00120     pc2 = 0.f;
00121     ivrc[1] = 0.f;
00122     ivrc[2] = 0.f;
00123     if (r__[0] > 1e-10f) {
00124    ivrc[1] = r__[1] / r__[0];
00125    ivrc[2] = (r__[2] - ivrc[1] * r__[1]) / (r__[0] - ivrc[1] * r__[1]);
00126    pc1 = ivrc[1] - ivrc[1] * ivrc[2];
00127    pc2 = ivrc[2];
00128     }
00129 /*  Inverse filter LPBUF into IVBUF */
00130     i__1 = *len;
00131     for (i__ = *len + 1 - *nsamp; i__ <= i__1; ++i__) {
00132    ivbuf[i__] = lpbuf[i__] - pc1 * lpbuf[i__ - 4] - pc2 * lpbuf[i__ - 8];
00133     }
00134     return 0;
00135 } /* ivfilt_ */

int lpcdec_ ( integer bits,
real speech 
)

int lpcenc_ ( real speech,
integer bits 
)

int lpfilt_ ( real inbuf,
real lpbuf,
integer len,
integer nsamp 
)

Definition at line 83 of file lpfilt.c.

References e, f, and lpc10_decoder_state::j.

Referenced by analys_().

00085 {
00086     /* System generated locals */
00087     integer i__1;
00088 
00089     /* Local variables */
00090     integer j;
00091     real t;
00092 
00093 /*    Arguments */
00094 /*    Parameters/constants */
00095 /*       Local variables that need not be saved */
00096 /*       Local state */
00097 /*       None */
00098     /* Parameter adjustments */
00099     --lpbuf;
00100     --inbuf;
00101 
00102     /* Function Body */
00103     i__1 = *len;
00104     for (j = *len + 1 - *nsamp; j <= i__1; ++j) {
00105    t = (inbuf[j] + inbuf[j - 30]) * -.0097201988f;
00106    t += (inbuf[j - 1] + inbuf[j - 29]) * -.0105179986f;
00107    t += (inbuf[j - 2] + inbuf[j - 28]) * -.0083479648f;
00108    t += (inbuf[j - 3] + inbuf[j - 27]) * 5.860774e-4f;
00109    t += (inbuf[j - 4] + inbuf[j - 26]) * .0130892089f;
00110    t += (inbuf[j - 5] + inbuf[j - 25]) * .0217052232f;
00111    t += (inbuf[j - 6] + inbuf[j - 24]) * .0184161253f;
00112    t += (inbuf[j - 7] + inbuf[j - 23]) * 3.39723e-4f;
00113    t += (inbuf[j - 8] + inbuf[j - 22]) * -.0260797087f;
00114    t += (inbuf[j - 9] + inbuf[j - 21]) * -.0455563702f;
00115    t += (inbuf[j - 10] + inbuf[j - 20]) * -.040306855f;
00116    t += (inbuf[j - 11] + inbuf[j - 19]) * 5.029835e-4f;
00117    t += (inbuf[j - 12] + inbuf[j - 18]) * .0729262903f;
00118    t += (inbuf[j - 13] + inbuf[j - 17]) * .1572008878f;
00119    t += (inbuf[j - 14] + inbuf[j - 16]) * .2247288674f;
00120    t += inbuf[j - 15] * .250535965f;
00121    lpbuf[j] = t;
00122     }
00123     return 0;
00124 } /* lpfilt_ */

integer median_ ( integer d1,
integer d2,
integer d3 
)

Definition at line 69 of file median.c.

Referenced by decode_().

00070 {
00071     /* System generated locals */
00072     integer ret_val;
00073 
00074 /*       Arguments */
00075     ret_val = *d2;
00076     if (*d2 > *d1 && *d2 > *d3) {
00077    ret_val = *d1;
00078    if (*d3 > *d1) {
00079        ret_val = *d3;
00080    }
00081     } else if (*d2 < *d1 && *d2 < *d3) {
00082    ret_val = *d1;
00083    if (*d3 < *d1) {
00084        ret_val = *d3;
00085    }
00086     }
00087     return ret_val;
00088 } /* median_ */

int mload_ ( integer order,
integer awins,
integer awinf,
real speech,
real phi,
real psi 
)

Definition at line 99 of file mload.c.

Referenced by analys_().

00101 {
00102     /* System generated locals */
00103     integer phi_dim1, phi_offset, i__1, i__2;
00104 
00105     /* Local variables */
00106     integer c__, i__, r__, start;
00107 
00108 /*       Arguments */
00109 /*       Local variables that need not be saved */
00110 /*   Load first column of triangular covariance matrix PHI */
00111     /* Parameter adjustments */
00112     --psi;
00113     phi_dim1 = *order;
00114     phi_offset = phi_dim1 + 1;
00115     phi -= phi_offset;
00116     --speech;
00117 
00118     /* Function Body */
00119     start = *awins + *order;
00120     i__1 = *order;
00121     for (r__ = 1; r__ <= i__1; ++r__) {
00122    phi[r__ + phi_dim1] = 0.f;
00123    i__2 = *awinf;
00124    for (i__ = start; i__ <= i__2; ++i__) {
00125        phi[r__ + phi_dim1] += speech[i__ - 1] * speech[i__ - r__];
00126    }
00127     }
00128 /*   Load last element of vector PSI */
00129     psi[*order] = 0.f;
00130     i__1 = *awinf;
00131     for (i__ = start; i__ <= i__1; ++i__) {
00132    psi[*order] += speech[i__] * speech[i__ - *order];
00133     }
00134 /*   End correct to get additional columns of PHI */
00135     i__1 = *order;
00136     for (r__ = 2; r__ <= i__1; ++r__) {
00137    i__2 = r__;
00138    for (c__ = 2; c__ <= i__2; ++c__) {
00139        phi[r__ + c__ * phi_dim1] = phi[r__ - 1 + (c__ - 1) * phi_dim1] - 
00140           speech[*awinf + 1 - r__] * speech[*awinf + 1 - c__] + 
00141           speech[start - r__] * speech[start - c__];
00142    }
00143     }
00144 /*   End correct to get additional elements of PSI */
00145     i__1 = *order - 1;
00146     for (c__ = 1; c__ <= i__1; ++c__) {
00147    psi[c__] = phi[c__ + 1 + phi_dim1] - speech[start - 1] * speech[start 
00148       - 1 - c__] + speech[*awinf] * speech[*awinf - c__];
00149     }
00150 /*   Copy lower triangular section into upper (why bother?) */
00151 /*       I'm commenting this out, since the upper triangular half of PHI 
00152 */
00153 /*       is never used by later code, unless a sufficiently high level of 
00154 */
00155 /*       tracing is turned on. */
00156 /*    DO R = 1,ORDER */
00157 /*       DO C = 1,R-1 */
00158 /*          PHI(C,R) = PHI(R,C) */
00159 /*       END DO */
00160 /*    END DO */
00161     return 0;
00162 } /* mload_ */

int onset_ ( real pebuf,
integer osbuf,
integer osptr,
integer oslen,
integer sbufl,
integer sbufh,
integer lframe,
struct lpc10_encoder_state st 
)

Definition at line 129 of file onset.c.

References abs, c_b2, lpc10_encoder_state::d__, f, FALSE_, lpc10_encoder_state::fpc, lpc10_encoder_state::hyst, lpc10_encoder_state::l2buf, lpc10_encoder_state::l2ptr1, lpc10_encoder_state::l2ptr2, lpc10_encoder_state::l2sum1, lpc10_encoder_state::lasti, lpc10_encoder_state::n, r_sign(), and TRUE_.

Referenced by analys_().

00132 {
00133     /* Initialized data */
00134 
00135     real *n;
00136     real *d__;
00137     real *l2buf;
00138     real *l2sum1;
00139     integer *l2ptr1;
00140     integer *l2ptr2;
00141     logical *hyst;
00142 
00143     /* System generated locals */
00144     integer pebuf_offset, i__1;
00145     real r__1;
00146 
00147     /* Builtin functions */
00148     double r_sign(real *, real *);
00149 
00150     /* Local variables */
00151     integer i__;
00152     integer *lasti;
00153     real l2sum2;
00154     real *fpc;
00155 
00156 /*       Arguments */
00157 /* $Log$
00158  * Revision 1.15  2004/06/26 03:50:14  markster
00159  * Merge source cleanups (bug #1911)
00160  *
00161  * Revision 1.14  2003/02/12 13:59:15  matteo
00162  * mer feb 12 14:56:57 CET 2003
00163  *
00164  * Revision 1.1.1.1  2003/02/12 13:59:15  matteo
00165  * mer feb 12 14:56:57 CET 2003
00166  *
00167  * Revision 1.2  2000/01/05 08:20:39  markster
00168  * Some OSS fixes and a few lpc changes to make it actually work
00169  *
00170  * Revision 1.2  1996/08/20  20:37:55  jaf
00171  * Removed all static local variables that were SAVE'd in the Fortran
00172  * code, and put them in struct lpc10_encoder_state that is passed as an
00173  * argument.
00174  *
00175  * Removed init function, since all initialization is now done in
00176  * init_lpc10_encoder_state().
00177  *
00178  * Revision 1.1  1996/08/19  22:31:18  jaf
00179  * Initial revision
00180  * */
00181 /* Revision 1.3  1996/03/29  22:03:47  jaf */
00182 /* Removed definitions for any constants that were no longer used. */
00183 
00184 /* Revision 1.2  1996/03/26  19:34:33  jaf */
00185 /* Added comments indicating which constants are not needed in an */
00186 /* application that uses the LPC-10 coder. */
00187 
00188 /* Revision 1.1  1996/02/07  14:43:51  jaf */
00189 /* Initial revision */
00190 
00191 /*   LPC Configuration parameters: */
00192 /* Frame size, Prediction order, Pitch period */
00193 /*       Parameters/constants */
00194 /*   Parameters for onset detection algorithm: */
00195 /*    L2    Threshold for filtered slope of FPC (function of L2WID!) */
00196 /*    L2LAG Lag due to both filters which compute filtered slope of FPC */
00197 /*    L2WID Width of the filter which computes the slope of FPC */
00198 /*    OSHYST   The number of samples of slope(FPC) which must be below */
00199 /*            the threshold before a new onset may be declared. */
00200 /*       Local variables that need not be saved */
00201 /*       Local state */
00202 /*   Variables */
00203 /*    N, D       Numerator and denominator of prediction filters */
00204 /*    FPC        Current prediction coefs */
00205 /*    L2BUF, L2SUM1, L2SUM2    State of slope filter */
00206 /*       The only "significant" change I've made is to change L2SUM2 out 
00207 */
00208 /*       of the list of local variables that need to be saved, since it */
00209 /*       didn't need to be. */
00210 /*       L2SUM1 need not be, but avoiding saving it would require a small 
00211 */
00212 /*       change to the body of the code.  See comments below for an */
00213 /*       example of how the code could be changed to avoid saving L2SUM1. 
00214 */
00215 /*       FPC and LASTI are saved from one invocation to the next, but */
00216 /*       they are not given initial values.  This is acceptable, because 
00217 */
00218 /*       FPC will be assigned a value the first time that this function */
00219 /*       is called after D is initialized to 1, since the formula to */
00220 /*       change D will not change it to 0 in one step, and the IF (D */
00221 /*       .NE. 0) statement will execute its THEN part, initializing FPC. 
00222 */
00223 
00224 /*       LASTI's value will not be used until HYST is .TRUE., and */
00225 /*       whenever HYST is changed from its initial value of .FALSE., */
00226 /*       LASTI is assigned a value. */
00227 /*       In a C version of this coder, it would be nice if all of these */
00228 /*       saved things, in this and all other subroutines, could be stored 
00229 */
00230 /*       in a single struct lpc10_coder_state_t, initialized with a call 
00231 */
00232 /*       to a function like lpc10_init(&lpc10_coder_state).  In this way, 
00233 */
00234 /*       a program that used these functions could conveniently alternate 
00235 */
00236 /*       coding more than one distinct audio stream. */
00237 
00238     n = &(st->n);
00239     d__ = &(st->d__);
00240     fpc = &(st->fpc);
00241     l2buf = &(st->l2buf[0]);
00242     l2sum1 = &(st->l2sum1);
00243     l2ptr1 = &(st->l2ptr1);
00244     l2ptr2 = &(st->l2ptr2);
00245     lasti = &(st->lasti);
00246     hyst = &(st->hyst);
00247 
00248     /* Parameter adjustments */
00249     if (osbuf) {
00250    --osbuf;
00251    }
00252     if (pebuf) {
00253    pebuf_offset = *sbufl;
00254    pebuf -= pebuf_offset;
00255    }
00256 
00257     /* Function Body */
00258 
00259 /*       The following line subtracted a hard-coded "180" from LASTI, */
00260 /*       instead of using a variable like LFRAME or a constant like */
00261 /*       MAXFRM.  I changed it to LFRAME, for "generality". */
00262     if (*hyst) {
00263    *lasti -= *lframe;
00264     }
00265     i__1 = *sbufh;
00266     for (i__ = *sbufh - *lframe + 1; i__ <= i__1; ++i__) {
00267 /*   Compute FPC; Use old FPC on divide by zero; Clamp FPC to +/- 1. 
00268 */
00269    *n = (pebuf[i__] * pebuf[i__ - 1] + (*n) * 63.f) / 64.f;
00270 /* Computing 2nd power */
00271    r__1 = pebuf[i__ - 1];
00272    *d__ = (r__1 * r__1 + (*d__) * 63.f) / 64.f;
00273    if ((*d__) != 0.f) {
00274        if (abs(*n) > (*d__)) {
00275       *fpc = (real)r_sign(&c_b2, n);
00276        } else {
00277       *fpc = (*n) / (*d__);
00278        }
00279    }
00280 /*   Filter FPC */
00281 /*       In order to allow L2SUM1 not to be saved from one invocation 
00282 of */
00283 /*       this subroutine to the next, one could change the sequence of
00284  */
00285 /*       assignments below, up to the IF statement, to the following. 
00286  In */
00287 /*       addition, the initial value of L2PTR2 should be changed to */
00288 /*       L2WID/2 instead of L2WID/2+1. */
00289 
00290 /*       L2SUM1 = L2BUF(L2PTR2) */
00291 /*       L2PTR2 = MOD(L2PTR2,L2WID)+1 */
00292 /*       L2SUM1 = L2SUM1 - L2BUF(L2PTR2) + FPC */
00293 /*       L2BUF(L2PTR2) = L2SUM1 */
00294 
00295 /* *       The following lines didn't change from the original: */
00296 /*       L2SUM2 = L2BUF(L2PTR1) */
00297 /*       L2BUF(L2PTR1) = FPC */
00298 /*       L2PTR1 = MOD(L2PTR1,L2WID)+1 */
00299 
00300    l2sum2 = l2buf[*l2ptr1 - 1];
00301    *l2sum1 = *l2sum1 - l2buf[*l2ptr2 - 1] + *fpc;
00302    l2buf[*l2ptr2 - 1] = *l2sum1;
00303    l2buf[*l2ptr1 - 1] = *fpc;
00304    *l2ptr1 = *l2ptr1 % 16 + 1;
00305    *l2ptr2 = *l2ptr2 % 16 + 1;
00306    if ((r__1 = *l2sum1 - l2sum2, abs(r__1)) > 1.7f) {
00307        if (! (*hyst)) {
00308 /*   Ignore if buffer full */
00309       if (*osptr <= *oslen) {
00310           osbuf[*osptr] = i__ - 9;
00311           ++(*osptr);
00312       }
00313       *hyst = TRUE_;
00314        }
00315        *lasti = i__;
00316 /*       After one onset detection, at least OSHYST sample times m
00317 ust go */
00318 /*       by before another is allowed to occur. */
00319    } else if ((*hyst) && i__ - *lasti >= 10) {
00320        *hyst = FALSE_;
00321    }
00322     }
00323     return 0;
00324 } /* onset_ */

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 
)

Definition at line 132 of file pitsyn.c.

References f, FALSE_, first, lpc10_decoder_state::first_pitsyn, lpc10_decoder_state::ipito, lpc10_decoder_state::ivoico, lpc10_decoder_state::jsamp, lpc10_decoder_state::rco, lpc10_decoder_state::rmso, and TRUE_.

Referenced by synths_().

00136 {
00137     /* Initialized data */
00138 
00139     real *rmso;
00140     logical *first;
00141 
00142     /* System generated locals */
00143     integer rci_dim1 = 0, rci_offset, i__1, i__2;
00144     real r__1;
00145 
00146     /* Builtin functions */
00147     double log(doublereal), exp(doublereal);
00148 
00149     /* Local variables */
00150     real alrn, alro, yarc[10], prop;
00151     integer i__, j, vflag, jused, lsamp;
00152     integer *jsamp;
00153     real slope;
00154     integer *ipito;
00155     real uvpit;
00156     integer ip, nl, ivoice;
00157     integer *ivoico;
00158     integer istart;
00159     real *rco;
00160     real xxy;
00161 
00162 /*       Arguments */
00163 /* $Log$
00164  * Revision 1.16  2004/06/26 03:50:14  markster
00165  * Merge source cleanups (bug #1911)
00166  *
00167  * Revision 1.15  2003/11/23 22:14:32  markster
00168  * Various warning cleanups
00169  *
00170  * Revision 1.14  2003/02/12 13:59:15  matteo
00171  * mer feb 12 14:56:57 CET 2003
00172  *
00173  * Revision 1.1.1.1  2003/02/12 13:59:15  matteo
00174  * mer feb 12 14:56:57 CET 2003
00175  *
00176  * Revision 1.2  2000/01/05 08:20:39  markster
00177  * Some OSS fixes and a few lpc changes to make it actually work
00178  *
00179  * Revision 1.2  1996/08/20  20:40:12  jaf
00180  * Removed all static local variables that were SAVE'd in the Fortran
00181  * code, and put them in struct lpc10_decoder_state that is passed as an
00182  * argument.
00183  *
00184  * Removed init function, since all initialization is now done in
00185  * init_lpc10_decoder_state().
00186  *
00187  * Revision 1.1  1996/08/19  22:31:12  jaf
00188  * Initial revision
00189  * */
00190 /* Revision 1.3  1996/03/29  22:03:47  jaf */
00191 /* Removed definitions for any constants that were no longer used. */
00192 
00193 /* Revision 1.2  1996/03/26  19:34:33  jaf */
00194 /* Added comments indicating which constants are not needed in an */
00195 /* application that uses the LPC-10 coder. */
00196 
00197 /* Revision 1.1  1996/02/07  14:43:51  jaf */
00198 /* Initial revision */
00199 
00200 /*   LPC Configuration parameters: */
00201 /* Frame size, Prediction order, Pitch period */
00202 /*       Local variables that need not be saved */
00203 /*       LSAMP is initialized in the IF (FIRST) THEN clause, but it is */
00204 /*       not used the first time through, and it is given a value before 
00205 */
00206 /*       use whenever FIRST is .FALSE., so it appears unnecessary to */
00207 /*       assign it a value when FIRST is .TRUE. */
00208 /*       Local state */
00209 /* FIRST  - .TRUE. only on first call to PITSYN. */
00210 /* IVOICO - Previous VOICE(2) value. */
00211 /* IPITO  - Previous PITCH value. */
00212 /* RMSO   - Previous RMS value. */
00213 /* RCO    - Previous RC values. */
00214 
00215 /* JSAMP  - If this routine is called N times with identical values of */
00216 /*          LFRAME, then the total length of all pitch periods returned */
00217 /*          is always N*LFRAME-JSAMP, and JSAMP is always in the range 0 
00218 */
00219 /*          to MAXPIT-1 (see below for why this is so).  Thus JSAMP is */
00220 /*          the number of samples "left over" from the previous call to */
00221 /*          PITSYN, that haven't been "used" in a pitch period returned */
00222 /*          from this subroutine.  Every time this subroutine is called, 
00223 */
00224 /*          it returns pitch periods with a total length of at most */
00225 /*          LFRAME+JSAMP. */
00226 
00227 /* IVOICO, IPITO, RCO, and JSAMP need not be assigned an initial value */
00228 /* with a DATA statement, because they are always initialized on the */
00229 /* first call to PITSYN. */
00230 
00231 /* FIRST and RMSO should be initialized with DATA statements, because */
00232 /* even on the first call, they are used before being initialized. */
00233     /* Parameter adjustments */
00234     if (rc) {
00235    --rc;
00236    }
00237     if (rci) {
00238    rci_dim1 = *order;
00239    rci_offset = rci_dim1 + 1;
00240    rci -= rci_offset;
00241    }
00242     if (voice) {
00243    --voice;
00244    }
00245     if (ivuv) {
00246    --ivuv;
00247    }
00248     if (ipiti) {
00249    --ipiti;
00250    }
00251     if (rmsi) {
00252    --rmsi;
00253    }
00254 
00255     /* Function Body */
00256     ivoico = &(st->ivoico);
00257     ipito = &(st->ipito);
00258     rmso = &(st->rmso);
00259     rco = &(st->rco[0]);
00260     jsamp = &(st->jsamp);
00261     first = &(st->first_pitsyn);
00262 
00263     if (*rms < 1.f) {
00264    *rms = 1.f;
00265     }
00266     if (*rmso < 1.f) {
00267    *rmso = 1.f;
00268     }
00269     uvpit = 0.f;
00270     *ratio = *rms / (*rmso + 8.f);
00271     if (*first) {
00272    lsamp = 0;
00273    ivoice = voice[2];
00274    if (ivoice == 0) {
00275        *pitch = *lframe / 4;
00276    }
00277    *nout = *lframe / *pitch;
00278    *jsamp = *lframe - *nout * *pitch;
00279 
00280 /*          SYNTHS only calls this subroutine with PITCH in the range 
00281 20 */
00282 /*          to 156.  LFRAME = MAXFRM = 180, so NOUT is somewhere in th
00283 e */
00284 /*          range 1 to 9. */
00285 
00286 /*          JSAMP is "LFRAME mod PITCH", so it is in the range 0 to */
00287 /*          (PITCH-1), or 0 to MAXPIT-1=155, after the first call. */
00288 
00289    i__1 = *nout;
00290    for (i__ = 1; i__ <= i__1; ++i__) {
00291        i__2 = *order;
00292        for (j = 1; j <= i__2; ++j) {
00293       rci[j + i__ * rci_dim1] = rc[j];
00294        }
00295        ivuv[i__] = ivoice;
00296        ipiti[i__] = *pitch;
00297        rmsi[i__] = *rms;
00298    }
00299    *first = FALSE_;
00300     } else {
00301    vflag = 0;
00302    lsamp = *lframe + *jsamp;
00303    slope = (*pitch - *ipito) / (real) lsamp;
00304    *nout = 0;
00305    jused = 0;
00306    istart = 1;
00307    if (voice[1] == *ivoico && voice[2] == voice[1]) {
00308        if (voice[2] == 0) {
00309 /* SSUV - -   0  ,  0  ,  0 */
00310       *pitch = *lframe / 4;
00311       *ipito = *pitch;
00312       if (*ratio > 8.f) {
00313           *rmso = *rms;
00314       }
00315        }
00316 /* SSVC - -   1  ,  1  ,  1 */
00317        slope = (*pitch - *ipito) / (real) lsamp;
00318        ivoice = voice[2];
00319    } else {
00320        if (*ivoico != 1) {
00321       if (*ivoico == voice[1]) {
00322 /* UV2VC2 - -  0  ,  0  ,  1 */
00323           nl = lsamp - *lframe / 4;
00324       } else {
00325 /* UV2VC1 - -  0  ,  1  ,  1 */
00326           nl = lsamp - *lframe * 3 / 4;
00327       }
00328       ipiti[1] = nl / 2;
00329       ipiti[2] = nl - ipiti[1];
00330       ivuv[1] = 0;
00331       ivuv[2] = 0;
00332       rmsi[1] = *rmso;
00333       rmsi[2] = *rmso;
00334       i__1 = *order;
00335       for (i__ = 1; i__ <= i__1; ++i__) {
00336           rci[i__ + rci_dim1] = rco[i__ - 1];
00337           rci[i__ + (rci_dim1 << 1)] = rco[i__ - 1];
00338           rco[i__ - 1] = rc[i__];
00339       }
00340       slope = 0.f;
00341       *nout = 2;
00342       *ipito = *pitch;
00343       jused = nl;
00344       istart = nl + 1;
00345       ivoice = 1;
00346        } else {
00347       if (*ivoico != voice[1]) {
00348 /* VC2UV1 - -   1  ,  0  ,  0 */
00349           lsamp = *lframe / 4 + *jsamp;
00350       } else {
00351 /* VC2UV2 - -   1  ,  1  ,  0 */
00352           lsamp = *lframe * 3 / 4 + *jsamp;
00353       }
00354       i__1 = *order;
00355       for (i__ = 1; i__ <= i__1; ++i__) {
00356           yarc[i__ - 1] = rc[i__];
00357           rc[i__] = rco[i__ - 1];
00358       }
00359       ivoice = 1;
00360       slope = 0.f;
00361       vflag = 1;
00362        }
00363    }
00364 /* Here is the value of most variables that are used below, depending 
00365 on */
00366 /* the values of IVOICO, VOICE(1), and VOICE(2).  VOICE(1) and VOICE(2
00367 ) */
00368 /* are input arguments, and IVOICO is the value of VOICE(2) on the */
00369 /* previous call (see notes for the IF (NOUT .NE. 0) statement near th
00370 e */
00371 /* end).  Each of these three values is either 0 or 1.  These three */
00372 /* values below are given as 3-bit long strings, in the order IVOICO, 
00373 */
00374 /* VOICE(1), and VOICE(2).  It appears that the code above assumes tha
00375 t */
00376 /* the bit sequences 010 and 101 never occur, but I wonder whether a 
00377 */
00378 /* large enough number of bit errors in the channel could cause such a
00379  */
00380 /* thing to happen, and if so, could that cause NOUT to ever go over 1
00381 1? */
00382 
00383 /* Note that all of the 180 values in the table are really LFRAME, but
00384  */
00385 /* 180 has fewer characters, and it makes the table a little more */
00386 /* concrete.  If LFRAME is ever changed, keep this in mind.  Similarly
00387 , */
00388 /* 135's are 3*LFRAME/4, and 45's are LFRAME/4.  If LFRAME is not a */
00389 /* multiple of 4, then the 135 for NL-JSAMP is actually LFRAME-LFRAME/
00390 4, */
00391 /* and the 45 for NL-JSAMP is actually LFRAME-3*LFRAME/4. */
00392 
00393 /* Note that LSAMP-JSAMP is given as the variable.  This was just for 
00394 */
00395 /* brevity, to avoid adding "+JSAMP" to all of the column entries. */
00396 /* Similarly for NL-JSAMP. */
00397 
00398 /* Variable    | 000  001    011,010  111       110       100,101 */
00399 /* ------------+-------------------------------------------------- */
00400 /* ISTART      | 1    NL+1   NL+1     1         1         1 */
00401 /* LSAMP-JSAMP | 180  180    180      180       135       45 */
00402 /* IPITO       | 45   PITCH  PITCH    oldPITCH  oldPITCH  oldPITCH */
00403 /* SLOPE       | 0    0      0        seebelow  0         0 */
00404 /* JUSED       | 0    NL     NL       0         0         0 */
00405 /* PITCH       | 45   PITCH  PITCH    PITCH     PITCH     PITCH */
00406 /* NL-JSAMP    | --   135    45       --        --        -- */
00407 /* VFLAG       | 0    0      0        0         1         1 */
00408 /* NOUT        | 0    2      2        0         0         0 */
00409 /* IVOICE      | 0    1      1        1         1         1 */
00410 
00411 /* while_loop  | once once   once     once      twice     twice */
00412 
00413 /* ISTART      | --   --     --       --        JUSED+1   JUSED+1 */
00414 /* LSAMP-JSAMP | --   --     --       --        180       180 */
00415 /* IPITO       | --   --     --       --        oldPITCH  oldPITCH */
00416 /* SLOPE       | --   --     --       --        0         0 */
00417 /* JUSED       | --   --     --       --        ??        ?? */
00418 /* PITCH       | --   --     --       --        PITCH     PITCH */
00419 /* NL-JSAMP    | --   --     --       --        --        -- */
00420 /* VFLAG       | --   --     --       --        0         0 */
00421 /* NOUT        | --   --     --       --        ??        ?? */
00422 /* IVOICE      | --   --     --       --        0         0 */
00423 
00424 
00425 /* UVPIT is always 0.0 on the first pass through the DO WHILE (.TRUE.)
00426  */
00427 /* loop below. */
00428 
00429 /* The only possible non-0 value of SLOPE (in column 111) is */
00430 /* (PITCH-IPITO)/FLOAT(LSAMP) */
00431 
00432 /* Column 101 is identical to 100.  Any good properties we can prove 
00433 */
00434 /* for 100 will also hold for 101.  Similarly for 010 and 011. */
00435 
00436 /* SYNTHS calls this subroutine with PITCH restricted to the range 20 
00437 to */
00438 /* 156.  IPITO is similarly restricted to this range, after the first 
00439 */
00440 /* call.  IP below is also restricted to this range, given the */
00441 /* definitions of IPITO, SLOPE, UVPIT, and that I is in the range ISTA
00442 RT */
00443 /* to LSAMP. */
00444 
00445    while(TRUE_) {
00446 
00447 /*             JUSED is the total length of all pitch periods curr
00448 ently */
00449 /*             in the output arrays, in samples. */
00450 
00451 /*             An invariant of the DO I = ISTART,LSAMP loop below,
00452  under */
00453 /*             the condition that IP is always in the range 1 thro
00454 ugh */
00455 /*             MAXPIT, is: */
00456 
00457 /*             (I - MAXPIT) .LE. JUSED .LE. (I-1) */
00458 
00459 /*             Note that the final value of I is LSAMP+1, so that 
00460 after */
00461 /*             the DO loop is complete, we know: */
00462 
00463 /*             (LSAMP - MAXPIT + 1) .LE. JUSED .LE. LSAMP */
00464 
00465        i__1 = lsamp;
00466        for (i__ = istart; i__ <= i__1; ++i__) {
00467       r__1 = *ipito + slope * i__;
00468       ip = (integer)(r__1 + .5f);
00469       if (uvpit != 0.f) {
00470           ip = (integer)uvpit;
00471       }
00472       if (ip <= i__ - jused) {
00473           ++(*nout);
00474 
00475 /*                   The following check is no longer nece
00476 ssary, now that */
00477 /*                   we can prove that NOUT will never go 
00478 over 16. */
00479 
00480 /*           IF (NOUT .GT. 16) STOP 'PITSYN: too many epochs' 
00481 */
00482 
00483           ipiti[*nout] = ip;
00484           *pitch = ip;
00485           ivuv[*nout] = ivoice;
00486           jused += ip;
00487           prop = (jused - ip / 2) / (real) lsamp;
00488           i__2 = *order;
00489           for (j = 1; j <= i__2; ++j) {
00490          alro = (real)log((rco[j - 1] + 1) / (1 - rco[j - 1]));
00491          alrn = (real)log((rc[j] + 1) / (1 - rc[j]));
00492          xxy = alro + prop * (alrn - alro);
00493          xxy = (real)exp(xxy);
00494          rci[j + *nout * rci_dim1] = (xxy - 1) / (xxy + 1);
00495           }
00496           rmsi[*nout] = (real)(log(*rmso) + prop * (log(*rms) - log(*rmso)));
00497           rmsi[*nout] = (real)exp(rmsi[*nout]);
00498       }
00499        }
00500        if (vflag != 1) {
00501       goto L100;
00502        }
00503 
00504 /*             I want to prove what range UVPIT must lie in after 
00505 the */
00506 /*             assignments to it below.  To do this, I must determ
00507 ine */
00508 /*             what range (LSAMP-ISTART) must lie in, after the */
00509 /*             assignments to ISTART and LSAMP below. */
00510 
00511 /*             Let oldLSAMP be the value of LSAMP at this point in
00512  the */
00513 /*             execution.  This is 135+JSAMP in state 110, or 45+J
00514 SAMP in */
00515 /*             states 100 or 101. */
00516 
00517 /*             Given the loop invariant on JUSED above, we know th
00518 at: */
00519 
00520 /*             (oldLSAMP - MAXPIT + 1) .LE. JUSED .LE. oldLSAMP */
00521 
00522 /*             ISTART is one more than this. */
00523 
00524 /*             Let newLSAMP be the value assigned to LSAMP below. 
00525  This */
00526 /*             is 180+JSAMP.  Thus (newLSAMP-oldLSAMP) is either 4
00527 5 or */
00528 /*             135, depending on the state. */
00529 
00530 /*             Thus, the range of newLSAMP-ISTART is: */
00531 
00532 /*             (newLSAMP-(oldLSAMP+1)) .LE. newLSAMP-ISTART */
00533 /*             .LE. (newLSAMP-(oldLSAMP - MAXPIT + 2)) */
00534 
00535 /*             or: */
00536 
00537 /*             46 .LE. newLSAMP-ISTART .LE. 133+MAXPIT .EQ. 289 */
00538 
00539 /*             Therefore, UVPIT is in the range 23 to 144 after th
00540 e first */
00541 /*             assignment to UVPIT below, and after the conditiona
00542 l */
00543 /*             assignment, it is in the range 23 to 90. */
00544 
00545 /*             The important thing is that it is in the range 20 t
00546 o 156, */
00547 /*             so that in the loop above, IP is always in this ran
00548 ge. */
00549 
00550        vflag = 0;
00551        istart = jused + 1;
00552        lsamp = *lframe + *jsamp;
00553        slope = 0.f;
00554        ivoice = 0;
00555        uvpit = (real) ((lsamp - istart) / 2);
00556        if (uvpit > 90.f) {
00557       uvpit /= 2;
00558        }
00559        *rmso = *rms;
00560        i__1 = *order;
00561        for (i__ = 1; i__ <= i__1; ++i__) {
00562       rc[i__] = yarc[i__ - 1];
00563       rco[i__ - 1] = yarc[i__ - 1];
00564        }
00565    }
00566 L100:
00567    *jsamp = lsamp - jused;
00568     }
00569 /*       Given that the maximum pitch period MAXPIT .LT. LFRAME (this is 
00570 */
00571 /*       currently true on every call, since SYNTHS always sets */
00572 /*       LFRAME=180), NOUT will always be .GE. 1 at this point. */
00573     if (*nout != 0) {
00574    *ivoico = voice[2];
00575    *ipito = *pitch;
00576    *rmso = *rms;
00577    i__1 = *order;
00578    for (i__ = 1; i__ <= i__1; ++i__) {
00579        rco[i__ - 1] = rc[i__];
00580    }
00581     }
00582     return 0;
00583 } /* pitsyn_ */

int placea_ ( integer ipitch,
integer voibuf,
integer obound,
integer af,
integer vwin,
integer awin,
integer ewin,
integer lframe,
integer maxwin 
)

Definition at line 116 of file placea.c.

References FALSE_, i_nint(), and TRUE_.

Referenced by analys_().

00119 {
00120     /* System generated locals */
00121     real r__1;
00122 
00123     /* Builtin functions */
00124     integer i_nint(real *);
00125 
00126     /* Local variables */
00127     logical allv, winv;
00128     integer i__, j, k, l, hrange;
00129     logical ephase;
00130     integer lrange;
00131 
00132 /*       Arguments */
00133 /*       Local variables that need not be saved */
00134     /* Parameter adjustments */
00135     ewin -= 3;
00136     awin -= 3;
00137     vwin -= 3;
00138     --voibuf;
00139 
00140     /* Function Body */
00141     lrange = (*af - 2) * *lframe + 1;
00142     hrange = *af * *lframe;
00143 /*   Place the Analysis window based on the voicing window */
00144 /*   placement, onsets, tentative voicing decision, and pitch. */
00145 
00146 /*   Case 1:  Sustained Voiced Speech */
00147 /*   If the five most recent voicing decisions are */
00148 /*   voiced, then the window is placed phase-synchronously with the */
00149 /*   previous window, as close to the present voicing window if possible. 
00150 */
00151 /*   If onsets bound the voicing window, then preference is given to */
00152 /*   a phase-synchronous placement which does not overlap these onsets. */
00153 
00154 /*   Case 2:  Voiced Transition */
00155 /*   If at least one voicing decision in AF is voicied, and there are no 
00156 */
00157 /*   onsets, then the window is placed as in case 1. */
00158 
00159 /*   Case 3:  Unvoiced Speech or Onsets */
00160 /*   If both voicing decisions in AF are unvoiced, or there are onsets, */
00161 /*   then the window is placed coincident with the voicing window. */
00162 
00163 /*   Note:  During phase-synchronous placement of windows, the length */
00164 /*   is not altered from MAXWIN, since this would defeat the purpose */
00165 /*   of phase-synchronous placement. */
00166 /* Check for case 1 and case 2 */
00167     allv = voibuf[((*af - 2) << 1) + 2] == 1;
00168     allv = allv && voibuf[((*af - 1) << 1) + 1] == 1;
00169     allv = allv && voibuf[((*af - 1) << 1) + 2] == 1;
00170     allv = allv && voibuf[(*af << 1) + 1] == 1;
00171     allv = allv && voibuf[(*af << 1) + 2] == 1;
00172     winv = voibuf[(*af << 1) + 1] == 1 || voibuf[(*af << 1) + 2] == 1;
00173     if (allv || (winv && *obound == 0)) {
00174 /* APHASE:  Phase synchronous window placement. */
00175 /* Get minimum lower index of the window. */
00176    i__ = (lrange + *ipitch - 1 - awin[((*af - 1) << 1) + 1]) / *ipitch;
00177    i__ *= *ipitch;
00178    i__ += awin[((*af - 1) << 1) + 1];
00179 /* L = the actual length of this frame's analysis window. */
00180    l = *maxwin;
00181 /* Calculate the location where a perfectly centered window would star
00182 t. */
00183    k = (vwin[(*af << 1) + 1] + vwin[(*af << 1) + 2] + 1 - l) / 2;
00184 /* Choose the actual location to be the pitch multiple closest to this
00185 . */
00186    r__1 = (real) (k - i__) / *ipitch;
00187    awin[(*af << 1) + 1] = i__ + i_nint(&r__1) * *ipitch;
00188    awin[(*af << 1) + 2] = awin[(*af << 1) + 1] + l - 1;
00189 /* If there is an onset bounding the right of the voicing window and t
00190 he */
00191 /* analysis window overlaps that, then move the analysis window backwa
00192 rd */
00193 /* to avoid this onset. */
00194    if (*obound >= 2 && awin[(*af << 1) + 2] > vwin[(*af << 1) + 2]) {
00195        awin[(*af << 1) + 1] -= *ipitch;
00196        awin[(*af << 1) + 2] -= *ipitch;
00197    }
00198 /* Similarly for the left of the voicing window. */
00199    if ((*obound == 1 || *obound == 3) && awin[(*af << 1) + 1] < vwin[(*
00200       af << 1) + 1]) {
00201        awin[(*af << 1) + 1] += *ipitch;
00202        awin[(*af << 1) + 2] += *ipitch;
00203    }
00204 /* If this placement puts the analysis window above HRANGE, then */
00205 /* move it backward an integer number of pitch periods. */
00206    while(awin[(*af << 1) + 2] > hrange) {
00207        awin[(*af << 1) + 1] -= *ipitch;
00208        awin[(*af << 1) + 2] -= *ipitch;
00209    }
00210 /* Similarly if the placement puts the analysis window below LRANGE. 
00211 */
00212    while(awin[(*af << 1) + 1] < lrange) {
00213        awin[(*af << 1) + 1] += *ipitch;
00214        awin[(*af << 1) + 2] += *ipitch;
00215    }
00216 /* Make Energy window be phase-synchronous. */
00217    ephase = TRUE_;
00218 /* Case 3 */
00219     } else {
00220    awin[(*af << 1) + 1] = vwin[(*af << 1) + 1];
00221    awin[(*af << 1) + 2] = vwin[(*af << 1) + 2];
00222    ephase = FALSE_;
00223     }
00224 /* RMS is computed over an integer number of pitch periods in the analysis
00225  */
00226 /*window.  When it is not placed phase-synchronously, it is placed as clos
00227 e*/
00228 /* as possible to onsets. */
00229     j = (awin[(*af << 1) + 2] - awin[(*af << 1) + 1] + 1) / *ipitch * *ipitch;
00230     if (j == 0 || ! winv) {
00231    ewin[(*af << 1) + 1] = vwin[(*af << 1) + 1];
00232    ewin[(*af << 1) + 2] = vwin[(*af << 1) + 2];
00233     } else if (! ephase && *obound == 2) {
00234    ewin[(*af << 1) + 1] = awin[(*af << 1) + 2] - j + 1;
00235    ewin[(*af << 1) + 2] = awin[(*af << 1) + 2];
00236     } else {
00237    ewin[(*af << 1) + 1] = awin[(*af << 1) + 1];
00238    ewin[(*af << 1) + 2] = awin[(*af << 1) + 1] + j - 1;
00239     }
00240     return 0;
00241 } /* placea_ */

int placev_ ( integer osbuf,
integer osptr,
integer oslen,
integer obound,
integer vwin,
integer af,
integer lframe,
integer minwin,
integer maxwin,
integer dvwinl,
integer dvwinh 
)

Definition at line 112 of file placev.c.

References FALSE_, max, min, and TRUE_.

Referenced by analys_().

00115 {
00116     /* System generated locals */
00117     integer i__1, i__2;
00118 
00119     /* Local variables */
00120     logical crit;
00121     integer i__, q, osptr1, hrange, lrange;
00122 
00123 /*       Arguments */
00124 /*       Local variables that need not be saved */
00125 /*   Variables */
00126 /*    LRANGE, HRANGE  Range in which window is placed */
00127 /*    OSPTR1     OSPTR excluding samples in 3F */
00128 /*       Local state */
00129 /*       None */
00130 /*   Voicing Window Placement */
00131 
00132 /*         __________________ __________________ ______________ */
00133 /*        |                  |                  | */
00134 /*        |        1F        |        2F        |        3F ... */
00135 /*        |__________________|__________________|______________ */
00136 
00137 /*    Previous | */
00138 /*      Window | */
00139 /*  ...________| */
00140 
00141 /*             |                                | */
00142 /*      ------>| This window's placement range  |<------ */
00143 /*             |                                | */
00144 
00145 /*   There are three cases.  Note that these are different from those */
00146 /*   given in the LPC-10e phase 1 report. */
00147 
00148 /*   1.  If there are no onsets in this range, then the voicing window */
00149 /*   is centered in the pitch window.  If such a placement is not within 
00150 */
00151 /*   the window's placement range, then the window is placed in the left- 
00152 */
00153 /*   most portion of the placement range.  Its length is always MAXWIN. */
00154 
00155 /*   2.  If the first onset is in 2F and there is sufficient room to place
00156  */
00157 /*   the window immediately before this onset, then the window is placed 
00158 */
00159 /*   there, and its length is set to the maximum possible under these */
00160 /*   constraints. */
00161 
00162 /*    "Critical Region Exception":  If there is another onset in 2F */
00163 /*    such that a window can be placed between the two onsets, the */
00164 /*    window is placed there (ie, as in case 3). */
00165 
00166 /*   3.  Otherwise, the window is placed immediately after the onset.  The
00167  */
00168 /*   window's length */
00169 /*  is the longest length that can fit in the range under these constraint
00170 s,*/
00171 /*  except that the window may be shortened even further to avoid overlapp
00172 ing*/
00173 /*  other onsets in the placement range.  In any case, the window's length
00174 */
00175 /*   is at least MINWIN. */
00176 
00177 /*   Note that the values of MINWIN and LFRAME must be chosen such */
00178 /*   that case 2 = false implies case 3 = true.   This means that */
00179 /*   MINWIN <= LFRAME/2.  If this were not the case, then a fourth case */
00180 /*   would have to be added for when the window cannot fit either before 
00181 */
00182 /*   or after the onset. */
00183 
00184 /*   Note also that onsets which weren't in 2F last time may be in 1F this
00185  */
00186 /*  time, due to the filter delays in computing onsets.  The result is tha
00187 t*/
00188 /*   occasionally a voicing window will overlap that onset.  The only way 
00189 */
00190 /*   to circumvent this problem is to add more delay in processing input 
00191 */
00192 /*   speech.  In the trade-off between delay and window-placement, window 
00193 */
00194 /*   placement lost. */
00195 /* Compute the placement range */
00196     /* Parameter adjustments */
00197     --osbuf;
00198     vwin -= 3;
00199 
00200     /* Function Body */
00201 /* Computing MAX */
00202     i__1 = vwin[((*af - 1) << 1) + 2] + 1, i__2 = (*af - 2) * *lframe + 1;
00203     lrange = max(i__1,i__2);
00204     hrange = *af * *lframe;
00205 /* Compute OSPTR1, so the following code only looks at relevant onsets. */
00206     for (osptr1 = *osptr - 1; osptr1 >= 1; --osptr1) {
00207    if (osbuf[osptr1] <= hrange) {
00208        goto L90;
00209    }
00210     }
00211 L90:
00212     ++osptr1;
00213 /* Check for case 1 first (fast case): */
00214     if (osptr1 <= 1 || osbuf[osptr1 - 1] < lrange) {
00215 /* Computing MAX */
00216    i__1 = vwin[((*af - 1) << 1) + 2] + 1;
00217    vwin[(*af << 1) + 1] = max(i__1,*dvwinl);
00218    vwin[(*af << 1) + 2] = vwin[(*af << 1) + 1] + *maxwin - 1;
00219    *obound = 0;
00220     } else {
00221 /* Search backward in OSBUF for first onset in range. */
00222 /* This code relies on the above check being performed first. */
00223    for (q = osptr1 - 1; q >= 1; --q) {
00224        if (osbuf[q] < lrange) {
00225       goto L100;
00226        }
00227    }
00228 L100:
00229    ++q;
00230 /* Check for case 2 (placement before onset): */
00231 /* Check for critical region exception: */
00232    i__1 = osptr1 - 1;
00233    for (i__ = q + 1; i__ <= i__1; ++i__) {
00234        if (osbuf[i__] - osbuf[q] >= *minwin) {
00235       crit = TRUE_;
00236       goto L105;
00237        }
00238    }
00239    crit = FALSE_;
00240 L105:
00241 /* Computing MAX */
00242    i__1 = (*af - 1) * *lframe, i__2 = lrange + *minwin - 1;
00243    if (! crit && osbuf[q] > max(i__1,i__2)) {
00244        vwin[(*af << 1) + 2] = osbuf[q] - 1;
00245 /* Computing MAX */
00246        i__1 = lrange, i__2 = vwin[(*af << 1) + 2] - *maxwin + 1;
00247        vwin[(*af << 1) + 1] = max(i__1,i__2);
00248        *obound = 2;
00249 /* Case 3 (placement after onset) */
00250    } else {
00251        vwin[(*af << 1) + 1] = osbuf[q];
00252 L110:
00253        ++q;
00254        if (q >= osptr1) {
00255       goto L120;
00256        }
00257        if (osbuf[q] > vwin[(*af << 1) + 1] + *maxwin) {
00258       goto L120;
00259        }
00260        if (osbuf[q] < vwin[(*af << 1) + 1] + *minwin) {
00261       goto L110;
00262        }
00263        vwin[(*af << 1) + 2] = osbuf[q] - 1;
00264        *obound = 3;
00265        return 0;
00266 L120:
00267 /* Computing MIN */
00268        i__1 = vwin[(*af << 1) + 1] + *maxwin - 1;
00269        vwin[(*af << 1) + 2] = min(i__1,hrange);
00270        *obound = 1;
00271    }
00272     }
00273     return 0;
00274 } /* placev_ */

integer pow_ii ( integer ap,
integer bp 
)

Definition at line 30 of file f2clib.c.

Referenced by decode_(), and encode_().

00032 {
00033    integer pow, x, n;
00034    unsigned long u;
00035 
00036    x = *ap;
00037    n = *bp;
00038 
00039    if (n <= 0) {
00040       if (n == 0 || x == 1)
00041          return 1;
00042       if (x != -1)
00043          return x == 0 ? 0 : 1/x;
00044       n = -n;
00045       }
00046    u = n;
00047    for(pow = 1; ; )
00048       {
00049       if(u & 01)
00050          pow *= x;
00051       if(u >>= 1)
00052          x *= x;
00053       else
00054          break;
00055       }
00056    return(pow);
00057    }

int preemp_ ( real inbuf,
real pebuf,
integer nsamp,
real coef,
real z__ 
)

Definition at line 82 of file preemp.c.

Referenced by analys_().

00084 {
00085     /* System generated locals */
00086     integer i__1;
00087 
00088     /* Local variables */
00089     real temp;
00090     integer i__;
00091 
00092 /*       Arguments */
00093 /*       Local variables */
00094 
00095 /*       None of these need to have their values saved from one */
00096 /*       invocation to the next. */
00097 
00098 /*       Logically, this subroutine computes the output sequence */
00099 /*       pebuf(1:nsamp) defined by: */
00100 
00101 /*       pebuf(i) = inbuf(i) - coef * inbuf(i-1) */
00102 
00103 /*       where inbuf(0) is defined by the value of z given as input to */
00104 /*       this subroutine. */
00105 
00106 /*       What is this filter's frequency response and phase response? */
00107 
00108 /*       Why is this filter applied to the speech? */
00109 
00110 /*       Could it be more efficient to apply multiple filters */
00111 /*       simultaneously, by combining them into one equivalent filter? */
00112 
00113 /*       Are there ever cases when "factoring" one high-order filter into 
00114 */
00115 /*       multiple smaller-order filter actually reduces the number of */
00116 /*       arithmetic operations needed to perform them? */
00117 /*       When I first read this subroutine, I didn't understand why the */
00118 /*       variable temp was used.  It seemed that the statements in the do 
00119 */
00120 /*       loop could be replaced with the following: */
00121 
00122 /*           pebuf(i) = inbuf(i) - coef * z */
00123 /*           z = inbuf(i) */
00124 
00125 /*       The reason for temp is so that even if pebuf and inbuf are the */
00126 /*       same arrays in memory (i.e., they are aliased), then this */
00127 /*       subroutine will still work correctly.  I didn't realize this */
00128 /*       until seeing the comment after PEBUF above that says "(can be */
00129 /*       equal to INBUF)". */
00130     /* Parameter adjustments */
00131     --pebuf;
00132     --inbuf;
00133 
00134     /* Function Body */
00135     i__1 = *nsamp;
00136     for (i__ = 1; i__ <= i__1; ++i__) {
00137    temp = inbuf[i__] - *coef * *z__;
00138    *z__ = inbuf[i__];
00139    pebuf[i__] = temp;
00140 /* L10: */
00141     }
00142     return 0;
00143 } /* preemp_ */

int prepro_ ( real speech,
integer length,
struct lpc10_encoder_state st 
)

Definition at line 101 of file prepro.c.

References c__1, and hp100_().

Referenced by lpc10_encode().

00103 {
00104     extern /* Subroutine */ int hp100_(real *, integer *, integer *, struct lpc10_encoder_state *);
00105 
00106 /*       Arguments */
00107 /*   High Pass Filter at 100 Hz */
00108     /* Parameter adjustments */
00109     if (speech) {
00110    --speech;
00111    }
00112 
00113     /* Function Body */
00114     hp100_(&speech[1], &c__1, length, st);
00115     return 0;
00116 } /* prepro_ */

double r_sign ( real a,
real b 
)

Definition at line 64 of file f2clib.c.

Referenced by onset_(), and vparms_().

00066 {
00067 double x;
00068 x = (*a >= 0 ? *a : - *a);
00069 return( *b >= 0 ? x : -x);
00070 }

integer random_ ( struct lpc10_decoder_state st  ) 

Definition at line 93 of file random.c.

References lpc10_decoder_state::j, lpc10_decoder_state::k, and lpc10_decoder_state::y.

Referenced by bsynz_().

00094 {
00095     /* Initialized data */
00096 
00097     integer *j;
00098     integer *k;
00099     shortint *y;
00100 
00101     /* System generated locals */
00102     integer ret_val;
00103 
00104 /*    Parameters/constants */
00105 /*       Local state */
00106 /*   The following is a 16 bit 2's complement addition, */
00107 /*   with overflow checking disabled */
00108 
00109     j = &(st->j);
00110     k = &(st->k);
00111     y = &(st->y[0]);
00112 
00113     y[*k - 1] += y[*j - 1];
00114     ret_val = y[*k - 1];
00115     --(*k);
00116     if (*k <= 0) {
00117    *k = 5;
00118     }
00119     --(*j);
00120     if (*j <= 0) {
00121    *j = 5;
00122     }
00123     return ret_val;
00124 } /* random_ */

int rcchk_ ( integer order,
real rc1f,
real rc2f 
)

Definition at line 82 of file rcchk.c.

References abs, and f.

Referenced by analys_().

00083 {
00084     /* System generated locals */
00085     integer i__1;
00086     real r__1;
00087 
00088     /* Local variables */
00089     integer i__;
00090 
00091 /*       Arguments */
00092 /*       Local variables that need not be saved */
00093     /* Parameter adjustments */
00094     --rc2f;
00095     --rc1f;
00096 
00097     /* Function Body */
00098     i__1 = *order;
00099     for (i__ = 1; i__ <= i__1; ++i__) {
00100    if ((r__1 = rc2f[i__], abs(r__1)) > .99f) {
00101        goto L10;
00102    }
00103     }
00104     return 0;
00105 /*       Note: In version embedded in other software, all calls to ERROR 
00106 */
00107 /*       should probably be removed. */
00108 L10:
00109 
00110 /*       This call to ERROR is only needed for debugging purposes. */
00111 
00112 /*       CALL ERROR('RCCHK',2,I) */
00113     i__1 = *order;
00114     for (i__ = 1; i__ <= i__1; ++i__) {
00115    rc2f[i__] = rc1f[i__];
00116     }
00117     return 0;
00118 } /* rcchk_ */

int synths_ ( integer voice,
integer pitch,
real rms,
real rc,
real speech,
integer k,
struct lpc10_decoder_state st 
)

Definition at line 170 of file synths.c.

References bsynz_(), lpc10_decoder_state::buf, buf, lpc10_decoder_state::buflen, c_b2, contrl_1, deemp_(), f, irc2pc_(), max, min, and pitsyn_().

Referenced by lpc10_decode().

00172 {
00173     /* Initialized data */
00174 
00175     real *buf;
00176     integer *buflen;
00177 
00178     /* System generated locals */
00179     integer i__1;
00180     real r__1, r__2;
00181 
00182     /* Local variables */
00183     real rmsi[16];
00184     integer nout, ivuv[16], i__, j;
00185     extern /* Subroutine */ int deemp_(real *, integer *, struct lpc10_decoder_state *);
00186     real ratio;
00187     integer ipiti[16];
00188     real g2pass;
00189     real pc[10];
00190     extern /* Subroutine */ int pitsyn_(integer *, integer *, integer *, real 
00191        *, real *, integer *, integer *, integer *, real *, real *, 
00192        integer *, real *, struct lpc10_decoder_state *);
00193     real rci[160] /* was [10][16] */;
00194 
00195 /* $Log$
00196  * Revision 1.16  2004/06/26 03:50:14  markster
00197  * Merge source cleanups (bug #1911)
00198  *
00199  * Revision 1.15  2003/09/27 02:45:37  markster
00200  * Fix various compiler warnings (bug #322)
00201  *
00202  * Revision 1.2  2003/09/27 02:45:37  markster
00203  * Fix various compiler warnings (bug #322)
00204  *
00205  * Revision 1.1.1.1  2003/02/12 13:59:15  matteo
00206  * mer feb 12 14:56:57 CET 2003
00207  *
00208  * Revision 1.2  2000/01/05 08:20:39  markster
00209  * Some OSS fixes and a few lpc changes to make it actually work
00210  *
00211  * Revision 1.2  1996/08/20  20:42:59  jaf
00212  * Removed all static local variables that were SAVE'd in the Fortran
00213  * code, and put them in struct lpc10_decoder_state that is passed as an
00214  * argument.
00215  *
00216  * Removed init function, since all initialization is now done in
00217  * init_lpc10_decoder_state().
00218  *
00219  * Revision 1.1  1996/08/19  22:30:33  jaf
00220  * Initial revision
00221  * */
00222 /* Revision 1.3  1996/03/29  22:03:47  jaf */
00223 /* Removed definitions for any constants that were no longer used. */
00224 
00225 /* Revision 1.2  1996/03/26  19:34:33  jaf */
00226 /* Added comments indicating which constants are not needed in an */
00227 /* application that uses the LPC-10 coder. */
00228 
00229 /* Revision 1.1  1996/02/07  14:43:51  jaf */
00230 /* Initial revision */
00231 
00232 /*   LPC Configuration parameters: */
00233 /* Frame size, Prediction order, Pitch period */
00234 /*       Arguments */
00235 /* $Log$
00236  * Revision 1.16  2004/06/26 03:50:14  markster
00237  * Merge source cleanups (bug #1911)
00238  *
00239  * Revision 1.15  2003/09/27 02:45:37  markster
00240  * Fix various compiler warnings (bug #322)
00241  *
00242  * Revision 1.2  2003/09/27 02:45:37  markster
00243  * Fix various compiler warnings (bug #322)
00244  *
00245  * Revision 1.1.1.1  2003/02/12 13:59:15  matteo
00246  * mer feb 12 14:56:57 CET 2003
00247  *
00248  * Revision 1.2  2000/01/05 08:20:39  markster
00249  * Some OSS fixes and a few lpc changes to make it actually work
00250  *
00251  * Revision 1.2  1996/08/20  20:42:59  jaf
00252  * Removed all static local variables that were SAVE'd in the Fortran
00253  * code, and put them in struct lpc10_decoder_state that is passed as an
00254  * argument.
00255  *
00256  * Removed init function, since all initialization is now done in
00257  * init_lpc10_decoder_state().
00258  *
00259  * Revision 1.1  1996/08/19  22:30:33  jaf
00260  * Initial revision
00261  * */
00262 /* Revision 1.3  1996/03/29  22:05:55  jaf */
00263 /* Commented out the common block variables that are not needed by the */
00264 /* embedded version. */
00265 
00266 /* Revision 1.2  1996/03/26  19:34:50  jaf */
00267 /* Added comments indicating which constants are not needed in an */
00268 /* application that uses the LPC-10 coder. */
00269 
00270 /* Revision 1.1  1996/02/07  14:44:09  jaf */
00271 /* Initial revision */
00272 
00273 /*   LPC Processing control variables: */
00274 
00275 /* *** Read-only: initialized in setup */
00276 
00277 /*  Files for Speech, Parameter, and Bitstream Input & Output, */
00278 /*    and message and debug outputs. */
00279 
00280 /* Here are the only files which use these variables: */
00281 
00282 /* lpcsim.f setup.f trans.f error.f vqsetup.f */
00283 
00284 /* Many files which use fdebug are not listed, since it is only used in */
00285 /* those other files conditionally, to print trace statements. */
00286 /*    integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
00287 /*  LPC order, Frame size, Quantization rate, Bits per frame, */
00288 /*    Error correction */
00289 /* Subroutine SETUP is the only place where order is assigned a value, */
00290 /* and that value is 10.  It could increase efficiency 1% or so to */
00291 /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as 
00292 */
00293 /* a variable in a COMMON block, since it is used in many places in the */
00294 /* core of the coding and decoding routines.  Actually, I take that back. 
00295 */
00296 /* At least when compiling with f2c, the upper bound of DO loops is */
00297 /* stored in a local variable before the DO loop begins, and then that is 
00298 */
00299 /* compared against on each iteration. */
00300 /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */
00301 /* Similarly for quant, which is given a value of 2400 in SETUP.  quant */
00302 /* is used in only a few places, and never in the core coding and */
00303 /* decoding routines, so it could be eliminated entirely. */
00304 /* nbits is similar to quant, and is given a value of 54 in SETUP. */
00305 /* corrp is given a value of .TRUE. in SETUP, and is only used in the */
00306 /* subroutines ENCODE and DECODE.  It doesn't affect the speed of the */
00307 /* coder significantly whether it is .TRUE. or .FALSE., or whether it is 
00308 */
00309 /* a constant or a variable, since it is only examined once per frame. */
00310 /* Leaving it as a variable that is set to .TRUE.  seems like a good */
00311 /* idea, since it does enable some error-correction capability for */
00312 /* unvoiced frames, with no change in the coding rate, and no noticeable 
00313 */
00314 /* quality difference in the decoded speech. */
00315 /*    integer quant, nbits */
00316 /* *** Read/write: variables for debugging, not needed for LPC algorithm 
00317 */
00318 
00319 /*  Current frame, Unstable frames, Output clip count, Max onset buffer, 
00320 */
00321 /*    Debug listing detail level, Line count on listing page */
00322 
00323 /* nframe is not needed for an embedded LPC10 at all. */
00324 /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */
00325 /* ERROR, which is only called from RCCHK.  When LPC10 is embedded into */
00326 /* an application, I would recommend removing the call to ERROR in RCCHK, 
00327 */
00328 /* and remove ERROR and nunsfm completely. */
00329 /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in 
00330 */
00331 /* sread.f.  When LPC10 is embedded into an application, one might want */
00332 /* to cause it to be incremented in a routine that takes the output of */
00333 /* SYNTHS and sends it to an audio device.  It could be optionally */
00334 /* displayed, for those that might want to know what it is. */
00335 /* maxosp is never initialized to 0 in SETUP, although it probably should 
00336 */
00337 /* be, and it is updated in subroutine ANALYS.  I doubt that its value */
00338 /* would be of much interest to an application in which LPC10 is */
00339 /* embedded. */
00340 /* listl and lincnt are not needed for an embedded LPC10 at all. */
00341 /*    integer nframe, nunsfm, iclip, maxosp, listl, lincnt */
00342 /*    common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
00343 /*    common /contrl/ quant, nbits */
00344 /*    common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */
00345 /*       Parameters/constants */
00346 /*       Local variables that need not be saved */
00347 /*       Local state */
00348 /*       BUF is a buffer of speech samples that would have been returned 
00349 */
00350 /*       by the older version of SYNTHS, but the newer version doesn't, */
00351 /*       so that the newer version can always return MAXFRM samples on */
00352 /*       every call.  This has the effect of delaying the return of */
00353 /*       samples for one additional frame time. */
00354 
00355 /*       Indices 1 through BUFLEN contain samples that are left over from 
00356 */
00357 /*       the last call to SYNTHS.  Given the way that PITSYN works, */
00358 /*       BUFLEN should always be in the range MAXFRM-MAXPIT+1 through */
00359 /*       MAXFRM, inclusive, after a call to SYNTHS is complete. */
00360 
00361 /*       On the first call to SYNTHS (or the first call after */
00362 /*       reinitializing with the entry INITSYNTHS), BUFLEN is MAXFRM, and 
00363 */
00364 /*       a frame of silence is always returned. */
00365     /* Parameter adjustments */
00366     if (voice) {
00367    --voice;
00368    }
00369     if (rc) {
00370    --rc;
00371    }
00372     if (speech) {
00373    --speech;
00374    }
00375 
00376     /* Function Body */
00377     buf = &(st->buf[0]);
00378     buflen = &(st->buflen);
00379 
00380 /* Computing MAX */
00381     i__1 = min(*pitch,156);
00382     *pitch = max(i__1,20);
00383     i__1 = contrl_1.order;
00384     for (i__ = 1; i__ <= i__1; ++i__) {
00385 /* Computing MAX */
00386 /* Computing MIN */
00387    r__2 = rc[i__];
00388    r__1 = min(r__2,.99f);
00389    rc[i__] = max(r__1,-.99f);
00390     }
00391     pitsyn_(&contrl_1.order, &voice[1], pitch, rms, &rc[1], &contrl_1.lframe, 
00392        ivuv, ipiti, rmsi, rci, &nout, &ratio, st);
00393     if (nout > 0) {
00394    i__1 = nout;
00395    for (j = 1; j <= i__1; ++j) {
00396 
00397 /*             Add synthesized speech for pitch period J to the en
00398 d of */
00399 /*             BUF. */
00400 
00401        irc2pc_(&rci[j * 10 - 10], pc, &contrl_1.order, &c_b2, &g2pass);
00402        bsynz_(pc, &ipiti[j - 1], &ivuv[j - 1], &buf[*buflen], &rmsi[j - 1]
00403           , &ratio, &g2pass, st);
00404        deemp_(&buf[*buflen], &ipiti[j - 1], st);
00405        *buflen += ipiti[j - 1];
00406    }
00407 
00408 /*          Copy first MAXFRM samples from BUF to output array SPEECH 
00409 */
00410 /*          (scaling them), and then remove them from the beginning of
00411  */
00412 /*          BUF. */
00413 
00414    for (i__ = 1; i__ <= 180; ++i__) {
00415        speech[i__] = buf[i__ - 1] / 4096.f;
00416    }
00417    *k = 180;
00418    *buflen += -180;
00419    i__1 = *buflen;
00420    for (i__ = 1; i__ <= i__1; ++i__) {
00421        buf[i__ - 1] = buf[i__ + 179];
00422    }
00423     }
00424     return 0;
00425 } /* synths_ */

int tbdm_ ( real speech,
integer lpita,
integer tau,
integer ltau,
real amdf,
integer minptr,
integer maxptr,
integer mintau 
)

Definition at line 94 of file tbdm.c.

References difmag_(), max, and min.

Referenced by analys_().

00097 {
00098     /* System generated locals */
00099     integer i__1, i__2, i__3, i__4;
00100 
00101     /* Local variables */
00102     real amdf2[6];
00103     integer minp2, ltau2, maxp2, i__;
00104     extern /* Subroutine */ int difmag_(real *, integer *, integer *, integer 
00105        *, integer *, real *, integer *, integer *);
00106     integer minamd, ptr, tau2[6];
00107 
00108 /*    Arguments */
00109 /*    REAL SPEECH(LPITA+TAU(LTAU)), AMDF(LTAU) */
00110 /*   Stupid TOAST doesn't understand expressions */
00111 /*       Local variables that need not be saved */
00112 /*       Local state */
00113 /*       None */
00114 /*   Compute full AMDF using log spaced lags, find coarse minimum */
00115     /* Parameter adjustments */
00116     --speech;
00117     --amdf;
00118     --tau;
00119 
00120     /* Function Body */
00121     difmag_(&speech[1], lpita, &tau[1], ltau, &tau[*ltau], &amdf[1], minptr, 
00122        maxptr);
00123     *mintau = tau[*minptr];
00124     minamd = (integer)amdf[*minptr];
00125 /*   Build table containing all lags within +/- 3 of the AMDF minimum */
00126 /*    excluding all that have already been computed */
00127     ltau2 = 0;
00128     ptr = *minptr - 2;
00129 /* Computing MAX */
00130     i__1 = *mintau - 3;
00131 /* Computing MIN */
00132     i__3 = *mintau + 3, i__4 = tau[*ltau] - 1;
00133     i__2 = min(i__3,i__4);
00134     for (i__ = max(i__1,41); i__ <= i__2; ++i__) {
00135    while(tau[ptr] < i__) {
00136        ++ptr;
00137    }
00138    if (tau[ptr] != i__) {
00139        ++ltau2;
00140        tau2[ltau2 - 1] = i__;
00141    }
00142     }
00143 /*   Compute AMDF of the new lags, if there are any, and choose one */
00144 /*    if it is better than the coarse minimum */
00145     if (ltau2 > 0) {
00146    difmag_(&speech[1], lpita, tau2, &ltau2, &tau[*ltau], amdf2, &minp2, &
00147       maxp2);
00148    if (amdf2[minp2 - 1] < (real) minamd) {
00149        *mintau = tau2[minp2 - 1];
00150        minamd = (integer)amdf2[minp2 - 1];
00151    }
00152     }
00153 /*   Check one octave up, if there are any lags not yet computed */
00154     if (*mintau >= 80) {
00155    i__ = *mintau / 2;
00156    if ((i__ & 1) == 0) {
00157        ltau2 = 2;
00158        tau2[0] = i__ - 1;
00159        tau2[1] = i__ + 1;
00160    } else {
00161        ltau2 = 1;
00162        tau2[0] = i__;
00163    }
00164    difmag_(&speech[1], lpita, tau2, &ltau2, &tau[*ltau], amdf2, &minp2, &
00165       maxp2);
00166    if (amdf2[minp2 - 1] < (real) minamd) {
00167        *mintau = tau2[minp2 - 1];
00168        minamd = (integer)amdf2[minp2 - 1];
00169        *minptr += -20;
00170    }
00171     }
00172 /*   Force minimum of the AMDF array to the high resolution minimum */
00173     amdf[*minptr] = (real) minamd;
00174 /*   Find maximum of AMDF within 1/2 octave of minimum */
00175 /* Computing MAX */
00176     i__2 = *minptr - 5;
00177     *maxptr = max(i__2,1);
00178 /* Computing MIN */
00179     i__1 = *minptr + 5;
00180     i__2 = min(i__1,*ltau);
00181     for (i__ = *maxptr + 1; i__ <= i__2; ++i__) {
00182    if (amdf[i__] > amdf[*maxptr]) {
00183        *maxptr = i__;
00184    }
00185     }
00186     return 0;
00187 } /* tbdm_ */

int voicin_ ( integer vwin,
real inbuf,
real lpbuf,
integer buflim,
integer half,
real minamd,
real maxamd,
integer mintau,
real ivrc,
integer obound,
integer voibuf,
integer af,
struct lpc10_encoder_state st 
)

Definition at line 258 of file voicin.c.

References lpc10_encoder_state::dither, f, lpc10_encoder_state::fbue, lpc10_encoder_state::fbve, i_nint(), L1, L2, lpc10_encoder_state::lbue, lpc10_encoder_state::lbve, max, lpc10_encoder_state::maxmin, min, lpc10_encoder_state::ofbue, lpc10_encoder_state::olbue, lpc10_encoder_state::sfbue, lpc10_encoder_state::slbue, lpc10_encoder_state::snr, value, lpc10_encoder_state::voice, and vparms_().

Referenced by analys_().

00262 {
00263     /* Initialized data */
00264 
00265     real *dither;
00266     static real vdc[100]   /* was [10][10] */ = { 0.f,1714.f,-110.f,
00267        334.f,-4096.f,-654.f,3752.f,3769.f,0.f,1181.f,0.f,874.f,-97.f,
00268        300.f,-4096.f,-1021.f,2451.f,2527.f,0.f,-500.f,0.f,510.f,-70.f,
00269        250.f,-4096.f,-1270.f,2194.f,2491.f,0.f,-1500.f,0.f,500.f,-10.f,
00270        200.f,-4096.f,-1300.f,2e3f,2e3f,0.f,-2e3f,0.f,500.f,0.f,0.f,
00271        -4096.f,-1300.f,2e3f,2e3f,0.f,-2500.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,
00272        0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,
00273        0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,
00274        0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f };
00275     static integer nvdcl = 5;
00276     static real vdcl[10] = { 600.f,450.f,300.f,200.f,0.f,0.f,0.f,0.f,0.f,0.f }
00277        ;
00278 
00279     /* System generated locals */
00280     integer inbuf_offset = 0, lpbuf_offset = 0, i__1, i__2;
00281     real r__1, r__2;
00282 
00283     /* Builtin functions */
00284     integer i_nint(real *);
00285     double sqrt(doublereal);
00286 
00287     /* Local variables */
00288     real ar_b__, ar_f__;
00289     integer *lbve, *lbue, *fbve, *fbue;
00290     integer snrl, i__;
00291     integer *ofbue, *sfbue;
00292     real *voice;
00293     integer *olbue, *slbue;
00294     real value[9];
00295     integer zc;
00296     logical ot;
00297     real qs;
00298     real *maxmin;
00299     integer vstate;
00300     real rc1;
00301     extern /* Subroutine */ int vparms_(integer *, real *, real *, integer *, 
00302        integer *, real *, integer *, integer *, integer *, integer *, 
00303        real *, real *, real *, real *);
00304     integer fbe, lbe;
00305     real *snr;
00306     real snr2;
00307 
00308 /*    Global Variables: */
00309 /*       Arguments */
00310 /* $Log$
00311  * Revision 1.16  2004/06/26 03:50:14  markster
00312  * Merge source cleanups (bug #1911)
00313  *
00314  * Revision 1.15  2003/11/23 22:14:32  markster
00315  * Various warning cleanups
00316  *
00317  * Revision 1.14  2003/02/12 13:59:15  matteo
00318  * mer feb 12 14:56:57 CET 2003
00319  *
00320  * Revision 1.1.1.1  2003/02/12 13:59:15  matteo
00321  * mer feb 12 14:56:57 CET 2003
00322  *
00323  * Revision 1.2  2000/01/05 08:20:40  markster
00324  * Some OSS fixes and a few lpc changes to make it actually work
00325  *
00326  * Revision 1.2  1996/08/20  20:45:00  jaf
00327  * Removed all static local variables that were SAVE'd in the Fortran
00328  * code, and put them in struct lpc10_encoder_state that is passed as an
00329  * argument.
00330  *
00331  * Removed init function, since all initialization is now done in
00332  * init_lpc10_encoder_state().
00333  *
00334  * Revision 1.1  1996/08/19  22:30:14  jaf
00335  * Initial revision
00336  * */
00337 /* Revision 1.3  1996/03/29  22:05:55  jaf */
00338 /* Commented out the common block variables that are not needed by the */
00339 /* embedded version. */
00340 
00341 /* Revision 1.2  1996/03/26  19:34:50  jaf */
00342 /* Added comments indicating which constants are not needed in an */
00343 /* application that uses the LPC-10 coder. */
00344 
00345 /* Revision 1.1  1996/02/07  14:44:09  jaf */
00346 /* Initial revision */
00347 
00348 /*   LPC Processing control variables: */
00349 
00350 /* *** Read-only: initialized in setup */
00351 
00352 /*  Files for Speech, Parameter, and Bitstream Input & Output, */
00353 /*    and message and debug outputs. */
00354 
00355 /* Here are the only files which use these variables: */
00356 
00357 /* lpcsim.f setup.f trans.f error.f vqsetup.f */
00358 
00359 /* Many files which use fdebug are not listed, since it is only used in */
00360 /* those other files conditionally, to print trace statements. */
00361 /*    integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
00362 /*  LPC order, Frame size, Quantization rate, Bits per frame, */
00363 /*    Error correction */
00364 /* Subroutine SETUP is the only place where order is assigned a value, */
00365 /* and that value is 10.  It could increase efficiency 1% or so to */
00366 /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as 
00367 */
00368 /* a variable in a COMMON block, since it is used in many places in the */
00369 /* core of the coding and decoding routines.  Actually, I take that back. 
00370 */
00371 /* At least when compiling with f2c, the upper bound of DO loops is */
00372 /* stored in a local variable before the DO loop begins, and then that is 
00373 */
00374 /* compared against on each iteration. */
00375 /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */
00376 /* Similarly for quant, which is given a value of 2400 in SETUP.  quant */
00377 /* is used in only a few places, and never in the core coding and */
00378 /* decoding routines, so it could be eliminated entirely. */
00379 /* nbits is similar to quant, and is given a value of 54 in SETUP. */
00380 /* corrp is given a value of .TRUE. in SETUP, and is only used in the */
00381 /* subroutines ENCODE and DECODE.  It doesn't affect the speed of the */
00382 /* coder significantly whether it is .TRUE. or .FALSE., or whether it is 
00383 */
00384 /* a constant or a variable, since it is only examined once per frame. */
00385 /* Leaving it as a variable that is set to .TRUE.  seems like a good */
00386 /* idea, since it does enable some error-correction capability for */
00387 /* unvoiced frames, with no change in the coding rate, and no noticeable 
00388 */
00389 /* quality difference in the decoded speech. */
00390 /*    integer quant, nbits */
00391 /* *** Read/write: variables for debugging, not needed for LPC algorithm 
00392 */
00393 
00394 /*  Current frame, Unstable frames, Output clip count, Max onset buffer, 
00395 */
00396 /*    Debug listing detail level, Line count on listing page */
00397 
00398 /* nframe is not needed for an embedded LPC10 at all. */
00399 /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */
00400 /* ERROR, which is only called from RCCHK.  When LPC10 is embedded into */
00401 /* an application, I would recommend removing the call to ERROR in RCCHK, 
00402 */
00403 /* and remove ERROR and nunsfm completely. */
00404 /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in 
00405 */
00406 /* sread.f.  When LPC10 is embedded into an application, one might want */
00407 /* to cause it to be incremented in a routine that takes the output of */
00408 /* SYNTHS and sends it to an audio device.  It could be optionally */
00409 /* displayed, for those that might want to know what it is. */
00410 /* maxosp is never initialized to 0 in SETUP, although it probably should 
00411 */
00412 /* be, and it is updated in subroutine ANALYS.  I doubt that its value */
00413 /* would be of much interest to an application in which LPC10 is */
00414 /* embedded. */
00415 /* listl and lincnt are not needed for an embedded LPC10 at all. */
00416 /*    integer nframe, nunsfm, iclip, maxosp, listl, lincnt */
00417 /*    common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
00418 /*    common /contrl/ quant, nbits */
00419 /*    common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */
00420 /*    Parameters/constants */
00421 /*       Voicing coefficient and Linear Discriminant Analysis variables: 
00422 */
00423 /*       Max number of VDC's and VDC levels */
00424 /*       The following are not Fortran PARAMETER's, but they are */
00425 /*       initialized with DATA statements, and never modified. */
00426 /*       Actual number of VDC's and levels */
00427 /*       Local variables that need not be saved */
00428 /*       Note: */
00429 
00430 /*       VALUE(1) through VALUE(8) are assigned values, but VALUE(9) */
00431 /*       never is.  Yet VALUE(9) is read in the loop that begins "DO I = 
00432 */
00433 /*       1, 9" below.  I believe that this doesn't cause any problems in 
00434 */
00435 /*       this subroutine, because all VDC(9,*) array elements are 0, and 
00436 */
00437 /*       this is what is multiplied by VALUE(9) in all cases.  Still, it 
00438 */
00439 /*       would save a multiplication to change the loop to "DO I = 1, 8". 
00440 */
00441 /*       Local state */
00442 /*       WARNING! */
00443 
00444 /*       VOICE, SFBUE, and SLBUE should be saved from one invocation to */
00445 /*       the next, but they are never given an initial value. */
00446 
00447 /*       Does Fortran 77 specify some default initial value, like 0, or */
00448 /*       is it undefined?  If it is undefined, then this code should be */
00449 /*       corrected to specify an initial value. */
00450 
00451 /*       For VOICE, note that it is "shifted" in the statement that */
00452 /*       begins "IF (HALF .EQ. 1) THEN" below.  Also, uninitialized */
00453 /*       values in the VOICE array can only affect entries in the VOIBUF 
00454 */
00455 /*       array that are for the same frame, or for an older frame.  Thus 
00456 */
00457 /*       the effects of uninitialized values in VOICE cannot linger on */
00458 /*       for more than 2 or 3 frame times. */
00459 
00460 /*       For SFBUE and SLBUE, the effects of uninitialized values can */
00461 /*       linger on for many frame times, because their previous values */
00462 /*       are exponentially decayed.  Thus it is more important to choose 
00463 */
00464 /*       initial values for these variables.  I would guess that a */
00465 /*       reasonable initial value for SFBUE is REF/16, the same as used */
00466 /*       for FBUE and OFBUE.  Similarly, SLBUE can be initialized to */
00467 /*       REF/32, the same as for LBUE and OLBUE. */
00468 
00469 /*       These guessed initial values should be validated by re-running */
00470 /*       the modified program on some audio samples. */
00471 
00472 /*   Declare and initialize filters: */
00473 
00474     dither = (&st->dither);
00475     snr = (&st->snr);
00476     maxmin = (&st->maxmin);
00477     voice = (&st->voice[0]);
00478     lbve = (&st->lbve);
00479     lbue = (&st->lbue);
00480     fbve = (&st->fbve);
00481     fbue = (&st->fbue);
00482     ofbue = (&st->ofbue);
00483     olbue = (&st->olbue);
00484     sfbue = (&st->sfbue);
00485     slbue = (&st->slbue);
00486 
00487     /* Parameter adjustments */
00488     if (vwin) {
00489    --vwin;
00490    }
00491     if (buflim) {
00492    --buflim;
00493    }
00494     if (inbuf) {
00495    inbuf_offset = buflim[1];
00496    inbuf -= inbuf_offset;
00497    }
00498     if (lpbuf) {
00499    lpbuf_offset = buflim[3];
00500    lpbuf -= lpbuf_offset;
00501    }
00502     if (ivrc) {
00503    --ivrc;
00504    }
00505     if (obound) {
00506    --obound;
00507    }
00508     if (voibuf) {
00509    --voibuf;
00510    }
00511 
00512     /* Function Body */
00513 
00514 /*       The following variables are saved from one invocation to the */
00515 /*       next, but are not initialized with DATA statements.  This is */
00516 /*       acceptable, because FIRST is initialized ot .TRUE., and the */
00517 /*       first time that this subroutine is then called, they are all */
00518 /*       given initial values. */
00519 
00520 /*       SNR */
00521 /*       LBVE, LBUE, FBVE, FBUE, OFBUE, OLBUE */
00522 
00523 /*       MAXMIN is initialized on the first call, assuming that HALF */
00524 /*       .EQ. 1 on first call.  This is how ANALYS calls this subroutine. 
00525 */
00526 
00527 /*   Voicing Decision Parameter vector (* denotes zero coefficient): */
00528 
00529 /*    * MAXMIN */
00530 /*      LBE/LBVE */
00531 /*      ZC */
00532 /*      RC1 */
00533 /*      QS */
00534 /*      IVRC2 */
00535 /*      aR_B */
00536 /*      aR_F */
00537 /*    * LOG(LBE/LBVE) */
00538 /*  Define 2-D voicing decision coefficient vector according to the voicin
00539 g*/
00540 /*  parameter order above.  Each row (VDC vector) is optimized for a speci
00541 fic*/
00542 /*   SNR.  The last element of the vector is the constant. */
00543 /*             E    ZC    RC1    Qs   IVRC2  aRb   aRf        c */
00544 
00545 /*  The VOICE array contains the result of the linear discriminant functio
00546 n*/
00547 /*   (analog values).  The VOIBUF array contains the hard-limited binary 
00548 */
00549 /*   voicing decisions.  The VOICE and VOIBUF arrays, according to FORTRAN
00550  */
00551 /*   memory allocation, are addressed as: */
00552 
00553 /*       (half-frame number, future-frame number) */
00554 
00555 /*       |   Past    |  Present  |  Future1  |  Future2  | */
00556 /*       | 1,0 | 2,0 | 1,1 | 2,1 | 1,2 | 2,2 | 1,3 | 2,3 |  --->  time */
00557 
00558 /*   Update linear discriminant function history each frame: */
00559     if (*half == 1) {
00560    voice[0] = voice[2];
00561    voice[1] = voice[3];
00562    voice[2] = voice[4];
00563    voice[3] = voice[5];
00564    *maxmin = *maxamd / max(*minamd,1.f);
00565     }
00566 /*   Calculate voicing parameters twice per frame: */
00567     vparms_(&vwin[1], &inbuf[inbuf_offset], &lpbuf[lpbuf_offset], &buflim[1], 
00568        half, dither, mintau, &zc, &lbe, &fbe, &qs, &rc1, &ar_b__, &
00569        ar_f__);
00570 /*   Estimate signal-to-noise ratio to select the appropriate VDC vector. 
00571 */
00572 /*   The SNR is estimated as the running average of the ratio of the */
00573 /*   running average full-band voiced energy to the running average */
00574 /*   full-band unvoiced energy. SNR filter has gain of 63. */
00575     r__1 = (*snr + *fbve / (real) max(*fbue,1)) * 63 / 64.f;
00576     *snr = (real) i_nint(&r__1);
00577     snr2 = *snr * *fbue / max(*lbue,1);
00578 /*   Quantize SNR to SNRL according to VDCL thresholds. */
00579     snrl = 1;
00580     i__1 = nvdcl - 1;
00581     for (snrl = 1; snrl <= i__1; ++snrl) {
00582    if (snr2 > vdcl[snrl - 1]) {
00583        goto L69;
00584    }
00585     }
00586 /*    (Note:  SNRL = NVDCL here) */
00587 L69:
00588 /*   Linear discriminant voicing parameters: */
00589     value[0] = *maxmin;
00590     value[1] = (real) lbe / max(*lbve,1);
00591     value[2] = (real) zc;
00592     value[3] = rc1;
00593     value[4] = qs;
00594     value[5] = ivrc[2];
00595     value[6] = ar_b__;
00596     value[7] = ar_f__;
00597 /*   Evaluation of linear discriminant function: */
00598     voice[*half + 3] = vdc[snrl * 10 - 1];
00599     for (i__ = 1; i__ <= 8; ++i__) {
00600    voice[*half + 3] += vdc[i__ + snrl * 10 - 11] * value[i__ - 1];
00601     }
00602 /*   Classify as voiced if discriminant > 0, otherwise unvoiced */
00603 /*   Voicing decision for current half-frame:  1 = Voiced; 0 = Unvoiced */
00604     if (voice[*half + 3] > 0.f) {
00605    voibuf[*half + 6] = 1;
00606     } else {
00607    voibuf[*half + 6] = 0;
00608     }
00609 /*   Skip voicing decision smoothing in first half-frame: */
00610 /*     Give a value to VSTATE, so that trace statements below will print 
00611 */
00612 /*     a consistent value from one call to the next when HALF .EQ. 1. */
00613 /*     The value of VSTATE is not used for any other purpose when this is 
00614 */
00615 /*     true. */
00616     vstate = -1;
00617     if (*half == 1) {
00618    goto L99;
00619     }
00620 /*   Voicing decision smoothing rules (override of linear combination): */
00621 
00622 /*    Unvoiced half-frames:  At least two in a row. */
00623 /*    -------------------- */
00624 
00625 /*    Voiced half-frames:    At least two in a row in one frame. */
00626 /*    -------------------    Otherwise at least three in a row. */
00627 /*                 (Due to the way transition frames are encoded) */
00628 
00629 /*    In many cases, the discriminant function determines how to smooth. */
00630 /* In the following chart, the decisions marked with a * may be overridden
00631 .*/
00632 
00633 /*   Voicing override of transitions at onsets: */
00634 /*    If a V/UV or UV/V voicing decision transition occurs within one-half 
00635 */
00636 /*    frame of an onset bounding a voicing window, then the transition is */
00637 /*    moved to occur at the onset. */
00638 
00639 /*    P  1F */
00640 /*    ----- ----- */
00641 /*    0   0   0   0 */
00642 /*    0   0   0*  1  (If there is an onset there) */
00643 /*    0   0   1*  0* (Based on 2F and discriminant distance) */
00644 /*    0   0   1   1 */
00645 /*    0   1*  0   0  (Always) */
00646 /*    0   1*  0*  1  (Based on discriminant distance) */
00647 /*    0*  1   1   0* (Based on past, 2F, and discriminant distance) */
00648 /*    0   1*  1   1  (If there is an onset there) */
00649 /*    1   0*  0   0  (If there is an onset there) */
00650 /*    1   0   0   1 */
00651 /*    1   0*  1*  0  (Based on discriminant distance) */
00652 /*    1   0*  1   1  (Always) */
00653 /*    1   1   0   0 */
00654 /*    1   1   0*  1* (Based on 2F and discriminant distance) */
00655 /*    1   1   1*  0  (If there is an onset there) */
00656 /*    1   1   1   1 */
00657 
00658 /*   Determine if there is an onset transition between P and 1F. */
00659 /*   OT (Onset Transition) is true if there is an onset between */
00660 /*   P and 1F but not after 1F. */
00661     ot = ((obound[1] & 2) != 0 || obound[2] == 1) && (obound[3] & 1) == 0;
00662 /*   Multi-way dispatch on voicing decision history: */
00663     vstate = (voibuf[3] << 3) + (voibuf[4] << 2) + (voibuf[5] << 1) + voibuf[
00664        6];
00665     switch (vstate + 1) {
00666    case 1:  goto L99;
00667    case 2:  goto L1;
00668    case 3:  goto L2;
00669    case 4:  goto L99;
00670    case 5:  goto L4;
00671    case 6:  goto L5;
00672    case 7:  goto L6;
00673    case 8:  goto L7;
00674    case 9:  goto L8;
00675    case 10:  goto L99;
00676    case 11:  goto L10;
00677    case 12:  goto L11;
00678    case 13:  goto L99;
00679    case 14:  goto L13;
00680    case 15:  goto L14;
00681    case 16:  goto L99;
00682     }
00683 L1:
00684     if (ot && voibuf[7] == 1) {
00685    voibuf[5] = 1;
00686     }
00687     goto L99;
00688 L2:
00689     if (voibuf[7] == 0 || voice[2] < -voice[3]) {
00690    voibuf[5] = 0;
00691     } else {
00692    voibuf[6] = 1;
00693     }
00694     goto L99;
00695 L4:
00696     voibuf[4] = 0;
00697     goto L99;
00698 L5:
00699     if (voice[1] < -voice[2]) {
00700    voibuf[4] = 0;
00701     } else {
00702    voibuf[5] = 1;
00703     }
00704     goto L99;
00705 /*   VOIBUF(2,0) must be 0 */
00706 L6:
00707     if (voibuf[1] == 1 || voibuf[7] == 1 || voice[3] > voice[0]) {
00708    voibuf[6] = 1;
00709     } else {
00710    voibuf[3] = 1;
00711     }
00712     goto L99;
00713 L7:
00714     if (ot) {
00715    voibuf[4] = 0;
00716     }
00717     goto L99;
00718 L8:
00719     if (ot) {
00720    voibuf[4] = 1;
00721     }
00722     goto L99;
00723 L10:
00724     if (voice[2] < -voice[1]) {
00725    voibuf[5] = 0;
00726     } else {
00727    voibuf[4] = 1;
00728     }
00729     goto L99;
00730 L11:
00731     voibuf[4] = 1;
00732     goto L99;
00733 L13:
00734     if (voibuf[7] == 0 && voice[3] < -voice[2]) {
00735    voibuf[6] = 0;
00736     } else {
00737    voibuf[5] = 1;
00738     }
00739     goto L99;
00740 L14:
00741     if (ot && voibuf[7] == 0) {
00742    voibuf[5] = 0;
00743     }
00744 /*    GOTO 99 */
00745 L99:
00746 /*   Now update parameters: */
00747 /*   ---------------------- */
00748 
00749 /*  During unvoiced half-frames, update the low band and full band unvoice
00750 d*/
00751 /*   energy estimates (LBUE and FBUE) and also the zero crossing */
00752 /*   threshold (DITHER).  (The input to the unvoiced energy filters is */
00753 /*   restricted to be less than 10dB above the previous inputs of the */
00754 /*   filters.) */
00755 /*   During voiced half-frames, update the low-pass (LBVE) and all-pass */
00756 /*   (FBVE) voiced energy estimates. */
00757     if (voibuf[*half + 6] == 0) {
00758 /* Computing MIN */
00759    i__1 = fbe, i__2 = *ofbue * 3;
00760    r__1 = (*sfbue * 63 + (min(i__1,i__2) << 3)) / 64.f;
00761    *sfbue = i_nint(&r__1);
00762    *fbue = *sfbue / 8;
00763    *ofbue = fbe;
00764 /* Computing MIN */
00765    i__1 = lbe, i__2 = *olbue * 3;
00766    r__1 = (*slbue * 63 + (min(i__1,i__2) << 3)) / 64.f;
00767    *slbue = i_nint(&r__1);
00768    *lbue = *slbue / 8;
00769    *olbue = lbe;
00770     } else {
00771    r__1 = (*lbve * 63 + lbe) / 64.f;
00772    *lbve = i_nint(&r__1);
00773    r__1 = (*fbve * 63 + fbe) / 64.f;
00774    *fbve = i_nint(&r__1);
00775     }
00776 /*   Set dither threshold to yield proper zero crossing rates in the */
00777 /*   presence of low frequency noise and low level signal input. */
00778 /*   NOTE: The divisor is a function of REF, the expected energies. */
00779 /* Computing MIN */
00780 /* Computing MAX */
00781     r__2 = (real)(sqrt((real) (*lbue * *lbve)) * 64 / 3000);
00782     r__1 = max(r__2,1.f);
00783     *dither = min(r__1,20.f);
00784 /*   Voicing decisions are returned in VOIBUF. */
00785     return 0;
00786 } /* voicin_ */

int vparms_ ( integer vwin,
real inbuf,
real lpbuf,
integer buflim,
integer half,
real dither,
integer mintau,
integer zc,
integer lbe,
integer fbe,
real qs,
real rc1,
real ar_b__,
real ar_f__ 
)

Definition at line 134 of file vparms.c.

References abs, c_b2, f, i_nint(), max, min, r_sign(), and stop.

Referenced by voicin_().

00138 {
00139     /* System generated locals */
00140     integer inbuf_offset, lpbuf_offset, i__1;
00141     real r__1, r__2;
00142 
00143     /* Builtin functions */
00144     double r_sign(real *, real *);
00145     integer i_nint(real *);
00146 
00147     /* Local variables */
00148     integer vlen, stop, i__;
00149     real e_pre__;
00150     integer start;
00151     real ap_rms__, e_0__, oldsgn, lp_rms__, e_b__, e_f__, r_b__, r_f__, e0ap;
00152 
00153 /*       Arguments */
00154 /*       Local variables that need not be saved */
00155 /*   Calculate zero crossings (ZC) and several energy and correlation */
00156 /*   measures on low band and full band speech.  Each measure is taken */
00157 /*   over either the first or the second half of the voicing window, */
00158 /*   depending on the variable HALF. */
00159     /* Parameter adjustments */
00160     --vwin;
00161     --buflim;
00162     lpbuf_offset = buflim[3];
00163     lpbuf -= lpbuf_offset;
00164     inbuf_offset = buflim[1];
00165     inbuf -= inbuf_offset;
00166 
00167     /* Function Body */
00168     lp_rms__ = 0.f;
00169     ap_rms__ = 0.f;
00170     e_pre__ = 0.f;
00171     e0ap = 0.f;
00172     *rc1 = 0.f;
00173     e_0__ = 0.f;
00174     e_b__ = 0.f;
00175     e_f__ = 0.f;
00176     r_f__ = 0.f;
00177     r_b__ = 0.f;
00178     *zc = 0;
00179     vlen = vwin[2] - vwin[1] + 1;
00180     start = vwin[1] + (*half - 1) * vlen / 2 + 1;
00181     stop = start + vlen / 2 - 1;
00182 
00183 /* I'll use the symbol HVL in the table below to represent the value */
00184 /* VLEN/2.  Note that if VLEN is odd, then HVL should be rounded down, */
00185 /* i.e., HVL = (VLEN-1)/2. */
00186 
00187 /* HALF  START          STOP */
00188 
00189 /* 1     VWIN(1)+1      VWIN(1)+HVL */
00190 /* 2     VWIN(1)+HVL+1  VWIN(1)+2*HVL */
00191 
00192 /* Note that if VLEN is even and HALF is 2, then STOP will be */
00193 /* VWIN(1)+VLEN = VWIN(2)+1.  That could be bad, if that index of INBUF */
00194 /* is undefined. */
00195 
00196     r__1 = inbuf[start - 1] - *dither;
00197     oldsgn = (real)r_sign(&c_b2, &r__1);
00198     i__1 = stop;
00199     for (i__ = start; i__ <= i__1; ++i__) {
00200    lp_rms__ += (r__1 = lpbuf[i__], abs(r__1));
00201    ap_rms__ += (r__1 = inbuf[i__], abs(r__1));
00202    e_pre__ += (r__1 = inbuf[i__] - inbuf[i__ - 1], abs(r__1));
00203 /* Computing 2nd power */
00204    r__1 = inbuf[i__];
00205    e0ap += r__1 * r__1;
00206    *rc1 += inbuf[i__] * inbuf[i__ - 1];
00207 /* Computing 2nd power */
00208    r__1 = lpbuf[i__];
00209    e_0__ += r__1 * r__1;
00210 /* Computing 2nd power */
00211    r__1 = lpbuf[i__ - *mintau];
00212    e_b__ += r__1 * r__1;
00213 /* Computing 2nd power */
00214    r__1 = lpbuf[i__ + *mintau];
00215    e_f__ += r__1 * r__1;
00216    r_f__ += lpbuf[i__] * lpbuf[i__ + *mintau];
00217    r_b__ += lpbuf[i__] * lpbuf[i__ - *mintau];
00218    r__1 = inbuf[i__] + *dither;
00219    if (r_sign(&c_b2, &r__1) != oldsgn) {
00220        ++(*zc);
00221        oldsgn = -oldsgn;
00222    }
00223    *dither = -(*dither);
00224     }
00225 /*   Normalized short-term autocovariance coefficient at unit sample delay
00226  */
00227     *rc1 /= max(e0ap,1.f);
00228 /*  Ratio of the energy of the first difference signal (6 dB/oct preemphas
00229 is)*/
00230 /*   to the energy of the full band signal */
00231 /* Computing MAX */
00232     r__1 = ap_rms__ * 2.f;
00233     *qs = e_pre__ / max(r__1,1.f);
00234 /*   aR_b is the product of the forward and reverse prediction gains, */
00235 /*   looking backward in time (the causal case). */
00236     *ar_b__ = r_b__ / max(e_b__,1.f) * (r_b__ / max(e_0__,1.f));
00237 /*  aR_f is the same as aR_b, but looking forward in time (non causal case
00238 ).*/
00239     *ar_f__ = r_f__ / max(e_f__,1.f) * (r_f__ / max(e_0__,1.f));
00240 /*   Normalize ZC, LBE, and FBE to old fixed window length of 180. */
00241 /*   (The fraction 90/VLEN has a range of .58 to 1) */
00242     r__2 = (real) (*zc << 1);
00243     r__1 = r__2 * (90.f / vlen);
00244     *zc = i_nint(&r__1);
00245 /* Computing MIN */
00246     r__1 = lp_rms__ / 4 * (90.f / vlen);
00247     i__1 = i_nint(&r__1);
00248     *lbe = min(i__1,32767);
00249 /* Computing MIN */
00250     r__1 = ap_rms__ / 4 * (90.f / vlen);
00251     i__1 = i_nint(&r__1);
00252     *fbe = min(i__1,32767);
00253     return 0;
00254 } /* vparms_ */


Generated on Thu Apr 16 06:30:57 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6