DSPRelated.com
Forums

Method of Finding LPC Coefficients for Digital Filter

Started by alexandra3753 June 28, 2009
Hi, I'm doing some speech processing using Linear Predictive Coding, and I'm trying to use MATLAB to find the feedback coefficients, ai, for a digital filter of the form

y[n] = x[n] + Ʃ(ai * y[n-i])

(sum goes from i = 1 to i = N where N is the order of the filter)

where n is the index of the sample point, y[n] is the output, x[n] is a pulse input with period equal to the pitch period of the speech segment, and the y[n-i] are the past outputs. I'm pretty sure the feedforward coefficients in this case should be b = [1 0 0 0....0] of length N +1, so I ignore them in the formula.

I wrote a program which will solve for the ai's by simply looping through and plugging in each value of y[n], a 0 for x[n] and the previous values for y[n], but now I'm confused:

Once I solve for my ai's, I can plug them back in and get my vector y[n], since that's what I used to solve for the coefficients in the first place... but when I use the filter function in MATLAB

y = filter(b,a,x(n));

where x(n) is the pulse input, I thought y should be equal or at least close to my original output vector y[n], but it isn't. Also, when I use the freqz function

[H,F] = freqz(b,a,# of points,sampling frequency);
plot(F,20*log10(abs(H)));

The plot does not look like the frequency spectrum of the original signal, and does not get better as I increase the order of the filter. This tells me my coefficients must be wrong. When I use the built-in MATLAB function

a = lpc(y,N) (where N is again the filter order)

I get coefficients that are nothing like the ones I found, and when I use the filter function on them, the y is nothing like the original y[n]. However, the plot of the spectral envelope looks just like it should, so obviously the coefficients are correct.

I know the built-in lpc function is using the autocorrelation method, but I don't understand why my method of finding the coefficients isn't working!

I must be missing something, as I'm very new to signal processing. Could you please help me figure out what I'm doing wrong? Why am I not getting the right results by simply plug in present output, present pulse input and past outputs to solve for the coefficients?

Don't ask me why I can't just use the built-in MATLAB lpc function :) ... I just need to know why my method isn't working or whether it would work if I fixed something that I'm doing wrong.
Any help/suggestions would be very very much appreciated!

Thank you! Alexandra.