(New page: 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]; %ha...)
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Matlab Code:
+
Matlab Code:  
  
%ECE 301
+
<br>
%Homework 1
+
%Josh O'Meara
+
  
 +
%ECE 301<br>%Homework 1<br>%Josh O'Meara
  
%%%% PART 1 %%%%%
+
<br>
  
%ORIGINAL%
+
<br>%%%% PART 1&nbsp;%%%%%
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
+
%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
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];
+
%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
sound(smoke_original, 1/delta)
+
wavwrite(smoke_original, 1/delta, 'HW1_1a.wav')
+
pause(8)
+
  
%TWICE AS FAST%
+
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)  
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
+
%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
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];
+
%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
sound(smoke_fast, 1/delta)
+
wavwrite(smoke_fast, 1/delta, 'HW1_1b.wav')
+
pause(8)
+
  
 +
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)
  
%HIGHER PITCH%
+
<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  
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
+
%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  
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];
+
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)  
sound(smoke_high, 1/delta)
+
wavwrite(smoke_high, 1/delta, 'HW1_1c.wav')
+
pause(15)
+
  
 +
<br>%%%%PART 2%%%%
  
%%%%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>
  
[Beatles, Fs] = wavread('Beatles.wav');
+
<br>
sound(Beatles, Fs)
+
pause(8)
+
sound(flipud(Beatles), Fs)
+
wavwrite(flipud(Beatles), Fs, 'Beatles_Reverse.wav')
+
  
 +
Sound Files:
  
 +
[[Media:HW1_1a.wav]]
  
Sound Files:
+
[[Media:HW1_1b.wav]]
  
[[Media:HW1_1a.wav]]
+
[[Media:HW1_1c.wav]]  
[[Media:HW1_1b.wav]]
+
 
[[Media:HW1_1c.wav]]
+
[[Media:Beatles_Reverse.wav]]  
[[Media:Beatles_Reverse.wav]]
+
 
 +
<br>
 +
 
 +
The forward repeated phrase is "Number 9"
 +
 
 +
Backwards it sounds like "Turn me on dead man"

Latest revision as of 12: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

Recent Math PhD now doing a post-doctorate at UC Riverside.

Kuei-Nuan Lin