Line 1: Line 1:
 
Matlab Code:  
 
Matlab Code:  
  
 +
<br>
  
 +
%ECE 301<br>%Homework 1<br>%Josh O'Meara
  
%ECE 301<br>%Homework 1<br>%Josh O'Meara
+
<br>  
  
 +
<br>%%%% PART 1&nbsp;%%%%%
  
 +
%ORIGINAL%<br>BPM = 112;&nbsp;%beats per minute<br>BPS = 112/60;&nbsp;%beats per second<br>delta = 0.00005; <br>H = [0:delta:(1/BPS)*2];&nbsp;%half note<br>Q = [0:delta:(1/BPS)];&nbsp;%quarter note<br>E = [0:delta:(1/BPS)/2];&nbsp;%eigth note<br>DQ = [0:delta:(1/BPS)*3/2];&nbsp;%dotted quarter note
  
<br>%%%% PART 1 %%%%%
+
%The following notes are needed to play Smoke on the Water<br>Q_G = sin(2*pi*2^(-1/6)*440*Q);&nbsp;%quarter G<br>Q_Bf = sin(2*pi*2^(1/12)*440*Q);&nbsp;%quarter B flat<br>DQ_C = sin(2*pi*2^(1/4)*440*DQ);&nbsp;%dotted quarter C<br>E_Df = sin(2*pi*2^(1/3)*440*E);&nbsp;%eigth D flat<br>H_C = sin(2*pi*2^(1/4)*440*H);&nbsp;%half C
  
%ORIGINAL%<br>BPM = 112; %beats per minute<br>BPS = 112/60; %beats per second<br>delta = 0.00005; <br>H = [0:delta:(1/BPS)*2]; %half note<br>Q = [0:delta:(1/BPS)]; %quarter note<br>E = [0:delta:(1/BPS)/2]; %eigth note<br>DQ = [0:delta:(1/BPS)*3/2]; %dotted quarter note
+
smoke_original = [Q_G, Q_Bf, DQ_C, Q_G, Q_Bf, E_Df, H_C, Q_G, Q_Bf, DQ_C, Q_Bf, Q_G];<br>sound(smoke_original, 1/delta)<br>wavwrite(smoke_original, 1/delta, 'HW1_1a.wav')<br>pause(8)  
  
%The following notes are needed to play Smoke on the Water<br>Q_G = sin(2*pi*2^(-1/6)*440*Q); %quarter G<br>Q_Bf = sin(2*pi*2^(1/12)*440*Q); %quarter B flat<br>DQ_C = sin(2*pi*2^(1/4)*440*DQ); %dotted quarter C<br>E_Df = sin(2*pi*2^(1/3)*440*E); %eigth D flat<br>H_C = sin(2*pi*2^(1/4)*440*H); %half C
+
%TWICE AS FAST%<br>delta = 0.00005; <br>H = [0:delta:0.5*(1/BPS)*2];&nbsp;%half note<br>Q = [0:delta:0.5*(1/BPS)];&nbsp;%quarter note<br>E = [0:delta:0.5*(1/BPS)/2];&nbsp;%eigth note<br>DQ = [0:delta:0.5*(1/BPS)*3/2];&nbsp;%dotted quarter note
  
smoke_original = [Q_G, Q_Bf, DQ_C, Q_G, Q_Bf, E_Df, H_C, Q_G, Q_Bf, DQ_C, Q_Bf, Q_G];<br>sound(smoke_original, 1/delta)<br>wavwrite(smoke_original, 1/delta, 'HW1_1a.wav')<br>pause(8)
+
%Notes<br>Q_G = sin(2*pi*2^(-1/6)*440*Q);&nbsp;%quarter G<br>Q_Bf = sin(2*pi*2^(1/12)*440*Q);&nbsp;%quarter B flat<br>DQ_C = sin(2*pi*2^(1/4)*440*DQ);&nbsp;%dotted quarter C<br>E_Df = sin(2*pi*2^(1/3)*440*E);&nbsp;%eigth D flat<br>H_C = sin(2*pi*2^(1/4)*440*H);&nbsp;%half C
  
%TWICE AS FAST%<br>delta = 0.00005; <br>H = [0:delta:0.5*(1/BPS)*2]; %half note<br>Q = [0:delta:0.5*(1/BPS)]; %quarter note<br>E = [0:delta:0.5*(1/BPS)/2]; %eigth note<br>DQ = [0:delta:0.5*(1/BPS)*3/2]; %dotted quarter note
+
smoke_fast = [Q_G, Q_Bf, DQ_C, Q_G, Q_Bf, E_Df, H_C, Q_G, Q_Bf, DQ_C, Q_Bf, Q_G];<br>sound(smoke_fast, 1/delta)<br>wavwrite(smoke_fast, 1/delta, 'HW1_1b.wav')<br>pause(8)  
  
%Notes<br>Q_G = sin(2*pi*2^(-1/6)*440*Q); %quarter G<br>Q_Bf = sin(2*pi*2^(1/12)*440*Q); %quarter B flat<br>DQ_C = sin(2*pi*2^(1/4)*440*DQ); %dotted quarter C<br>E_Df = sin(2*pi*2^(1/3)*440*E); %eigth D flat<br>H_C = sin(2*pi*2^(1/4)*440*H); %half C
+
<br>%HIGHER PITCH%<br>delta = 0.00005; <br>H = [0:delta:(1/BPS)*2];&nbsp;%half note<br>Q = [0:delta:(1/BPS)];&nbsp;%quarter note<br>E = [0:delta:(1/BPS)/2];&nbsp;%eigth note<br>DQ = [0:delta:(1/BPS)*3/2];&nbsp;%dotted quarter note
  
smoke_fast = [Q_G, Q_Bf, DQ_C, Q_G, Q_Bf, E_Df, H_C, Q_G, Q_Bf, DQ_C, Q_Bf, Q_G];<br>sound(smoke_fast, 1/delta)<br>wavwrite(smoke_fast, 1/delta, 'HW1_1b.wav')<br>pause(8)
+
%Notes<br>Q_G = sin(2*2*pi*2^(-1/6)*440*Q);&nbsp;%quarter G<br>Q_Bf = sin(2*2*pi*2^(1/12)*440*Q);&nbsp;%quarter B flat<br>DQ_C = sin(2*2*pi*2^(1/4)*440*DQ);&nbsp;%dotted quarter C<br>E_Df = sin(2*2*pi*2^(1/3)*440*E);&nbsp;%eigth D flat<br>H_C = sin(2*2*pi*2^(1/4)*440*H);&nbsp;%half C
  
<br>%HIGHER PITCH%<br>delta = 0.00005; <br>H = [0:delta:(1/BPS)*2]; %half note<br>Q = [0:delta:(1/BPS)]; %quarter note<br>E = [0:delta:(1/BPS)/2]; %eigth note<br>DQ = [0:delta:(1/BPS)*3/2]; %dotted quarter note
+
smoke_high = [Q_G, Q_Bf, DQ_C, Q_G, Q_Bf, E_Df, H_C, Q_G, Q_Bf, DQ_C, Q_Bf, Q_G];<br>sound(smoke_high, 1/delta)<br>wavwrite(smoke_high, 1/delta, 'HW1_1c.wav')<br>pause(15)  
  
%Notes<br>Q_G = sin(2*2*pi*2^(-1/6)*440*Q); %quarter G<br>Q_Bf = sin(2*2*pi*2^(1/12)*440*Q); %quarter B flat<br>DQ_C = sin(2*2*pi*2^(1/4)*440*DQ); %dotted quarter C<br>E_Df = sin(2*2*pi*2^(1/3)*440*E); %eigth D flat<br>H_C = sin(2*2*pi*2^(1/4)*440*H); %half C
+
<br>%%%%PART 2%%%%
  
smoke_high = [Q_G, Q_Bf, DQ_C, Q_G, Q_Bf, E_Df, H_C, Q_G, Q_Bf, DQ_C, Q_Bf, Q_G];<br>sound(smoke_high, 1/delta)<br>wavwrite(smoke_high, 1/delta, 'HW1_1c.wav')<br>pause(15)
+
[Beatles, Fs] = wavread('Beatles.wav');<br>sound(Beatles, Fs)<br>pause(8)<br>sound(flipud(Beatles), Fs)<br>wavwrite(flipud(Beatles), Fs, 'Beatles_Reverse.wav')<br>  
 
+
<br>%%%%PART 2%%%%
+
 
+
[Beatles, Fs] = wavread('Beatles.wav');<br>sound(Beatles, Fs)<br>pause(8)<br>sound(flipud(Beatles), Fs)<br>wavwrite(flipud(Beatles), Fs, 'Beatles_Reverse.wav')<br>
+
  
 
<br>  
 
<br>  
Line 39: Line 39:
 
[[Media:HW1_1b.wav]]  
 
[[Media:HW1_1b.wav]]  
  
[[Media:HW1_1c.wav]] [[Media:Beatles_Reverse.wav|Beatles_Reverse.wav]]
+
[[Media:HW1_1c.wav]]  
  
 
[[Media:Beatles_Reverse.wav]]  
 
[[Media:Beatles_Reverse.wav]]  
  
 +
<br>
  
 
+
The forward repeated phrase is "Number 9"  
The forward repeated phrase is "Number 9"
+
  
 
Backwards it sounds like "Turn me on dead man"
 
Backwards it sounds like "Turn me on dead man"

Latest revision as of 11:31, 18 January 2011

Matlab Code:


%ECE 301
%Homework 1
%Josh O'Meara



%%%% PART 1 %%%%%

%ORIGINAL%
BPM = 112; %beats per minute
BPS = 112/60; %beats per second
delta = 0.00005;
H = [0:delta:(1/BPS)*2]; %half note
Q = [0:delta:(1/BPS)]; %quarter note
E = [0:delta:(1/BPS)/2]; %eigth note
DQ = [0:delta:(1/BPS)*3/2]; %dotted quarter note

%The following notes are needed to play Smoke on the Water
Q_G = sin(2*pi*2^(-1/6)*440*Q); %quarter G
Q_Bf = sin(2*pi*2^(1/12)*440*Q); %quarter B flat
DQ_C = sin(2*pi*2^(1/4)*440*DQ); %dotted quarter C
E_Df = sin(2*pi*2^(1/3)*440*E); %eigth D flat
H_C = sin(2*pi*2^(1/4)*440*H); %half C

smoke_original = [Q_G, Q_Bf, DQ_C, Q_G, Q_Bf, E_Df, H_C, Q_G, Q_Bf, DQ_C, Q_Bf, Q_G];
sound(smoke_original, 1/delta)
wavwrite(smoke_original, 1/delta, 'HW1_1a.wav')
pause(8)

%TWICE AS FAST%
delta = 0.00005;
H = [0:delta:0.5*(1/BPS)*2]; %half note
Q = [0:delta:0.5*(1/BPS)]; %quarter note
E = [0:delta:0.5*(1/BPS)/2]; %eigth note
DQ = [0:delta:0.5*(1/BPS)*3/2]; %dotted quarter note

%Notes
Q_G = sin(2*pi*2^(-1/6)*440*Q); %quarter G
Q_Bf = sin(2*pi*2^(1/12)*440*Q); %quarter B flat
DQ_C = sin(2*pi*2^(1/4)*440*DQ); %dotted quarter C
E_Df = sin(2*pi*2^(1/3)*440*E); %eigth D flat
H_C = sin(2*pi*2^(1/4)*440*H); %half C

smoke_fast = [Q_G, Q_Bf, DQ_C, Q_G, Q_Bf, E_Df, H_C, Q_G, Q_Bf, DQ_C, Q_Bf, Q_G];
sound(smoke_fast, 1/delta)
wavwrite(smoke_fast, 1/delta, 'HW1_1b.wav')
pause(8)


%HIGHER PITCH%
delta = 0.00005;
H = [0:delta:(1/BPS)*2]; %half note
Q = [0:delta:(1/BPS)]; %quarter note
E = [0:delta:(1/BPS)/2]; %eigth note
DQ = [0:delta:(1/BPS)*3/2]; %dotted quarter note

%Notes
Q_G = sin(2*2*pi*2^(-1/6)*440*Q); %quarter G
Q_Bf = sin(2*2*pi*2^(1/12)*440*Q); %quarter B flat
DQ_C = sin(2*2*pi*2^(1/4)*440*DQ); %dotted quarter C
E_Df = sin(2*2*pi*2^(1/3)*440*E); %eigth D flat
H_C = sin(2*2*pi*2^(1/4)*440*H); %half C

smoke_high = [Q_G, Q_Bf, DQ_C, Q_G, Q_Bf, E_Df, H_C, Q_G, Q_Bf, DQ_C, Q_Bf, Q_G];
sound(smoke_high, 1/delta)
wavwrite(smoke_high, 1/delta, 'HW1_1c.wav')
pause(15)


%%%%PART 2%%%%

[Beatles, Fs] = wavread('Beatles.wav');
sound(Beatles, Fs)
pause(8)
sound(flipud(Beatles), Fs)
wavwrite(flipud(Beatles), Fs, 'Beatles_Reverse.wav')


Sound Files:

Media:HW1_1a.wav

Media:HW1_1b.wav

Media:HW1_1c.wav

Media:Beatles_Reverse.wav


The forward repeated phrase is "Number 9"

Backwards it sounds like "Turn me on dead man"

Alumni Liaison

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

Dr. Paul Garrett