Revision as of 13:02, 24 June 2009 by Nkgentry (Talk | contribs)

WAV FILE: Media:Mario_Nick_Gentry.wav‎

%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

ECE462 Survivor

Seraj Dosenbach