% 1.
% a)
deltat = 5e-5; %detemine the length of each tempo
Q = 0:deltat:(60/112);
E = 0:deltat:(60/112/2);
DQ = 0:deltat:(60/112*1.5);
H = 0:deltat:(60/112*2);
fA = 440*2*pi; %detemine the frequency of each tune
fG = 2^(-2/12) * fA;
fBf = 2^(1/12) * fA;
fC = 2^(3/12) * fA;
fD = 2^(4/12) * fA;
QG = sin(fG * Q); %generate each tune
QBf = sin(fBf * Q);
DQC = sin(fC * DQ);
EDf = sin(fD * E);
HC = sin(fC * H);
melody = [QG,QBf,DQC,QG,QBf,EDf,HC,QG,QBf,DQC,QBf,QG]; %generate melody
sound(melody,1/deltat);
wavwrite(melody,1/deltat,'smoke.wav'); %generate sound file
pause(10);
% b)
deltat = 5e-5; %detemine the length of each tempo
Q = 0:deltat:(60/112/2);
E = 0:deltat:(60/112/2/2);
DQ = 0:deltat:(60/112*1.5/2);
H = 0:deltat:(60/112*2/2);
fA = 440*2*pi; %detemine the frequency of each tune
fG = 2^(-2/12) * fA;
fBf = 2^(1/12) * fA;
fC = 2^(3/12) * fA;
fD = 2^(4/12) * fA;
QG = sin(fG * Q); %generate each tune
QBf = sin(fBf * Q);
DQC = sin(fC * DQ);
EDf = sin(fD * E);
HC = sin(fC * H);
melody = [QG,QBf,DQC,QG,QBf,EDf,HC,QG,QBf,DQC,QBf,QG]; %generate melody
sound(melody,1/deltat);
wavwrite(melody,1/deltat,'smokefast.wav'); %generate sound file
pause(10);
% c)
deltat = 5e-5; %detemine the length of each tempo
Q = 0:deltat:(60/112);
E = 0:deltat:(60/112/2);
DQ = 0:deltat:(60/112*1.5);
H = 0:deltat:(60/112*2);
fA = 880*2*pi; %detemine the frequency of each tune
fG = 2^(-2/12) * fA;
fBf = 2^(1/12) * fA;
fC = 2^(3/12) * fA;
fD = 2^(4/12) * fA;
QG = sin(fG * Q); %generate each tune
QBf = sin(fBf * Q);
DQC = sin(fC * DQ);
EDf = sin(fD * E);
HC = sin(fC * H);
melody = [QG,QBf,DQC,QG,QBf,EDf,HC,QG,QBf,DQC,QBf,QG]; %generate melody
sound(melody,1/deltat);
wavwrite(melody,1/deltat,'smokefast.wav'); %generate sound file
pause(10);
%2.
[beatles, Fs] = wavread('Beatles.wav');
beatles_rev = flipud(beatles);
sound(beatles_rev,Fs);
wavwrite(beatles_rev,Fs,'beatles_rev.wav');