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

Revision as of 11:30, 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 Beatles_Reverse.wav

Media:Beatles_Reverse.wav


The forward repeated phrase is "Number 9"

Backwards it sounds like "Turn me on dead man"

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn