% Aliasing and Folding because of too low sampling rate

% Musical scale fs=11025Hz
disp('Generate signal, play it, and spectrogram ...')
playscale;
soundsc(xx,fs)
specgram(xx,1024,fs)

pause
disp('Downsample so that fs=1102.5.Hz, spectrogram ...')
% Downsample by factor of 10 -> fs = 1102.5Hz
yy=xx(1:10:end);
specgram(yy,128,fs/10)

pause
disp('To play the signal, we must interpolate.')
% The damage is done, we need to interpolate to get back to 
% a sampling rate that can be played via soundsc
zz=interp(yy,10);
soundsc(zz,fs)

pause
disp('Play it again, spectrogram and sound have artifacts from interpolation.')

% The specttrogram (and sound) shows some artifacts introduced by the interpolation
soundsc(zz,fs)
specgram(zz,1024,fs)