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.


% Shweta Saxena
% ECE 301
% Hail Purdue Chorus

clc;

A=220;

B=247;

C=261.94;

Db=277;

D=294;

E=329.77;

F=349.13;

Gb=370;

G=392;

delta=0.0005;

stop=0.4;

notes=[A,B,C,Db,D,E,Gb,gB,G,G,D,E,F,Gb];

t=0:delta:stop;

for i=length(notes)

   x=sin(2*pi*t*notes(i));

sound(x,i/delta); end

pause(4);


% to play the song twice as fast for T=1:length(notes);

   t=0:delta:.5*lenght(notes(T));
   Y=sin(2*pi*t*notes(T));
   sound(Y,1/delta);

end

pause(4); % to play the song with double frequency for T=1:length(notes)

   t=0:delta:length(notes(T));
   Z=(sin(2*2*pi*t*notes(T))
   sound(Z,1/delta)

end

Alumni Liaison

Basic linear algebra uncovers and clarifies very important geometry and algebra.

Dr. Paul Garrett