Revision as of 12:31, 18 January 2011 by Jomeara (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Ph.D. on Applied Mathematics in Aug 2007. Involved on applications of image super-resolution to electron microscopy

Francisco Blanco-Silva