/*---------------------------------------------------------------------------*\ FILE........: lpc.c AUTHOR......: David Rowe DATE CREATED: 30/9/90 Linear Prediction functions written in C. \*---------------------------------------------------------------------------*/ /* Copyright (C) 2009 David Rowe All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ #define LPC_MAX_N 512 /* maximum no. of samples in frame */ #define PI 3.141592654 /* mathematical constant */ #include #include #include "defines.h" #include "lpc.h" /*---------------------------------------------------------------------------*\ hanning_window() Hanning windows a frame of speech samples. \*---------------------------------------------------------------------------*/ void hanning_window( float Sn[], /* input frame of speech samples */ float Wn[], /* output frame of windowed samples */ int Nsam /* number of samples */ ) { int i; /* loop variable */ for(i=0; i 1.0) k[i] = 0.0; a[i][i] = k[i]; for(j=1; j<=i-1; j++) a[i][j] = a[i-1][j] + k[i]*a[i-1][i-j]; /* Equation 38c, Makhoul */ E[i] = (1-k[i]*k[i])*E[i-1]; /* Equation 38d, Makhoul */ } for(i=1; i<=order; i++) lpcs[i] = a[order][i]; lpcs[0] = 1.0; } /*---------------------------------------------------------------------------*\ inverse_filter() Inverse Filter, A(z). Produces an array of residual samples from an array of input samples and linear prediction coefficients. The filter memory is stored in the first order samples of the input array. \*---------------------------------------------------------------------------*/ void inverse_filter( float Sn[], /* Nsam input samples */ float a[], /* LPCs for this frame of samples */ int Nsam, /* number of samples */ float res[], /* Nsam residual samples */ int order /* order of LPC */ ) { int i,j; /* loop variables */ for(i=0; i