# LPC spectra estimate

Started by February 6, 2009
LPC spectra should correspond with the envelope of DFT spectra.

I plot LPC spectra with matlab. The LPC spectra keep the same shape with the envelope of DFT spectra.

But it is larger with a offset than the DFT envelope.

Why? Where it go wrong?

Here is the matlab script which illustrate it.

N = 2560;
[x,fs] = wavread('lpc.wav',N); % any speech signal can be used

p;
a = lpc(x,p);

X t(x);
X = X(1:N/2+1)';
X = 10*log10(abs(X).^2);

Z = fft(a,N);
Z = 1./Z(1:N/2+1);
Z = 10*log10(abs(Z).^2);

figure;
plot(X');
hold on;
plot(Z,'r');
grid;
offset = 10;
figure;
plot(X+offset);
hold on;
plot(Z,'r');
grid;
Hyee Wang,

You must use the gain term to "lift" the log spectrum (in dB). It should
be returned by your lpc analysis function.

Best,

Miguel

h...@yahoo.com.cn wrote:
> LPC spectra should correspond with the envelope of DFT spectra.
>
> I plot LPC spectra with matlab. The LPC spectra keep the same shape with the envelope of DFT spectra.
>
> But it is larger with a offset than the DFT envelope.
>
> Why? Where it go wrong?
>
> Here is the matlab script which illustrate it.
>
> N = 2560;
> [x,fs] = wavread('lpc.wav',N); % any speech signal can be used
>
> p;
> a = lpc(x,p);
>
> X t(x);
> X = X(1:N/2+1)';
> X = 10*log10(abs(X).^2);
>
> Z = fft(a,N);
> Z = 1./Z(1:N/2+1);
> Z = 10*log10(abs(Z).^2);
>
> figure;
> plot(X');
> hold on;
> plot(Z,'r');
> grid;
> offset = 10;
> figure;
> plot(X+offset);
> hold on;
> plot(Z,'r');
> grid;
>
Hyee Wang,

The "correct" alternative is the one that multiplies by sqrt(residual
var). Please note that the LP spectral envelope is biased towards the
spectral peaks but does not quite touch them!

Regards,

Miguel

hyee wang wrote:
> Thank you.
>
> 1.I reply you by gmail system because I suspect that foriengers can
> not get my letters from yahoo system.
>
> Dspralted is bad .. that if I change my dsprated froum profile to
> gmail system, I can not find my any new post. I have to
>
> change back to the bad yahoo.com.cn system mail system.
>
> 2. LPC function in matlab return LPC coefficients and prediction error
> variance sigma^2. How to attain signal variance from prediction error variance?
>
> But, Multiply the spectra by either sigma^2 or 1/sigma^2 can not make a
> better spectra view.
> Multiply the spectra by either sigma or 1/sigma can not make a better
> spectra view.
>
> How to achieve the scale factor exactly?
>
> Here is the matlab script.
>
> N = 2560;
> [x,fs] = wavread('origsign.wav',N); % any speech signal can be used
> p= 12;
> [a,e] = lpc(x,p);
> %a = a.*(e);
> X t(x);
> X = X(1:N/2+1)';
> X = abs(X);
> X = 10*log10(abs(X));
> Z = fft(a,N);
> Z = 1./Z(1:N/2+1);
> Z = abs(Z);
> Z = Z*(1/e);
> %Z = Z*e;
> %Z = Z*sqrt(e);
> %Z = Z*sqrt(1/e);
> Z = 10*log10(abs(Z));
> figure;
> plot(X);
> hold on;
> plot(Z,'r');
> grid;
> offset = 24;
> figure;
> plot(X+offset);
> hold on;
> plot(Z,'r');
> grid;
> 2009/2/8 Hyee Wang :
>>
>> --- 0927, Miguel Arjona Ramrez д
>>
>> : Miguel Arjona Ramrez
>> : Re: [speechcoding] LPC spectra estimate
>> : h...@yahoo.com.cn
>> : s...
>> : 2009,27,,5:22
>>
>> Hyee Wang,
>> You must use the gain term to "lift" the log spectrum (in dB). It
>> should be returned by your lpc analysis function.
>> Best,
>> Miguel
>> h...@yahoo.com.cn wrote:
>>> LPC spectra should correspond with the envelope of DFT spectra.
>>> I plot LPC spectra with matlab. The LPC spectra keep the same shape with
>> the envelope of DFT spectra.
>>> But it is larger with a offset than the DFT envelope.
>>>
>>> Why? Where it go wrong?
>>>
>>> Here is the matlab script which illustrate it.
>>> N = 2560;
>>> [x,fs] = wavread('lpc.wav',N); % any speech signal can be used
>>>
>>> p;
>>> a = lpc(x,p);
>>>
>>> X t(x);
>>> X = X(1:N/2+1)';
>>> X = 10*log10(abs(X).^2);
>>>
>>> Z = fft(a,N);
>>> Z = 1./Z(1:N/2+1);
>>> Z = 10*log10(abs(Z).^2);
>>>
>>> figure;
>>> plot(X');
>>> hold on;
>>> plot(Z,'r');
>>> grid;
>>> offset = 10;
>>> figure;
>>> plot(X+offset);
>>> hold on;
>>> plot(Z,'r');
>>> grid;
LPC spectra should correspond with the envelope of DFT spectra.
>
>I plot LPC spectra with matlab. The LPC spectra keep the same shape with the envelope of DFT spectra.
>
>But it is larger with a offset than the DFT envelope.
>
>Why? Where it go wrong?
>
>Here is the matlab script which illustrate it.
>
>N = 2560;
>[x,fs] = wavread('lpc.wav',N); % any speech signal can be used
>
>p;
>a = lpc(x,p);
>
>X t(x);
>X = X(1:N/2+1)';
>X = 10*log10(abs(X).^2);
>
>Z = fft(a,N);
>Z = 1./Z(1:N/2+1);
>Z = 10*log10(abs(Z).^2);
>
>figure;
>plot(X');
>hold on;
>plot(Z,'r');
>grid;
>offset = 10;
>figure;
>plot(X+offset);
>hold on;
>plot(Z,'r');
>grid;

With some friend's help,I have acquired the exact multiplication

Although almost 90 percent of friends think the true multiplication
factor is sqrt(e), but the real one is
where,e refer to as the variance of prediction error ,the returned
value from lpc function.
N is the signal length.
Thank Rune Allnor.
But I am still puzzled with Why use energy sqrt(e*N) ,not power
(virance) sqrt(e), to be the true multiplication factor.
According to LPC theory,synthesis filter
H = G./[1-sum(ai.*Z.(-i))],
E(n) = s(n) - sp(n) = G*e(n);
here,E(n) refer to as lpc pediction error, and e(n) refer to as
excitation.
s(n) is the input speech,sp(n) is the estimated signal.
Assume the variance of e(n) to be 1.
sum( E(n)*E(n)) = G.^2*sum( e(n)*e(n)) = G.^2* N;
then G^2 = [sum( E(n)*E(n) ) ] ./ N.
It should be variance(power),not energy. Why?
Please tell the principle,not try to match the 2 spectrum curves
rouglyh without explanation.
Here is the matlab script which use " sqrt(e*N)" to illustrate it.
N = 25600;
[x,fs] = wavread('lpc.wav',N); % any speech signal can be used
p;
[a,e] = lpc(x,p);
X t(x);
X = X(1:N/2+1)';
X = 10*log10(abs(X).^2);
Z = fft(a,N);
Z1 = 1./Z(1:N/2+1);
Z = Z1.*sqrt(e*N); % to use sqrt(e*N),not sqrt(e),Why?
Z = 10*log10(abs(Z).^2);
figure;
plot(X);
hold on;
plot(Z,'r');
grid;
--- Z = Z1.*sqrt(e*N); % to use sqrt(e*N),not sqrt(e),Why?