Revision as of 16:09, 18 January 2011 by Kellsper (Talk | contribs)

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

%Kara Ellspermann

%ECE 301 HW 1


%PART 1, PLAYING MUSIC


for i = 1:3 %loops through for cases a-c


%If a quarter note = 1 beat, a quarter note is the inverse of beats per

%second (beats per minute * 60 seconds)

if i == 2

   tempo = 224; %tempo in beats per minute

else

   tempo = 112; %tempo in beats per minute

end

beat = 60/tempo; %length of quarter note, in seconds

delta = .00005; %length between steps in matrix


%Note lengths

Q = 0:delta:beat; %length of quarter note

H = 0:delta:2*beat; %length of half note

QD = 0:delta:1.5*beat; %length of quarter dot

E = 0:delta:beat/2; %length of eighth note


%Note frequencies

if i == 3

   fA = 880; %frequency of A, reference, in Hz

else

   fA = 440; %frequency of A, reference, in Hz

end

fG = 2^(-2/12)*fA; %frequency of G, in Hz

fBb = 2^(1/12)*fA; %frequency of B flat, in Hz

fC = 2^(3/12)*fA; %frequency of C, in Hz

fDb = 2^(4/12)*fA; %frequency of D flat, in Hz


%Notes used

Q_G = sin(2*pi*fG*Q); %quarter note, G

Q_Bb = sin(2*pi*fBb*Q); %quarter note, B flat

QD_C = sin(2*pi*fC*QD); %dotted quarter note, C

E_Db = sin(2*pi*fDb*E); %eighth note, D flat

H_C = sin(2*pi*fC*H); %half note, C


tune = [Q_G,Q_Bb,QD_C,Q_G,Q_Bb,E_Db,H_C,Q_G,Q_Bb,QD_C,Q_Bb,Q_G];

sound(tune, 1/delta)


if i == 1

   wavwrite(tune, 1/delta, 32, 'smoke1a_kellsper')

elseif i == 2

   wavwrite(tune, 1/delta, 32, 'smoke1b_kellsper')

else

   wavwrite(tune, 1/delta, 32, 'smoke1c_kellsper')

end


end


% PART 2, HIDDEN BACKWARD MESSAGE


% a.) The forward repeated phrase is "Number 9".


%Reversing the signal

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

Ynew = flipud(Y);

wavwrite(Ynew, Fs, 32, 'Beatles_reversed_kellsper')

sound(Ynew, Fs)


% b.) The backward repeated phrase sounds like "Turn me on, Levmond", if

% "Levmond" could be a name.

Alumni Liaison

Prof. Math. Ohio State and Associate Dean
Outstanding Alumnus Purdue Math 2008

Jeff McNeal