(New page: %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 possib...)
 
 
Line 1: Line 1:
%Jamis Martin
+
%Jamis Martin<br>
%ECE301 HW1 #4 (a)
+
%ECE301 HW1 #4 (a)<br>
%Super Mario Bros. Theme Song
+
%Super Mario Bros. Theme Song<br>
 
+
<br>
%Actual note frequencies can be found at
+
%Actual note frequencies can be found at<br>
%http://www.seventhstring.com/resources/notefrequencies.html
+
%http://www.seventhstring.com/resources/notefrequencies.html<br>
 
+
<br>
%Defining some possible note frequencies (in Hz).
+
%Defining some possible note frequencies (in Hz).<br>
%Values/equations were either given or interpreted
+
%Values/equations were either given or interpreted<br>
%from Table 1 in the problem.
+
%from Table 1 in the problem.<br>
 
+
<br>
%Middle Notes (Calculated from Table 1)
+
%Middle Notes (Calculated from Table 1)<br>
A_Middle = 440; %Given in the problem
+
A_Middle = 440; %Given in the problem<br>
C_Middle = A_Middle * (3/5);
+
C_Middle = A_Middle * (3/5);<br>
B_Middle = C_Middle * (15/8);
+
B_Middle = C_Middle * (15/8);<br>
G_Middle = C_Middle * (3/2);
+
G_Middle = C_Middle * (3/2);<br>
F_Middle = C_Middle * (4/3);
+
F_Middle = C_Middle * (4/3);<br>
E_Middle = C_Middle * (5/4);
+
E_Middle = C_Middle * (5/4);<br>
D_Middle = C_Middle * (9/8);
+
D_Middle = C_Middle * (9/8);<br>
 
+
<br>
%Lower Notes (Half the middle notes)
+
%Lower Notes (Half the middle notes)<br>
B_Lower = B_Middle / 2;
+
B_Lower = B_Middle / 2;<br>
A_Lower = A_Middle / 2;
+
A_Lower = A_Middle / 2;<br>
G_Lower = G_Middle / 2;
+
G_Lower = G_Middle / 2;<br>
F_Lower = F_Middle / 2;
+
F_Lower = F_Middle / 2;<br>
E_Lower = E_Middle / 2;
+
E_Lower = E_Middle / 2;<br>
D_Lower = D_Middle / 2;
+
D_Lower = D_Middle / 2;<br>
 
+
<br>
%High Notes (Twice the middle notes)
+
%High Notes (Twice the middle notes)<br>
C_High = C_Middle * 2;
+
C_High = C_Middle * 2;<br>
B_High = B_Middle * 2;
+
B_High = B_Middle * 2;<br>
A_High = A_Middle * 2;
+
A_High = A_Middle * 2;<br>
G_High = G_Middle * 2;
+
G_High = G_Middle * 2;<br>
F_High = F_Middle * 2;
+
F_High = F_Middle * 2;<br>
E_High = E_Middle * 2;
+
E_High = E_Middle * 2;<br>
D_High = D_Middle * 2;
+
D_High = D_Middle * 2;<br>
 
+
<br>
%Sharp Notes
+
%Sharp Notes<br>
A_Sharp_Lower = 233.08; %Given by instructor on Rhea website
+
A_Sharp_Lower = 233.08; %Given by instructor on Rhea website<br>
 
+
<br>
%Defining different note durations for a clearer song
+
%Defining different note durations for a clearer song<br>
 
+
<br>
delta = 0.0001; %Time increment
+
delta = 0.0001; %Time increment<br>
 
+
<br>
t_full = 0:delta:1; %Full note - 1.0 sec duration
+
t_full = 0:delta:1; %Full note - 1.0 sec duration<br>
t_half = 0:delta:0.5; %Half note - 0.5 sec duration
+
t_half = 0:delta:0.5; %Half note - 0.5 sec duration<br>
t_quart = 0:delta:0.25; %Quarter note - 0.25 sec duration
+
t_quart = 0:delta:0.25; %Quarter note - 0.25 sec duration<br>
t_eigth = 0:delta:0.125; %Eigth note - 0.125 sec duration
+
t_eigth = 0:delta:0.125; %Eigth note - 0.125 sec duration<br>
t_sixtnth = 0:delta:0.0625; %Sixteenth note - 0.0625 sec duration
+
t_sixtnth = 0:delta:0.0625; %Sixteenth note - 0.0625 sec duration<br>
 
+
<br>
%Start to play the song
+
%Start to play the song<br>
%E, E, E, G, C, E, G, C, Glower, Elower, Alower, Blower, A#lower, Alower
+
%E, E, E, G, C, E, G, C, Glower, Elower, Alower, Blower, A#lower, Alower<br>
 
+
<br>
%E_Middle
+
%E_Middle<br>
smb = sin(2*pi*E_Middle*t_quart);
+
smb = sin(2*pi*E_Middle*t_quart);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%E_Middle
+
%E_Middle<br>
smb = sin(2*pi*E_Middle*t_eigth);
+
smb = sin(2*pi*E_Middle*t_eigth);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%E_Middle
+
%E_Middle<br>
smb = sin(2*pi*E_Middle*t_quart);
+
smb = sin(2*pi*E_Middle*t_quart);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%G_Middle
+
%G_Middle<br>
smb = sin(2*pi*G_Middle*t_quart);
+
smb = sin(2*pi*G_Middle*t_quart);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%C_Middle
+
%C_Middle<br>
smb = sin(2*pi*C_Middle*t_eigth);
+
smb = sin(2*pi*C_Middle*t_eigth);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%E_Middle
+
%E_Middle<br>
smb = sin(2*pi*E_Middle*t_quart);
+
smb = sin(2*pi*E_Middle*t_quart);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%G_Middle
+
%G_Middle<br>
smb = sin(2*pi*G_Middle*t_half);
+
smb = sin(2*pi*G_Middle*t_half);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%C_Middle
+
%C_Middle<br>
smb = sin(2*pi*C_Middle*t_quart);
+
smb = sin(2*pi*C_Middle*t_quart);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%G_Lower
+
%G_Lower<br>
smb = sin(2*pi*G_Lower*t_eigth);
+
smb = sin(2*pi*G_Lower*t_eigth);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%E_Lower
+
%E_Lower<br>
smb = sin(2*pi*E_Lower*t_quart);
+
smb = sin(2*pi*E_Lower*t_quart);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%A_Lower
+
%A_Lower<br>
smb = sin(2*pi*A_Lower*t_quart);
+
smb = sin(2*pi*A_Lower*t_quart);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%B_Lower
+
%B_Lower<br>
smb = sin(2*pi*B_Lower*t_eigth);
+
smb = sin(2*pi*B_Lower*t_eigth);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%A_Sharp_Lower
+
%A_Sharp_Lower<br>
smb = sin(2*pi*A_Sharp_Lower*t_eigth);
+
smb = sin(2*pi*A_Sharp_Lower*t_eigth);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 
+
<br>
%A_Lower
+
%A_Lower<br>
smb = sin(2*pi*A_Lower*t_quart);
+
smb = sin(2*pi*A_Lower*t_quart);<br>
sound(smb, 1/delta);
+
sound(smb, 1/delta);<br>
 +
<br>

Latest revision as of 02:42, 25 June 2009

%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

EISL lab graduate

Mu Qiao