Revision as of 13:18, 13 January 2011 by Srigney (Talk | contribs)

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

%Shannon Rigney
%ECE 301 HW 1

%Part 1- Smoke On The Water
%Tempo 112 BPM
%G Bflat C G Bflat Dflat C G Bflat C Bflat G
%Q Q DQ Q Q E H Q Q DQ Q Q
%f = 2 ^ (n/12) * fa
clc;
clear;

delta = 0.00005;

for x = 1:1:3 %A for loop determining whether it is part a, b, or c.

if x == 2
Tempo = 224; %Doubles the tempo for part b
else
Tempo = 112; %Tempo used for parts a and c.
end

%Note Lengths calculated in seconds
Quarter = 0:delta: 1 * 60/Tempo;
Eighth = 0:delta: 0.5 * 60/Tempo;
Half = 0:delta: 2 * 60/Tempo;
DotQ = 0:delta: 1.5 * 60/Tempo;

%Frequencies of pitches used in Smoke On The Water
if x == 3
fa = 880; %Rescaling the pitch of A4 for part c to be y(t) = x(2t)
else
fa = 440; %Pitch for A4
end

fG = 2 ^ (-2/12) * fa;
fBf = 2 ^ (1/12) * fa;
fC = 2 ^ (3/12) * fa;
fDf = 2 ^ (4/12) * fa;

%Notes used
G_Q = sin(2 * pi * fG * Quarter);
Bf_Q = sin(2 * pi * fBf * Quarter);
C_H = sin(2 * pi * fC * Half);
C_DQ = sin(2 * pi * fC * DotQ);
Df_E = sin(2 * pi * fDf * Eighth);

%Play song
song = [G_Q, Bf_Q, C_DQ, G_Q, Bf_Q, Df_E, C_H, G_Q, Bf_Q C_DQ, Bf_Q, G_Q];
sound(song, 1/delta);

if x == 1
wavwrite(song,1/delta,32,'srigney_smokeonthewater_regular')
elseif x == 2
wavwrite(song,1/delta,32,'srigney_smokeonthewater_spedup')
else
wavwrite(song,1/delta,32,'srigney_smokeonthewater_highpitch')
end

end

%Part 2- Beatles
clear all;
clc;

[Beatles, fs] = wavread('Beatles.wav');
%It is kind of hard to hear, but it sounds like the extracted words are
%"Number Nine" repeatedly

Reversed = flipud(Beatles);
sound(10 * Reversed, fs);
wavwrite(Reversed, fs, 'srigney_Reversed_Beatles');

%It is also hard to hear so I amplified it by ten. The extracted words kind
%of sound like "Turn me on Edmond" or "Turn me on again" or something of
%the sort.


Alumni Liaison

To all math majors: "Mathematics is a wonderfully rich subject."

Dr. Paul Garrett