Line 1: Line 1:
%Kara Ellspermann<br>%ECE 301 HW 1
+
%Kara Ellspermann<br>%ECE 301 HW 1  
  
%PART 1, PLAYING MUSIC
+
%PART 1, PLAYING MUSIC  
  
for i = 1:3 %loops through for cases a-c<br><br>%If a quarter note = 1 beat, a quarter note is the inverse of beats per<br>%second (beats per minute * 60 seconds)<br>if i == 2<br>tempo = 224; %tempo in beats per minute<br>else<br>tempo = 112; %tempo in beats per minute<br>end<br>beat = 60/tempo; %length of quarter note, in seconds<br>delta = .00005; %length between steps in matrix
+
for i = 1:3&nbsp;%loops through for cases a-c<br><br>%If a quarter note = 1 beat, a quarter note is the inverse of beats per<br>%second (beats per minute * 60 seconds)<br>if i == 2<br>tempo = 224;&nbsp;%tempo in beats per minute<br>else<br>tempo = 112;&nbsp;%tempo in beats per minute<br>end<br>beat = 60/tempo;&nbsp;%length of quarter note, in seconds<br>delta = .00005;&nbsp;%length between steps in matrix  
  
%Note lengths<br>Q = 0:delta:beat; %length of quarter note<br>H = 0:delta:2*beat; %length of half note<br>QD = 0:delta:1.5*beat; %length of quarter dot<br>E = 0:delta:beat/2; %length of eighth note
+
%Note lengths<br>Q = 0:delta:beat;&nbsp;%length of quarter note<br>H = 0:delta:2*beat;&nbsp;%length of half note<br>QD = 0:delta:1.5*beat;&nbsp;%length of quarter dot<br>E = 0:delta:beat/2;&nbsp;%length of eighth note  
  
%Note frequencies<br>if i == 3<br>fA = 880; %frequency of A, reference, in Hz<br>else<br>fA = 440; %frequency of A, reference, in Hz<br>end<br>fG = 2^(-2/12)*fA; %frequency of G, in Hz<br>fBb = 2^(1/12)*fA; %frequency of B flat, in Hz<br>fC = 2^(3/12)*fA; %frequency of C, in Hz<br>fDb = 2^(4/12)*fA; %frequency of D flat, in Hz
+
%Note frequencies<br>if i == 3<br>fA = 880;&nbsp;%frequency of A, reference, in Hz<br>else<br>fA = 440;&nbsp;%frequency of A, reference, in Hz<br>end<br>fG = 2^(-2/12)*fA;&nbsp;%frequency of G, in Hz<br>fBb = 2^(1/12)*fA;&nbsp;%frequency of B flat, in Hz<br>fC = 2^(3/12)*fA;&nbsp;%frequency of C, in Hz<br>fDb = 2^(4/12)*fA;&nbsp;%frequency of D flat, in Hz  
  
%Notes used<br>Q_G = sin(2*pi*fG*Q); %quarter note, G<br>Q_Bb = sin(2*pi*fBb*Q); %quarter note, B flat<br>QD_C = sin(2*pi*fC*QD); %dotted quarter note, C<br>E_Db = sin(2*pi*fDb*E); %eighth note, D flat<br>H_C = sin(2*pi*fC*H); %half note, C
+
%Notes used<br>Q_G = sin(2*pi*fG*Q);&nbsp;%quarter note, G<br>Q_Bb = sin(2*pi*fBb*Q);&nbsp;%quarter note, B flat<br>QD_C = sin(2*pi*fC*QD);&nbsp;%dotted quarter note, C<br>E_Db = sin(2*pi*fDb*E);&nbsp;%eighth note, D flat<br>H_C = sin(2*pi*fC*H);&nbsp;%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];<br>sound(tune, 1/delta)
+
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];<br>sound(tune, 1/delta)  
  
if i == 1<br>wavwrite(tune, 1/delta, 32, 'smoke1a_kellsper')<br>elseif i == 2<br>wavwrite(tune, 1/delta, 32, 'smoke1b_kellsper')<br>else<br>wavwrite(tune, 1/delta, 32, 'smoke1c_kellsper')<br>end
+
if i == 1<br>wavwrite(tune, 1/delta, 32, 'smoke1a_kellsper')<br>elseif i == 2<br>wavwrite(tune, 1/delta, 32, 'smoke1b_kellsper')<br>else<br>wavwrite(tune, 1/delta, 32, 'smoke1c_kellsper')<br>end  
  
end
+
[[Image:smoke1a_kellsper.wav]]
 +
end  
  
% PART 2, HIDDEN BACKWARD MESSAGE
+
% PART 2, HIDDEN BACKWARD MESSAGE  
  
% a.) The forward repeated phrase is "Number 9".
+
% a.) The forward repeated phrase is "Number 9".  
  
%Reversing the signal<br>[Y, Fs] = wavread('Beatles.wav');<br>Ynew = flipud(Y);<br>wavwrite(Ynew, Fs, 32, 'Beatles_reversed_kellsper')<br>sound(Ynew, Fs)
+
%Reversing the signal<br>[Y, Fs] = wavread('Beatles.wav');<br>Ynew = flipud(Y);<br>wavwrite(Ynew, Fs, 32, 'Beatles_reversed_kellsper')<br>sound(Ynew, Fs)  
  
 
% b.) The backward repeated phrase sounds like "Turn me on, Levmond", if<br>% "Levmond" could be a name.
 
% b.) The backward repeated phrase sounds like "Turn me on, Levmond", if<br>% "Levmond" could be a name.

Revision as of 16:36, 18 January 2011

%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

File:Smoke1a kellsper.wav 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

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

Dr. Paul Garrett