> Isn't that what I showed? I only used the FFT, which hardly is
> matlab-specific. The one remaining problem is a normalization
> factor that could be computed from the signal energy.
>
Oh yes..you are right...sorry about that...Thanks :o)
Reply by Rune Allnor●September 28, 20052005-09-28
Lars Hansen wrote:
> Thanks, but the thing I was interested in is how the lpc-based power
> spectrum should be calculated so it is comparable with the non-parametric
> power spectrum (that is: so the lpc-based power spectrum is a smooth
> approximation of the non-parametric power spectrum) -- preferably without
> use of matlab-functions so I can see what's going on :o)
Isn't that what I showed? I only used the FFT, which hardly is
matlab-specific. The one remaining problem is a normalization
factor that could be computed from the signal energy.
Rune
Reply by Lars Hansen●September 28, 20052005-09-28
Thanks, but the thing I was interested in is how the lpc-based power
spectrum should be calculated so it is comparable with the non-parametric
power spectrum (that is: so the lpc-based power spectrum is a smooth
approximation of the non-parametric power spectrum) -- preferably without
use of matlab-functions so I can see what's going on :o)
Reply by Rune Allnor●September 28, 20052005-09-28
Lars Hansen wrote:
> Hi
>
> I have a question about LPC-analysis.
>
> I have a frame of 256 speech samples which I assume is the output of an
> IIR-filter and I do LPC-analysis of the frame to obtain the coefficients of
> the IIR-filter.
>
> I want to do a comparison of the non-parametric power spectrum (by use of
> FFT) and the model-based power spectrum to see how well they fit, but I am
> not sure if I have done it right.
>
> So I am hoping that there are some experts out there who could check out my
> code for possible errors and tell me whether or not I have done it
> correctly?
>
> Here is the code:
[-- code snipped --]
It is not up to me to say whether what you have done it correct or not,
but plotting the spectra can be done very easily.
Assume you have the data vector x and filter coefficient vectors
a and b available. What you do, then, is this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N = length(x);
X = fft(x,N);
A = fft(a,N);
B = fft(b,N);
H = B./A;
fv= [0:N-1]/N*fs;
plot(fv,abs(X),'b',fv,abs(H),'r')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
and that should be it, except for some normalization factor.
Rune
Reply by Lars Hansen●September 28, 20052005-09-28
Hi
I have a question about LPC-analysis.
I have a frame of 256 speech samples which I assume is the output of an
IIR-filter and I do LPC-analysis of the frame to obtain the coefficients of
the IIR-filter.
I want to do a comparison of the non-parametric power spectrum (by use of
FFT) and the model-based power spectrum to see how well they fit, but I am
not sure if I have done it right.
So I am hoping that there are some experts out there who could check out my
code for possible errors and tell me whether or not I have done it
correctly?
Here is the code:
clc
close all
clear
% load speech
[x,Fs]=wavread('1_s');
x=x';
% take a speech segment
N=1000;
x=x(1,5000+N:5255+N);
% do LPC-analysis
[a,e]=lpc(x,10);
a=real(a);
% find non-parametric power spectrum
Sxx=abs(fft(x)).^2;
Sxx=Sxx./256;
% find model-based power spectrum
for f=0:255
z=exp(-j*2*pi*f/256);
num=e;
den=256*abs(a(1)+a(2)*z^-1+a(3)*z^-2+a(4)*z^-3+a(5)*z^-4+a(6)*z^-5+a(7)*z^-6+a(8)*z^-7+a(9)*z^-8+a(10)*z^-9+a(11)*z^-10).^2;
u(f+1)=num/den;
end
% plot results
plot(u)
hold
plot(Sxx,'r--')
hold
Thanks in advance :o)