- if(i%2)lpc[j]+=lpc[j]*r;
-
- error*=1.0-r*r;
- }
-
- /* we need the error value to know how big an impulse to hit the
- filter with later */
-
- return error;
-}
-
-/* Input : n element envelope spectral curve
- Output: m lpc coefficients, excitation energy */
-
-double vorbis_lpc_from_curve(double *curve,double *lpc,lpc_lookup *l){
- int n=l->ln;
- int m=l->m;
- double *work=alloca(sizeof(double)*(n+n));
- double fscale=.5/n;
- int i,j;
-
- /* input is a real curve. make it complex-real */
- /* This mixes phase, but the LPC generation doesn't care. */
- for(i=0;i<n;i++){
- work[i*2]=curve[i]*fscale;
- work[i*2+1]=0;
- }
- work[n*2-1]=curve[n-1]*fscale;
-
- n*=2;
- drft_backward(&l->fft,work);
-
- /* The autocorrelation will not be circular. Shift, else we lose
- most of the power in the edges. */
-
- for(i=0,j=n/2;i<n/2;){
- double temp=work[i];
- work[i++]=work[j];
- work[j++]=temp;
- }
-
- return(vorbis_lpc_from_data(work,lpc,n,m));
-}
-
-void lpc_init(lpc_lookup *l,long mapped, int m){
- memset(l,0,sizeof(lpc_lookup));
-
- l->ln=mapped;
- l->m=m;
-
- /* we cheat decoding the LPC spectrum via FFTs */
- drft_init(&l->fft,mapped*2);
-
-}
-
-void lpc_clear(lpc_lookup *l){
- if(l){
- drft_clear(&l->fft);
- }
-}