Line 1: Line 1:
 +
== '''SOUND FILE:''' ==
 +
 +
 +
 
'''WAV FILE: [[Media:Mario_Nick_Gentry.wav‎]]'''
 
'''WAV FILE: [[Media:Mario_Nick_Gentry.wav‎]]'''
  
<code>
+
 
 +
----
 +
 
 +
== '''CODE:''' ==
 +
<font color="#006600">
 
%NICK GENTRY
 
%NICK GENTRY
 
%ECE301
 
%ECE301
 
%06/23/09
 
%06/23/09
 +
</font>
  
 
clc
 
clc
 
clear
 
clear
 
+
<font color="#006600">
 
%The frequencies (Hz) shown below were found on the NYU CS website:
 
%The frequencies (Hz) shown below were found on the NYU CS website:
 
%http://www.cs.nyu.edu/courses/fall03/V22.0201-003/notes.htm
 
%http://www.cs.nyu.edu/courses/fall03/V22.0201-003/notes.htm
 +
</font>
  
 
Clower = 262/2; CSharpLower = 277.18/2; D = 294/2; DSharp = 311/2; E = 330/2;  
 
Clower = 262/2; CSharpLower = 277.18/2; D = 294/2; DSharp = 311/2; E = 330/2;  
Line 27: Line 37:
 
a = 1.8;
 
a = 1.8;
  
%Note Lengths defined below:
+
<font color="#006600">%Note Lengths defined below:</font>
 
HLF = 0.50*a; QTR = 0.25*a; ETH = 0.125*a; SXT = 0.0625*a; ETHdot = 0.125*1.5*a; SXTdot = 0.0625*1.5*a;
 
HLF = 0.50*a; QTR = 0.25*a; ETH = 0.125*a; SXT = 0.0625*a; ETHdot = 0.125*1.5*a; SXTdot = 0.0625*1.5*a;
  
Line 36: Line 46:
 
noteLength = [SXT, ETH, SXT, SXT, SXT, ETH, QTR, QTR, ETHdot, SXT, ETH, ETH, SXT, ETH, SXT, SXT, SXT, ETH, SXTdot, SXTdot, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, ETH, ETHdot, SXT, ETH, ETH, SXT, ETH, SXT, SXT, ETH, SXTdot, SXTdot, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, ETHdot, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, ETH, SXT, ETH, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, ETH, ETH, SXT, ETH, QTR, QTR, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, SXT SXT, SXT, SXT, SXT, SXT, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, ETH, SXT];
 
noteLength = [SXT, ETH, SXT, SXT, SXT, ETH, QTR, QTR, ETHdot, SXT, ETH, ETH, SXT, ETH, SXT, SXT, SXT, ETH, SXTdot, SXTdot, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, ETH, ETHdot, SXT, ETH, ETH, SXT, ETH, SXT, SXT, ETH, SXTdot, SXTdot, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, ETHdot, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, ETH, SXT, ETH, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, ETH, ETH, SXT, ETH, QTR, QTR, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, SXT SXT, SXT, SXT, SXT, SXT, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, ETH, SXT];
  
numNotes = length(noteLength); %Number of notes to be played
+
numNotes = length(noteLength); <font color="#006600">%Number of notes to be played</font>
  
delta = 0.0001; %Sampling Rate
+
delta = 0.0001; <font color="#006600">%Sampling Rate</font>
x = 1; %Counter Value
+
x = 1; <font color="#006600">%Counter Value</font>
count1 = 1; %Used as counter for while loop.
+
count1 = 1; <font color="#006600">%Used as counter for while loop.</font>
 
%--------------------------------------------------------------------------
 
%--------------------------------------------------------------------------
 
%PART A
 
%PART A
 
%--------------------------------------------------------------------------
 
%--------------------------------------------------------------------------
 
while x<= numNotes;
 
while x<= numNotes;
     t1 = 0:delta:noteLength(x);     %Helps scale the length of notes
+
     t1 = 0:delta:noteLength(x); <font color="#006600">%Helps scale the length of notes</font>
     p1 = sin(2*pi*noteOrder(x)*t1); %Sound function
+
     p1 = sin(2*pi*noteOrder(x)*t1); <font color="#006600">%Sound function</font>
 
   
 
   
     count2 = 1; %While loop counter
+
     count2 = 1; <font color="#006600">%While loop counter</font>
     while count2<length(p1);  %Builds the array.
+
     while count2<length(p1);  <font color="#006600">%Builds the array.</font>
 
         writeArray1(count1) = p1(count2);
 
         writeArray1(count1) = p1(count2);
 
         count1 = count1 + 1;
 
         count1 = count1 + 1;
Line 55: Line 65:
 
     end
 
     end
 
          
 
          
     x = x + 1; %Increments the loop counter
+
     x = x + 1; <font color="#006600">%Increments the loop counter</font>
 
end
 
end
  
sound(writeArray1, 1/delta); %Plays sound file
+
sound(writeArray1, 1/delta); <font color="#006600">%Plays sound file</font>
wavwrite(writeArray1,'Mario_Nick_Gentry.wav'); %Creates a wav file of the sound
+
wavwrite(writeArray1,'Mario_Nick_Gentry.wav'); <font color="#006600">%Creates a wav file of the sound</font>
</code>
+
 
 +
 
 +
----

Revision as of 13:13, 24 June 2009

SOUND FILE:

WAV FILE: Media:Mario_Nick_Gentry.wav‎



CODE:

%NICK GENTRY %ECE301 %06/23/09

clc clear %The frequencies (Hz) shown below were found on the NYU CS website: %http://www.cs.nyu.edu/courses/fall03/V22.0201-003/notes.htm

Clower = 262/2; CSharpLower = 277.18/2; D = 294/2; DSharp = 311/2; E = 330/2; F = 349/2; FSharp = 370/2; G = 392/2; GSharp = 415/2; A = 440/2; ASharp = 466/2; B = 493.88/2;

C = 262; CSharp = 277.18; D = 294; DSharp = 311; E = 330; F = 349; FSharp = 370; G = 392; GSharp = 415; A = 440; ASharp = 466; B = 493.88; AFlat = 415.30;

Cupper = 262*2; CSharpUpper = 277.18*2; Dupper = 294*2; DSharpUpper = 311*2; Eupper = 330*2; Fupper = 349*2; FSharpUpper = 370*2; Gupper = 392*2; GSharpUpper = 415*2; Aupper = 440*2; ASharpUpper = 466*2; Bupper = 493.88*2;

CdblUpper = 262 * 4; a = 1.8;

%Note Lengths defined below: HLF = 0.50*a; QTR = 0.25*a; ETH = 0.125*a; SXT = 0.0625*a; ETHdot = 0.125*1.5*a; SXTdot = 0.0625*1.5*a;

%This is the array that makes up the notes played in the song:

noteOrder = [ Eupper, Eupper, Eupper, 0, Cupper, Eupper, Gupper, 0, Cupper, G, 0, E, 0, A, B, 0, ASharp, AFlat, G, Eupper, Gupper, Aupper, Fupper, Gupper, 0, Eupper, Cupper, Dupper, B, Cupper, G, 0, E, 0, A, B, 0, ASharp, A, G, Eupper, Gupper, Aupper, Fupper, Gupper, 0, Eupper, Cupper, Dupper, B, 0, Gupper, FSharpUpper, Fupper, D, E, 0, GSharp, A, Cupper, 0, A, Cupper, Dupper, 0, G, FSharpUpper, F, DSharpUpper, E, 0, CdblUpper, CdblUpper, CdblUpper, 0, Gupper, FSharpUpper, Fupper, DSharpUpper, Eupper, 0, GSharp, A, Cupper, 0, A, Cupper, Dupper, 0, DSharpUpper, 0, Dupper, Cupper, 0, 0, Gupper, FSharpUpper, Fupper, DSharpUpper, Eupper, 0, GSharp, A, Cupper, 0, A, Cupper, Dupper, 0, Gupper, FSharpUpper, Fupper, DSharp, E, 0, CdblUpper, CdblUpper, CdblUpper];

noteLength = [SXT, ETH, SXT, SXT, SXT, ETH, QTR, QTR, ETHdot, SXT, ETH, ETH, SXT, ETH, SXT, SXT, SXT, ETH, SXTdot, SXTdot, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, ETH, ETHdot, SXT, ETH, ETH, SXT, ETH, SXT, SXT, ETH, SXTdot, SXTdot, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, ETHdot, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, ETH, SXT, ETH, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, SXT, ETH, ETH, SXT, ETH, QTR, QTR, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, SXT SXT, SXT, SXT, SXT, SXT, SXT, ETH, SXT, SXT, SXT, ETH, SXT, SXT, SXT, ETH, SXT];

numNotes = length(noteLength); %Number of notes to be played

delta = 0.0001; %Sampling Rate x = 1; %Counter Value count1 = 1; %Used as counter for while loop. %-------------------------------------------------------------------------- %PART A %-------------------------------------------------------------------------- while x<= numNotes;

   t1 = 0:delta:noteLength(x); %Helps scale the length of notes
   p1 = sin(2*pi*noteOrder(x)*t1); %Sound function

   count2 = 1; %While loop counter
   while count2<length(p1);  %Builds the array.
       writeArray1(count1) = p1(count2);
       count1 = count1 + 1;
       count2 = count2 + 1;
   end
       
   x = x + 1; %Increments the loop counter

end

sound(writeArray1, 1/delta); %Plays sound file wavwrite(writeArray1,'Mario_Nick_Gentry.wav'); %Creates a wav file of the sound



Alumni Liaison

Prof. Math. Ohio State and Associate Dean
Outstanding Alumnus Purdue Math 2008

Jeff McNeal