(Matlab Code)
(Matlab Code)
Line 30: Line 30:
 
%First few notes of the chorus
 
%First few notes of the chorus
 
chorus = [A, B, Db, D, E, Gb, Gb, G, G, G, D, E, F, Gb];  
 
chorus = [A, B, Db, D, E, Gb, Gb, G, G, G, D, E, F, Gb];  
 +
 +
delta  = 0.0005;
  
 
%Part a
 
%Part a
 
endTime = 0.4;
 
endTime = 0.4;
delta  = 0.0005;
 
 
t = [0 : delta : endTime];
 
t = [0 : delta : endTime];
  
Line 43: Line 44:
 
%Part b
 
%Part b
 
endTime = endTime / 2;
 
endTime = endTime / 2;
delta  = 0.0005;
 
 
t = 0 : delta : endTime;
 
t = 0 : delta : endTime;
  
Line 53: Line 53:
 
%Part c
 
%Part c
 
endTime = 0.4;
 
endTime = 0.4;
delta  = 0.0005;
 
 
t = 0 : delta : endTime;
 
t = 0 : delta : endTime;
  

Revision as of 11:33, 4 September 2008

Matlab Code

%{
  Homework #1
  Problem 1
  Jeremiah Wise

  This Program plays the first portion of the corus "Hail Purdue".
  It first plats at a norlal speed then plays 2 times that speed.
  On the third trial in is played at the original speed in the next
  octave higher.
%}

%Frequencies associated with each note
A   = 220;
Bb  = 233.082;
B   = 246.942;
C   = 261.626;
Db  = 277.183;
D   = 293.665;
Eb  = 311.127;
E   = 329.628;
F   = 349.228;
Gb = 369.994;
G   = 391.995;
Ab  = 415.305;

%First few notes of the chorus
chorus = [A, B, Db, D, E, Gb, Gb, G, G, G, D, E, F, Gb]; 

delta   = 0.0005;

%Part a
endTime = 0.4;
t = [0 : delta : endTime];

for i = 1 : length(chorus)
  note = sin(2 * pi * t * chorus(i));
  sound(note, 1/delta);
end

%Part b
endTime = endTime / 2;
t = 0 : delta : endTime;

for i = 1 : length(chorus)
  note = sin(2 * pi * t * chorus(i));
  sound(note, 1/delta);
end

%Part c
endTime = 0.4;
t = 0 : delta : endTime;

for i = 1 : length(chorus)
  note = sin(4 * pi * t * chorus(i));
  sound(note, 1/delta);
end

Alumni Liaison

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

Dr. Paul Garrett