(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Matlab Code ==
+
<pre>
% Homework 1.1 Hail Purdue
+
% Homework 1.1 Hail Purdue
%David Record
+
%David Record
%September 3rd 2008
+
%September 3rd 2008
  
%%Song Notes and Lyrics:
+
%%Song Notes and Lyrics:
%%http://www.purdue.edu/bands/media/Sounds/aamb/Hail%20Purdue%20Piano%20Sheet.pdf
+
%%http://www.purdue.edu/bands/media/Sounds/aamb/Hail%20Purdue%20Piano%20Sheet.pdf
  
%Lyrics
+
%Lyrics
%Hail, to Old Purdue, All hail to our gold and black!
+
%Hail, to Old Purdue, All hail to our gold and black!
  
%Notes:
+
%Notes:
%E, F, G, A_, B_, C5, D5_, B
+
%E, F, G, A_, B_, C5, D5_, B
  
%Corresponding Frequencies: http://www.phy.mtu.edu/~suits/notefreqs.html
+
%Corresponding Frequencies: http://www.phy.mtu.edu/~suits/notefreqs.html
E  = 311.13; %HZ
+
E  = 311.13; %HZ
F  = 349.23; %HZ
+
F  = 349.23; %HZ
G  = 392.00; %HZ
+
G  = 392.00; %HZ
A_  = 415.30; %HZ
+
A_  = 415.30; %HZ
B_  = 466.16; %HZ
+
B_  = 466.16; %HZ
C5  = 523.25; %HZ
+
C5  = 523.25; %HZ
D5_ = 554.37; %HZ
+
D5_ = 554.37; %HZ
B  = 493.3;  %HZ
+
B  = 493.3;  %HZ
  
%Durations
+
%Durations
delta = 0.00005; %As defined in class
+
delta = 0.00005; %As defined in class
quarter = .25;  %Quarter Note
+
quarter = .25;  %Quarter Note
half = .5;      %Half Note
+
half = .5;      %Half Note
whole = 1;      %Whole Note
+
whole = 1;      %Whole Note
eigth = .125;  %Eighth Note
+
eigth = .125;  %Eighth Note
  
notes = [E, F, G, A_, B_, C5, C5, D5_, D5_, D5_, A_, B_, B, C5];
+
notes = [E, F, G, A_, B_, C5, C5, D5_, D5_, D5_, A_, B_, B, C5];
durations = [half, quarter, quarter, (quarter+eighth), eighth, quarter, quarter, quarter, eighth, eighth, quarter, eigth, eigth, (half+quarter) ];
+
durations = [half, quarter, quarter, (quarter+eighth), eighth, quarter, quarter, quarter, eighth, eighth, quarter, eigth, eigth, (half+quarter) ];
  
 +
%%% Song Unaltered %%%
 +
for counter = 1: length(notes)
 +
    t = 0:delta:durations(counter);
 +
    y = sin(2*pi*notes(counter)*t);
 +
    sound (y, 1/delta);
 +
end
  
x=1;
+
%%% Twice as Fast %%%
for counter = 1: length(notes)
+
for counter = 1: length(notes)
    t = 0:delta:durations(counter);
+
    t = 0:delta:durations(counter)/2;
    y = sin(2*pi*notes(counter)*t);
+
    y = sin(2*pi*notes(counter)*t);
    sound (y, 1/delta);
+
    sound (y, 1/delta);
 +
end
  
end
+
%%% y(t) = x(2t) %%% Doubles the Frequency of the notes
 +
for counter = 1: length(notes)
 +
    t = 0:delta:durations(counter);
 +
    y = sin(2*pi*notes(counter)*t*2);
 +
    sound (y, 1/delta);
 +
end
 +
</pre>
 +
[[Media:HailPurduex3_ECE301Fall2008mboutin.wav]]

Latest revision as of 07:04, 5 September 2008

% Homework 1.1 Hail Purdue
%David Record
%September 3rd 2008

%%Song Notes and Lyrics:
%%http://www.purdue.edu/bands/media/Sounds/aamb/Hail%20Purdue%20Piano%20Sheet.pdf

%Lyrics
%Hail, to Old Purdue, All hail to our gold and black!

%Notes:
%E, F, G, A_, B_, C5, D5_, B

%Corresponding Frequencies: http://www.phy.mtu.edu/~suits/notefreqs.html
E   = 311.13; %HZ
F   = 349.23; %HZ
G   = 392.00; %HZ
A_  = 415.30; %HZ
B_  = 466.16; %HZ
C5  = 523.25; %HZ
D5_ = 554.37; %HZ
B   = 493.3;  %HZ

%Durations
delta = 0.00005; %As defined in class
quarter = .25;  %Quarter Note
half = .5;      %Half Note
whole = 1;      %Whole Note
eigth = .125;  %Eighth Note

notes = [E, F, G, A_, B_, C5, C5, D5_, D5_, D5_, A_, B_, B, C5];
durations = [half, quarter, quarter, (quarter+eighth), eighth, quarter, quarter, quarter, eighth, eighth, quarter, eigth, eigth, (half+quarter) ];

%%% Song Unaltered %%%
for counter = 1: length(notes)
    t = 0:delta:durations(counter);
    y = sin(2*pi*notes(counter)*t);
    sound (y, 1/delta);
end

%%% Twice as Fast %%%
for counter = 1: length(notes)
    t = 0:delta:durations(counter)/2;
    y = sin(2*pi*notes(counter)*t);
    sound (y, 1/delta);
end

%%% y(t) = x(2t) %%% Doubles the Frequency of the notes
for counter = 1: length(notes)
    t = 0:delta:durations(counter);
    y = sin(2*pi*notes(counter)*t*2);
    sound (y, 1/delta);
end

Media:HailPurduex3_ECE301Fall2008mboutin.wav

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood