%Jamis Martin
%ECE301 HW1 #4 (a)
%Super Mario Bros. Theme Song

%Actual note frequencies can be found at
%http://www.seventhstring.com/resources/notefrequencies.html

%Defining some possible note frequencies (in Hz).
%Values/equations were either given or interpreted
%from Table 1 in the problem.

%Middle Notes (Calculated from Table 1)
A_Middle = 440; %Given in the problem
C_Middle = A_Middle * (3/5);
B_Middle = C_Middle * (15/8);
G_Middle = C_Middle * (3/2);
F_Middle = C_Middle * (4/3);
E_Middle = C_Middle * (5/4);
D_Middle = C_Middle * (9/8);

%Lower Notes (Half the middle notes)
B_Lower = B_Middle / 2;
A_Lower = A_Middle / 2;
G_Lower = G_Middle / 2;
F_Lower = F_Middle / 2;
E_Lower = E_Middle / 2;
D_Lower = D_Middle / 2;

%High Notes (Twice the middle notes)
C_High = C_Middle * 2;
B_High = B_Middle * 2;
A_High = A_Middle * 2;
G_High = G_Middle * 2;
F_High = F_Middle * 2;
E_High = E_Middle * 2;
D_High = D_Middle * 2;

%Sharp Notes
A_Sharp_Lower = 233.08; %Given by instructor on Rhea website

%Defining different note durations for a clearer song

delta = 0.0001; %Time increment

t_full = 0:delta:1; %Full note - 1.0 sec duration
t_half = 0:delta:0.5; %Half note - 0.5 sec duration
t_quart = 0:delta:0.25; %Quarter note - 0.25 sec duration
t_eigth = 0:delta:0.125; %Eigth note - 0.125 sec duration
t_sixtnth = 0:delta:0.0625; %Sixteenth note - 0.0625 sec duration

%Start to play the song
%E, E, E, G, C, E, G, C, Glower, Elower, Alower, Blower, A#lower, Alower

%E_Middle
smb = sin(2*pi*E_Middle*t_quart);
sound(smb, 1/delta);

%E_Middle
smb = sin(2*pi*E_Middle*t_eigth);
sound(smb, 1/delta);

%E_Middle
smb = sin(2*pi*E_Middle*t_quart);
sound(smb, 1/delta);

%G_Middle
smb = sin(2*pi*G_Middle*t_quart);
sound(smb, 1/delta);

%C_Middle
smb = sin(2*pi*C_Middle*t_eigth);
sound(smb, 1/delta);

%E_Middle
smb = sin(2*pi*E_Middle*t_quart);
sound(smb, 1/delta);

%G_Middle
smb = sin(2*pi*G_Middle*t_half);
sound(smb, 1/delta);

%C_Middle
smb = sin(2*pi*C_Middle*t_quart);
sound(smb, 1/delta);

%G_Lower
smb = sin(2*pi*G_Lower*t_eigth);
sound(smb, 1/delta);

%E_Lower
smb = sin(2*pi*E_Lower*t_quart);
sound(smb, 1/delta);

%A_Lower
smb = sin(2*pi*A_Lower*t_quart);
sound(smb, 1/delta);

%B_Lower
smb = sin(2*pi*B_Lower*t_eigth);
sound(smb, 1/delta);

%A_Sharp_Lower
smb = sin(2*pi*A_Sharp_Lower*t_eigth);
sound(smb, 1/delta);

%A_Lower
smb = sin(2*pi*A_Lower*t_quart);
sound(smb, 1/delta);

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood