%-----------------------------------
% script spectrum
clear
[y,Fs,bits]=wavread('tele_1.wav');
a=input('starting point')
n=input('length of series (=power of 2)')
x=y(a:a+n); m=n/2; 
sound(x,Fs)
%-----------------------------------
y = fft(x(1:n));
P2 = struct('a',real(y(1:m+1))/m,'b',-imag(y(2:m))/m);
P2.a(1)=P2.a(1)/2;P2.a(m+1)=P2.a(m+1)/2;
E(2:m)=sqrt(P2.a(2:m).^2+P2.b(1:m-1).^2);
E(1)=abs(P2.a(1));E(m+1)=abs(P2.a(m+1));
Bvals = linspace(0,n/Fs,n+1)';
Gvals = CSeval(P2,n/Fs,Bvals);
subplot(2,1,1); 
plot(Bvals,Gvals)
subplot(2,1,2);
plot(E(1:200))
for i=1:m+1
    if (E(i)>.038)
        i-1
    end
end
%axis([0 360 -.05 1.05])
%set(gca,'xTick',linspace(0,360,13))