%linespectralfrequency.m
function [LSP1,LSP2]=linespectralfrequency(S1,S2,FS)
[res1,res2,S11,utforste,ltforste,ltforzcr]=endpointdetection(S1,FS);
[res1,res2,S12,utforste,ltforste,ltforzcr]=endpointdetection(S2,FS);
S11=dynamictimewarping1(S11,S12,FS);
lpccoef11=mainprogramforlpc(S11,FS);
lpccoef12=mainprogramforlpc(S12,FS);
j=1;
for i=1:1:size(lpccoef11,2)
R=roots(lpccoef11(:,i));
R1=1./conj(R);
R2=poly(R1);
R3=[zeros(1,13) 1];
R4=conv(R2,R3);
R5=[zeros(1,13) -1];
R6=conv(R2,R5);
lpccoef11new(:,i)=[lpccoef11(:,i)' zeros(1,13) ];
poly1(:,i)=lpccoef11new(:,i)+R4';
linespectrum1(:,i)=roots(poly1(:,i));
poly2(:,i)=lpccoef11new(:,i)+R6';
linespectrum2(:,i)=roots(poly2(:,i));
figure(1)
subplot(3,6,j)
hold on
zplane([],[linespectrum1(:,i) linespectrum2(:,i)])
figure(2)
subplot(4,5,j)
plot(angle(linespectrum1(:,i)),'bo')
hold on
plot(angle(linespectrum2(:,i)),'bo')
LSP1{i}=[linespectrum1(:,i) linespectrum2(:,i)];
R=roots(lpccoef12(:,i));
R1=1./conj(R);
R2=poly(R1);
R3=[zeros(1,13) 1];
R4=conv(R2,R3);
R5=[zeros(1,13) -1];
R6=conv(R2,R5);
lpccoef12new(:,i)=[lpccoef12(:,i)' zeros(1,13) ];
poly1(:,i)=lpccoef12new(:,i)+R4';
linespectrum1(:,i)=roots(poly1(:,i));
poly2(:,i)=lpccoef12new(:,i)+R6';
linespectrum2(:,i)=roots(poly2(:,i));
figure(3)
subplot(3,6,j)
hold on
zplane([],[linespectrum1(:,i) linespectrum2(:,i)])
figure(2)
subplot(4,5,j)
plot(angle(linespectrum1(:,i)),'r*')
hold on
plot(angle(linespectrum2(:,i)),'r*')
LSP2{i}=[linespectrum1(:,i) linespectrum2(:,i)];
j=j+1;
end