www.pudn.com > lpc.zip > mload_i.c
/******************************************************************
*
* MLOAD Version 48
*
******************************************************************
*
* Load a covariance matrix
*
* Inputs:
* ORDER - Analysis order
* AWINS - Analysis window start
* AWINF - Analysis window finish
* SPEECH(AWINF) - Speech buffer
* Outputs:
* PHI(ORDER,ORDER) - Covariance matrix
* PSI(ORDER) - Prediction vector
*/
#include "lpcdefs.h"
#include "ourstuff.h"
mload_i(awinf, speech, phi, psi )
int_type awinf;
int_type speech[];
long_type phi[ORDER][ORDER], psi[ORDER];
{
int_type r, c, i, start;
/* Load first column of triangular covariance matrix PHI */
start = 1 + ORDER;
for(r=1;r<=ORDER;r++) {
phi[r-1][0] = 0;
for(i=start;i<=awinf;i++) {
phi[r-1][0] += (long_type)speech[i-1]*(long_type)speech[i-r];
/*if( r == 1) printf("int i:%d speech:%d %d phi_i:%ld\n",i,speech[i-1], speech[i-1], phi[r-1][0]);*/
}
}
/* Load last element of vector PSI */
psi[ORDER] = 0;
for(i=start;i<=awinf;i++) {
psi[ORDER] += (long_type)speech[i]*(long_type)speech[i-ORDER];
/*printf("int i:%d speech:%d %d psi:%d\n",i,speech[i], speech[i-ORDER],psi[ORDER]);*/
}
/* End correct to get additional columns of PHI */
for(r=2;r<=ORDER;r++)
for(c=2;c<=r;c++) {
phi[r-1][c-1] = phi[r-2][c-2]
- (long_type)speech[awinf+1-r]*(long_type)speech[awinf+1-c]
+ (long_type)speech[start-r]*(long_type)speech[start-c];
/*if (r == 10) printf("int c:%d phi_i:%ld\n",c, phi[r-1][c-1]); */
}
/* End correct to get additional elements of PSI */
for(c=1;c