(New page: % Shweta Saxena % ECE 301 %Registration number: 00224-61047 % Hail Purdue Chorus clc; close; A=220; B=247; C=261.94; Db=277; D=294; E=329.77; F=349.13; Gb=370; G=392; delta=0.0...) |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | + | =[[Homework_1_ECE301Fall2008mboutin|HW1]], [[ECE301]], Prof. [[user:mboutin|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; | A=220; | ||
Line 26: | Line 28: | ||
delta=0.0005; | delta=0.0005; | ||
+ | |||
stop=0.4; | stop=0.4; | ||
+ | |||
notes=[A,B,C,Db,D,E,Gb,gB,G,G,D,E,F,Gb]; | notes=[A,B,C,Db,D,E,Gb,gB,G,G,D,E,F,Gb]; | ||
+ | |||
t=0:delta:stop; | t=0:delta:stop; | ||
+ | |||
for i=length(notes) | for i=length(notes) | ||
x=sin(2*pi*t*notes(i)); | x=sin(2*pi*t*notes(i)); | ||
Line 35: | Line 41: | ||
pause(4); | pause(4); | ||
+ | |||
+ | |||
% to play the song twice as fast | % to play the song twice as fast | ||
for T=1:length(notes); | for T=1:length(notes); | ||
Line 42: | Line 50: | ||
end | end | ||
− | pause(4) | + | pause(4); |
% to play the song with double frequency | % to play the song with double frequency | ||
for T=1:length(notes) | for T=1:length(notes) |
Latest revision as of 09:03, 27 August 2010
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