예제 #1
0
void lpc(size_t lpc_ord, double lpc_stabl, size_t wsize, short *data, double *lpca,
         double *ar, double *lpck, double *normerr, double *rms, double preemp,
         window_type_t type)
{
    double *dwind;
    double rho[MAXORDER+1], k[MAXORDER], a[MAXORDER+1],*r,*kp,*ap,en,er;
    double wfact = 1.0;

    dwind = malloc(wsize*sizeof(double));

    w_window(data, dwind, wsize, preemp, type);
    if(!(r = ar)) r = rho;
    if(!(kp = lpck)) kp = k;
    if(!(ap = lpca)) ap = a;
    autoc( wsize, dwind, lpc_ord, r, &en );
    if(lpc_stabl > 1.0) { /* add a little to the diagonal for stability */
        size_t i;
        double ffact;
        ffact =1.0/(1.0 + exp((-lpc_stabl/20.0) * log(10.0)));
        for(i=1; i <= lpc_ord; i++) rho[i] = ffact * r[i];
        *rho = *r;
        r = rho;
        if(ar)
            for(i=0;i<=lpc_ord; i++) ar[i] = r[i]; /* copy out for possible use later */
    }
    durbin ( r, kp, &ap[1], lpc_ord, &er);

    *ap = 1.0;
    if(rms) *rms = en/wfact;
    if(normerr) *normerr = er;

    free(dwind);
}
예제 #2
0
파일: autohf.c 프로젝트: longluo/VoiceCodec
void autohf(float *si, float *w, int n, float omega, float *a)
{
    int i;
    float c0, c[MAXNO], atemp[MAXNO+1], s[MAXLL];

    memset(atemp, 0, sizeof(atemp));
    
    for (i = 0;  i < n ; i++)
        s[i] = si[i] * w[i];		/* apply window			*/

    cor(s, n, &c0, c);			/* calculate autocorrelations	*/

    atemp[0] = 1.0f;			/* convert autocorrelations to pc's  */
    durbin(c0, c, &atemp[1]);

    bwexp1(omega, atemp, a, MAXNO);		/* expand corrected pc's	*/
}