HW1, ECE301, Prof. Boutin
In this homework assignment, we were asked to write a Matlab code to play the "Hail Purdue" song with different speeds and pitch.
%Amber Amber %ECE 301 %Hail Purdue Chorus
A=220; B=246.942 Db=277.18; D= 293.665 E=329.62; F=349.228; Gb=370; G=391.99; del=.00005 stop=.4 tunes=[A,B,Db,D,E,Gb,Gb,G,G,G,D,E,F,Gb]; t=0:delta:stop; for i=length(Notes)
Hail=sin(2*pi*t*Notes(i)); sound(Hail,1/delta);
end
pause(5);
%To play the song twice as fast
for T=1:length(Notes)
t=0:del:.5*length(tunes(T));%.5 is the scaling factor Hail_1=sin(2*pi*t*tunes(T)); sound(Hail_1,1/del);
end
pause(5);
%To play the song at double frequency
for T=1:length(tunes)
t=0:del:length(tunes(T)); Hail_2=sin(2*2*pi*t*tunes(T))%2 is the scaling here sound(Hail_2,1/del);
end