Revision as of 17:52, 18 January 2011 by Kmrichmo (Talk | contribs)

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

%Homework #1

%ECE 301 - Spring 2011

%Kyle Richmond


%Part 1a: Play "Smoke on the Water" at original tempo

tempo = 112; %Beats per minute

delta = .00005; %Sampling rate

%Frequencies of necessary notes

G = (2^(-2/12))*440; %G note frequency

B_f = (2^(1/12))*440; %B flat note frequency

C = (2^(3/12))*440; %C note frequency

D_f = (2^(4/12))*440; %D flat note frequency

%Time spans for necessary notes

Q = [0:delta:(60/tempo)]; %Quarter note length

DQ = [0:delta:(90/tempo)]; %Dotted quarter note length

E = [0:delta:(30/tempo)]; %Eighth note length

H = [0:delta:(120/tempo)]; %Half note length

%Notes

G_Q = sin(2*pi*G*Q); %G quarter note

B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note

C_DQ = sin(2*pi*C*DQ); %C dotted quarter note

D_f_E = sin(2*pi*D_f*E); %D flat eighth note

C_H = sin(2*pi*C*H); %C half note

%Song

smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q];

sound(smoke, 1/delta); %Play "Smoke on the Water"

%Create sound file

wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_Regular');


%Part 1b: Play "Smoke on the Water" at twice the original tempo

tempo = 224; %Beats per minute

delta = .00005; %Sampling rate

%Frequencies of necessary notes

G = (2^(-2/12))*440; %G note frequency

B_f = (2^(1/12))*440; %B flat note frequency

C = (2^(3/12))*440; %C note frequency

D_f = (2^(4/12))*440; %D flat note frequency

%Time spans for necessary notes

Q = [0:delta:(60/tempo)]; %Quarter note length

DQ = [0:delta:(90/tempo)]; %Dotted quarter note length

E = [0:delta:(30/tempo)]; %Eighth note length

H = [0:delta:(120/tempo)]; %Half note length

%Notes

G_Q = sin(2*pi*G*Q); %G quarter note

B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note

C_DQ = sin(2*pi*C*DQ); %C dotted quarter note

D_f_E = sin(2*pi*D_f*E); %D flat eighth note

C_H = sin(2*pi*C*H); %C half note

%Song

smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q];

sound(smoke, 1/delta); %Play "Smoke on the Water"

%Create sound file

wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_Faster');


%Part 1c: Play "Smoke on the Water" with transformation y(t)=x(2t)

tempo = 112; %Beats per minute

delta = .00005; %Sampling rate

%Frequencies of necessary notes

G = (2^(-2/12))*880; %G note frequency

B_f = (2^(1/12))*880; %B flat note frequency

C = (2^(3/12))*880; %C note frequency

D_f = (2^(4/12))*880; %D flat note frequency

%Time spans for necessary notes

Q = [0:delta:(60/tempo)]; %Quarter note length

DQ = [0:delta:(90/tempo)]; %Dotted quarter note length

E = [0:delta:(30/tempo)]; %Eighth note length

H = [0:delta:(120/tempo)]; %Half note length

%Notes

G_Q = sin(2*pi*G*Q); %G quarter note

B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note

C_DQ = sin(2*pi*C*DQ); %C dotted quarter note

D_f_E = sin(2*pi*D_f*E); %D flat eighth note

C_H = sin(2*pi*C*H); %C half note

%Song

smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q];

sound(smoke, 1/delta); %Play "Smoke on the Water"

%Create sound file

wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_HighPitch');


%Part 2: Play a Beatles song in reverse

%Read the file

[Beatles, fs] = wavread('Beatles.wav');

%Reverse the file

Backwards = flipud(Beatles);

%Play the reversed file

sound(Backwards,fs);

%Create sound file

wavwrite(Backwards,fs,32,'Kyle_Richmond_BeatlesReversed');

%The original file is the verse "Number nine" repeated several times

%However, when the signal is reversed it sounds like they are saying

%"Turn me on dead man" repeatedly


Media:Kyle_Richmond_DeepPurple_Regular.wav

Media:Kyle_Richmond_DeepPurple_Faster.wav

Media:Kyle_Richmond_DeepPurple_HighPitch.wav

Media:Kyle_Richmond_BeatlesReversed.wav

Alumni Liaison

Sees the importance of signal filtering in medical imaging

Dhruv Lamba, BSEE2010