Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (56 sloc) 1.9 KB
close all
clc
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
% ALIASING MOZART %
% Author: Cecilia Casarini %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In this script the concept of aliasing is illustrated by modifying the
% sample rate in a famous aria from Mozart: Der Hölle Rache. To obtain the
% effect we just discard some samples, e.g. we keep one every two samples
% to halve the sample rate, then 1 over 4 and so on.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reading the .wav file
[y, fs] = audioread('Mozart_derhollerache_Fs_44100Hz.wav');
% Using just one channel
y = y(:,1);
% 1. Sampling at half the sample rate
y1 = y(1:2:end);
% Normalizing the signal
y1 = y1./max(abs(y1(:)));
% Sample rate
fs1 = round(fs/2);
% Play
soundsc(y1, fs1);
pause
% 2. Sampling at 1/4th of the sample rate
y2 = y(1:4:end);
% Normalizing the signal
y2 = y2./max(abs(y2(:)));
% Sample rate
fs2 = round(fs/4);
% Play
soundsc(y2, fs2);
pause
% 3. Sampling at 1/8th of the sample rate
y3 = y(1:8:end);
% Normalizing the signal
y3 = y3./max(abs(y3(:)));
% Sample rate
fs3 = round(fs/8);
% Play
soundsc(y3, fs3);
pause
% 4. Sampling at 1/16th of the sample rate
y4 = y(1:16:end);
% Normalizing the signal
y4 = y4./max(abs(y4(:)));
% Sample rate
fs4 = round(fs/16);
% Play
soundsc(y4, fs4);
% Saving .wav files
% audiowrite('Mozart_derhollerache_Fs_22050Hz.wav', y1,(fs1));
% audiowrite('Mozart_derhollerache_Fs_11025Hz.wav', y2,(fs2));
% audiowrite('Mozart_derhollerache_Fs_5513Hz.wav', y3,(fs3));
% audiowrite('Mozart_derhollerache_Fs_2756Hz.wav', y4,(fs4));