(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: |
− | + | <br> | |
− | + | ||
− | + | ||
+ | %ECE 301<br>%Homework 1<br>%Josh O'Meara | ||
− | + | <br> | |
− | % | + | <br>%%%% PART 1 %%%%% |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | % | + | %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 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | %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 | |
− | + | ||
− | + | ||
− | + | ||
− | + | 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) | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | % | + | %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 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | %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 | |
− | + | ||
− | + | ||
− | + | ||
+ | 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]; %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:(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); %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 |
− | 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%%%% | ||
− | + | [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: | ||
+ | [[Media:HW1_1a.wav]] | ||
− | + | [[Media:HW1_1b.wav]] | |
− | [[Media: | + | [[Media:HW1_1c.wav]] |
− | + | ||
− | [[Media: | + | [[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 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:
The forward repeated phrase is "Number 9"
Backwards it sounds like "Turn me on dead man"