Line 16: Line 16:
  
 
W=4*Q; % Whole note
 
W=4*Q; % Whole note
 +
 
En=Q/2; %Eighth note
 
En=Q/2; %Eighth note
 +
 
DQ=Q+En; %Dotted quarter
 
DQ=Q+En; %Dotted quarter
 +
  
 
%frequencies
 
%frequencies
 +
 
% A=440 = 5x/3 => x=264
 
% A=440 = 5x/3 => x=264
 +
 
% Middle C (do) = x = 264;
 
% Middle C (do) = x = 264;
 +
 
% D (re)=9x/8=297;
 
% D (re)=9x/8=297;
 +
 
% E (mi)=5x/4=330;
 
% E (mi)=5x/4=330;
 +
 
% F (fa)=4x/3=352;
 
% F (fa)=4x/3=352;
 +
 
% GL (so)=3x/2/2=198;
 
% GL (so)=3x/2/2=198;
 +
 
% AL (low la)=5x/3/2=220;
 
% AL (low la)=5x/3/2=220;
 +
 
% BL (low ti)=15x/8/2=247.5;
 
% BL (low ti)=15x/8/2=247.5;
  
 
C=264;
 
C=264;
 +
 
D=297;
 
D=297;
 +
 
E=330;
 
E=330;
 +
 
F=352;
 
F=352;
 +
 
GL=198;
 
GL=198;
 +
 
AL=220;
 
AL=220;
 +
 
BL=247.5;
 
BL=247.5;
  
  
 
notes = [GL,GL,AL,C,D,E,E,F,F,F,C,D,E,E,... %Hail, hail to old Purdue!All hail to our old gold and black!
 
notes = [GL,GL,AL,C,D,E,E,F,F,F,C,D,E,E,... %Hail, hail to old Purdue!All hail to our old gold and black!
 +
 
E,E,D,C,D,E,E,D,AL,BL,C,BL,AL,D,... %Hail, hail to old Purdue!Our friendship may she never lack,
 
E,E,D,C,D,E,E,D,AL,BL,C,BL,AL,D,... %Hail, hail to old Purdue!Our friendship may she never lack,
 +
 
GL,GL,GL,AL,C,D,E,E,F,F,C,D,E,... %Ever grateful ever true,Thus we raise our song anew,†
 
GL,GL,GL,AL,C,D,E,E,F,F,C,D,E,... %Ever grateful ever true,Thus we raise our song anew,†
 +
 
AL,BL,C,AL,GL,C,E,GL,AL,E,D,C,C]; %Of the days we've spent with you,All hail our own Purdue.
 
AL,BL,C,AL,GL,C,E,GL,AL,E,D,C,C]; %Of the days we've spent with you,All hail our own Purdue.
  
 
duration = [H,DQ,En,DQ,En,Q,Q,Q,En,En,Q,En,En,W,...  
 
duration = [H,DQ,En,DQ,En,Q,Q,Q,En,En,Q,En,En,W,...  
 +
 
H,DQ,En,DQ,En,Q,Q,Q,En,En,Q,En,En,W,...  
 
H,DQ,En,DQ,En,Q,Q,Q,En,En,Q,En,En,W,...  
 +
 
DQ,En,Q,Q,DQ,En,Q,Q,Q,Q,Q,Q,W,...
 
DQ,En,Q,Q,DQ,En,Q,Q,Q,Q,Q,Q,W,...
 +
 
DQ,En,Q,Q,Q,Q,Q,Q,DQ,En,DQ,En,W];
 
DQ,En,Q,Q,Q,Q,Q,Q,DQ,En,DQ,En,W];
  
 
% Play the song as what demonstrated in class
 
% Play the song as what demonstrated in class
 +
 
delta=0.00005;
 
delta=0.00005;
  
  
 
for n = 1:56
 
for n = 1:56
 +
 
t = 0:delta:duration(n);
 
t = 0:delta:duration(n);
 +
 
anthem = sin(2*pi*notes(n)*t);
 
anthem = sin(2*pi*notes(n)*t);
 +
 
sound(anthem, 1/delta);
 
sound(anthem, 1/delta);
 +
 
end
 
end

Revision as of 19:50, 4 September 2008

% Hail Purdue.

% XUJUN HUANG

% huang122@purdue.edu

% note durations.

% time signature = 4/4

% quarter note = 180bpm => quarter note duration is 60/180 minute.

Q=60/180;

H=2*Q; % Half note

W=4*Q; % Whole note

En=Q/2; %Eighth note

DQ=Q+En; %Dotted quarter


%frequencies

% A=440 = 5x/3 => x=264

% Middle C (do) = x = 264;

% D (re)=9x/8=297;

% E (mi)=5x/4=330;

% F (fa)=4x/3=352;

% GL (so)=3x/2/2=198;

% AL (low la)=5x/3/2=220;

% BL (low ti)=15x/8/2=247.5;

C=264;

D=297;

E=330;

F=352;

GL=198;

AL=220;

BL=247.5;


notes = [GL,GL,AL,C,D,E,E,F,F,F,C,D,E,E,... %Hail, hail to old Purdue!All hail to our old gold and black!

E,E,D,C,D,E,E,D,AL,BL,C,BL,AL,D,... %Hail, hail to old Purdue!Our friendship may she never lack,

GL,GL,GL,AL,C,D,E,E,F,F,C,D,E,... %Ever grateful ever true,Thus we raise our song anew,†

AL,BL,C,AL,GL,C,E,GL,AL,E,D,C,C]; %Of the days we've spent with you,All hail our own Purdue.

duration = [H,DQ,En,DQ,En,Q,Q,Q,En,En,Q,En,En,W,...

H,DQ,En,DQ,En,Q,Q,Q,En,En,Q,En,En,W,...

DQ,En,Q,Q,DQ,En,Q,Q,Q,Q,Q,Q,W,...

DQ,En,Q,Q,Q,Q,Q,Q,DQ,En,DQ,En,W];

% Play the song as what demonstrated in class

delta=0.00005;


for n = 1:56

t = 0:delta:duration(n);

anthem = sin(2*pi*notes(n)*t);

sound(anthem, 1/delta);

end

Alumni Liaison

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

Dr. Paul Garrett