clear
close all

[y,Fs] = audioread('carols.wav');
z=y(400001:800000,1)+y(400001:800000,2);
L=length(z)
Fs
figure(1)
plot((1:L)/Fs,z)
axis([ 0 L/Fs/2 -inf inf])
pause
figure(2)
plot((-L/2:L/2-1)*Fs/L,fftshift(abs(fft(z))))
axis([ -Fs/2 Fs/2 0 inf])
pause
sound(z,Fs);
pause
%LP
h=fir1(100,1/16);
zlp=conv(z,h,'same');
figure(2)
hold on
plot((-L/2:L/2-1)*Fs/L,fftshift(abs(fft(zlp))),'r')
axis([ -Fs/2 Fs/2 0 inf])
hold off
pause
sound(zlp,Fs);
pause
%Alias
za=z(1:16:L);
figure(3)
La=length(za)
Fsa=Fs/16;
plot((-La/2:La/2-1)*Fsa/La,fftshift(abs(fft(za))))
axis([ -Fsa/2 Fsa/2 0 inf])
pause
sound(za,Fsa);