% Aliasing and Folding because of too low sampling rate

% Musical scale fs=11025Hz with a big interfering sinusoid
disp('Generate signal, play it, and spectrogram ...')
playscale;
tt = (1:length(xx))/fs;
xx = xx+100*cos(2*pi*fs/4*tt);
soundsc(xx,fs)
specgram(xx,1024,fs)

pause
disp('Length 4 averager, spectrogram ...')
Len = 4;
yy=conv(xx,ones(1,Len)/Len);
specgram(yy,1024,fs)
soundsc(yy(Len:end-Len));
pause

disp('Length 16 averager, spectrogram ...')
Len = 16;
yy=conv(xx,ones(1,Len)/Len);
specgram(yy,1024,fs)
soundsc(yy(Len:end-Len));
pause

disp('Length 15 averager, spectrogram ...')
Len = 15;
yy=conv(xx,ones(1,Len)/Len);
specgram(yy,1024,fs)
soundsc(yy(Len:end-Len));

