function aux = analyse(y,Fe,fmin,fmax,nfft)
%        aux = analyse(y,Fe,fmin,fmax,nfft)
% analyse de sons sur la bande de frequence
% [fmin fmax] avec fft de longeur nfft
%--------------------------------------------

n = length(y);
T = n/Fe; t = (1:n)/n*T;
y = .95*y/max(abs(y));
sound(y,Fe);

% 'analyse' en temps
%-------------------
figure(1);
plot(t,y);
xlabel('Temps'); ylabel('Pression'); 

% analyse en frequence
%---------------------
figure(2);
a = ceil(log2(n));
N = 2^a; z = fft(y,N);
z =z/max(abs(z));
N1 = max(floor(N*fmin/Fe),1);
N2 = ceil(N*fmax/Fe);
z = z(N1:N2);
f = (N1:N2)/N2*fmax;
plot(f,abs(z));
xlabel('Fréquence'); ylabel('Fourier'); 

% analyse temps-frequence
%------------------------
figure(3);
window = nfft; noverlap = ceil(nfft/3);
specgram(y,nfft,Fe,window,noverlap);
xlabel('Temps'); ylabel('Fréquence');
axis([0 T fmin fmax]);
aux = 1;
pause(T+2);
