(New page: %ECE 301 HW 1 %Sarah Abraham %Professor Boutin %Part 1 %play melody of Smoke On the Water at original tempo %G Bf C G Bf Df C G Bf C Bf G %H = 1/2 note %Q = 1/4 note %E = 1/8 note %DQ = ...)
 
Line 1: Line 1:
%ECE 301 HW 1
+
%ECE 301 HW 1  
%Sarah Abraham
+
%Professor Boutin
+
  
%Part 1
+
%Sarah Abraham
%play melody of Smoke On the Water at original tempo
+
%G Bf C G Bf Df C G Bf C Bf G
+
  
%H = 1/2 note
+
%Professor Boutin
%Q = 1/4 note
+
%E = 1/8 note
+
%DQ = dotted quarter
+
  
clc
+
%Part 1
clear
+
delta = 5e-5; %sampling rate
+
bpm = 112; %beats per minute
+
bps = 60/bpm; %seconds per beat
+
  
H = 2*bps; % seconds required for half note
+
%play melody of Smoke On the Water at original tempo
Q = 1*bps; % seconds required for quarter note
+
E = .5*bps; % seconds required for eighth note
+
DQ = 1.5*bps; % seconds required for dotted quarter note
+
  
%time
+
%G Bf C G Bf Df C G Bf C Bf G
H_t = 0:delta:H;
+
Q_t = 0:delta:Q;
+
E_t = 0:delta:E;
+
DQ_t = 0:delta:DQ;
+
  
%frequencies for notes
+
%H = 1/2 note
fa = 440; %Hz
+
 
fg = 2^(-2/12)*fa;  
+
%Q = 1/4 note
fbf = 2^(1/12)*fa;
+
 
fc =2^(3/12)*fa;
+
%E = 1/8 note
fdf = 2^(4/12)*fa;
+
 
 +
%DQ = dotted quarter
 +
 
 +
clc
 +
 
 +
clear
 +
 
 +
delta = 5e-5; %sampling rate
 +
 
 +
bpm = 112; %beats per minute
 +
 
 +
bps = 60/bpm; %seconds per beat
 +
 
 +
H = 2*bps;&nbsp;% seconds required for half note <br>
 +
 
 +
Q = 1*bps;&nbsp;% seconds required for quarter note <br>
 +
 
 +
E = .5*bps;&nbsp;% seconds required for eighth note <br>
 +
 
 +
DQ = 1.5*bps;&nbsp;% seconds required for dotted quarter note
 +
 
 +
%time <br>
 +
 
 +
H_t = 0:delta:H; <br>
 +
 
 +
Q_t = 0:delta:Q;<br>
 +
 
 +
E_t = 0:delta:E; <br>
 +
 
 +
DQ_t = 0:delta:DQ;
 +
 
 +
%frequencies for notes<br>
 +
 
 +
fa = 440;&nbsp;%Hz <br>
 +
 
 +
fg = 2^(-2/12)*fa; <br>
 +
 
 +
fbf = 2^(1/12)*fa; <br>
 +
 
 +
fc =2^(3/12)*fa;<br>
 +
 
 +
fdf = 2^(4/12)*fa;  
 +
 
 +
%notes with appropriate times <br>
 +
 
 +
g = sin(2*pi*fg*Q_t); <br>
 +
 
 +
bf = sin(2*pi*fbf*Q_t); <br>
 +
 
 +
c_dq = sin(2*pi*fc*DQ_t);<br>
 +
 
 +
c_h = sin(2*pi*fc*H_t); <br>
  
%notes with appropriate times
 
g = sin(2*pi*fg*Q_t);
 
bf = sin(2*pi*fbf*Q_t);
 
c_dq = sin(2*pi*fc*DQ_t);
 
c_h = sin(2*pi*fc*H_t);
 
 
df = sin(2*pi*fdf*E_t);  
 
df = sin(2*pi*fdf*E_t);  
  
%song at regular tempo  
+
%song at regular tempo <br>
song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g];
+
%plays song
+
sound(song, 1/delta);
+
%write song to wavfile
+
wavwrite(song, 1/delta, 'Regular_Tempo.wav')
+
  
%PART 1B
+
song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g];&nbsp;<br>
bpm = 224; %beats per minute
+
bps = 60/bpm; %seconds per beat
+
  
H = 2*bps; % seconds required for half note
+
%plays <br>
Q = 1*bps; % seconds required for quarter note
+
E = .5*bps; % seconds required for eighth note
+
DQ = 1.5*bps; % seconds required for dotted quarter note
+
  
%time
+
song sound(song, 1/delta);&nbsp;<br>
H_t = 0:delta:H;
+
 
Q_t = 0:delta:Q;
+
%write song to wavfile<br>
E_t = 0:delta:E;
+
 
DQ_t = 0:delta:DQ;
+
wavwrite(song, 1/delta, 'Regular_Tempo.wav')
 +
 
 +
%PART 1B<br>
 +
 
 +
bpm = 224;&nbsp;%beats per minute<br>
 +
 
 +
bps = 60/bpm;&nbsp;%seconds per beat
 +
 
 +
H = 2*bps;&nbsp;% seconds required for half note<br>
 +
 
 +
Q = 1*bps;&nbsp;% seconds required for quarter note <br>
 +
 
 +
E = .5*bps;&nbsp;% seconds required for eighth note<br>
 +
 
 +
DQ = 1.5*bps;&nbsp;% seconds required for dotted quarter note
 +
 
 +
%time <br>
 +
 
 +
H_t = 0:delta:H;<br>
 +
 
 +
Q_t = 0:delta:Q; <br>
 +
 
 +
E_t = 0:delta:E; <br>
 +
 
 +
DQ_t = 0:delta:DQ;  
 +
 
 +
%notes with appropriate times <br>
 +
 
 +
g = sin(4*pi*fg*Q_t);<br>
 +
 
 +
bf = sin(4*pi*fbf*Q_t);<br>
 +
 
 +
c_dq = sin(4*pi*fc*DQ_t); <br>
 +
 
 +
c_h = sin(4*pi*fc*H_t);<br>
  
%notes with appropriate times
 
g = sin(4*pi*fg*Q_t);
 
bf = sin(4*pi*fbf*Q_t);
 
c_dq = sin(4*pi*fc*DQ_t);
 
c_h = sin(4*pi*fc*H_t);
 
 
df = sin(4*pi*fdf*E_t);  
 
df = sin(4*pi*fdf*E_t);  
  
%song at faster tempo  
+
%song at faster tempo<br>
song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g];
+
%plays song
+
sound(song, 1/delta);
+
%write song to wavfile
+
wavwrite(song, 1/delta, 'Faster_Tempo.wav')
+
  
%PART 1C
+
song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g];&nbsp;<br>
bpm = 112; %beats per minute
+
bps = 60/bpm; %seconds per beat
+
  
H = 2*bps; % seconds required for half note
+
%plays song sound(song, 1/delta);&nbsp;<br>
Q = 1*bps; % seconds required for quarter note
+
E = .5*bps; % seconds required for eighth note
+
DQ = 1.5*bps; % seconds required for dotted quarter note
+
  
%time
+
%write song to wavfile <br>
H_t = 0:delta:H;
+
Q_t = 0:delta:Q;
+
E_t = 0:delta:E;
+
DQ_t = 0:delta:DQ;
+
  
%frequencies for notes
+
wavwrite(song, 1/delta, 'Faster_Tempo.wav')
fa = 880; %Hz
+
 
fg = 2^(-2/12)*fa;  
+
%PART 1C<br>
fbf = 2^(1/12)*fa;
+
 
fc =2^(3/12)*fa;
+
bpm = 112;&nbsp;%beats per minute<br>
fdf = 2^(4/12)*fa;
+
 
 +
bps = 60/bpm;&nbsp;%seconds per beat
 +
 
 +
H = 2*bps;&nbsp;% seconds required for half note<br>
 +
 
 +
Q = 1*bps;&nbsp;% seconds required for quarter note <br>
 +
 
 +
E = .5*bps;&nbsp;% seconds required for eighth note <br>
 +
 
 +
DQ = 1.5*bps;&nbsp;% seconds required for dotted quarter note
 +
 
 +
%time <br>
 +
 
 +
H_t = 0:delta:H;<br>
 +
 
 +
Q_t = 0:delta:Q;<br>
 +
 
 +
E_t = 0:delta:E; <br>
 +
 
 +
DQ_t = 0:delta:DQ;
 +
 
 +
%frequencies for notes<br>
 +
 
 +
fa = 880;&nbsp;%Hz<br>
 +
 
 +
fg = 2^(-2/12)*fa;<br>
 +
 
 +
fbf = 2^(1/12)*fa; <br>
 +
 
 +
fc =2^(3/12)*fa; <br>
 +
 
 +
fdf = 2^(4/12)*fa;  
 +
 
 +
%notes with appropriate times <br>
 +
 
 +
g = sin(2*pi*fg*Q_t);<br>
 +
 
 +
bf = sin(2*pi*fbf*Q_t);<br>
 +
 
 +
c_dq = sin(2*pi*fc*DQ_t);<br>
 +
 
 +
c_h = sin(2*pi*fc*H_t);<br>
  
%notes with appropriate times
 
g = sin(2*pi*fg*Q_t);
 
bf = sin(2*pi*fbf*Q_t);
 
c_dq = sin(2*pi*fc*DQ_t);
 
c_h = sin(2*pi*fc*H_t);
 
 
df = sin(2*pi*fdf*E_t);  
 
df = sin(2*pi*fdf*E_t);  
  
%song at regular tempo  
+
%song at regular tempo <br>
song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g];  
+
 
%plays song
+
song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g];&nbsp;<br>
sound(song, 1/delta);  
+
 
%write song to wavfile
+
%plays <br>
wavwrite(song, 1/delta, 'Higher_Octave.wav')
+
 
 +
song sound(song, 1/delta);&nbsp;<br>
 +
 
 +
%write song to wavfile <br>
 +
 
 +
wavwrite(song, 1/delta, 'Higher_Octave.wav')  
 +
 
 +
<br>&nbsp;%Part 2
 +
 
 +
%load Beatles clip and frequency <br>
 +
 
 +
[beatles,fs] = wavread('Beatles.wav');&nbsp;%plays clip sound(beatles, fs);
 +
 
 +
%The repeated message seems to be 'Number Nine' repeated over and over&nbsp;%again.
  
 +
%reverses the sound matrix<br>
  
%Part 2
+
reverse = flipud(beatles);&nbsp;<br>
  
%load Beatles clip and frequency
+
%plays reversed clip <br>
[beatles,fs] = wavread('Beatles.wav');
+
%plays clip
+
sound(beatles, fs);
+
  
%The repeated message seems to be 'Number Nine' repeated over and over
+
sound(reverse, fs)&nbsp;<br>
%again.
+
  
%reverses the sound matrix
 
reverse = flipud(beatles);
 
%plays reversed clip
 
sound(reverse, fs)
 
 
%The repeated message seems like it says 'Turn me on dead man'
 
%The repeated message seems like it says 'Turn me on dead man'

Revision as of 07:48, 19 January 2011

%ECE 301 HW 1

%Sarah Abraham

%Professor Boutin

%Part 1

%play melody of Smoke On the Water at original tempo

%G Bf C G Bf Df C G Bf C Bf G

%H = 1/2 note

%Q = 1/4 note

%E = 1/8 note

%DQ = dotted quarter

clc

clear

delta = 5e-5; %sampling rate

bpm = 112; %beats per minute

bps = 60/bpm; %seconds per beat

H = 2*bps; % seconds required for half note

Q = 1*bps; % seconds required for quarter note

E = .5*bps; % seconds required for eighth note

DQ = 1.5*bps; % seconds required for dotted quarter note

%time

H_t = 0:delta:H;

Q_t = 0:delta:Q;

E_t = 0:delta:E;

DQ_t = 0:delta:DQ;

%frequencies for notes

fa = 440; %Hz

fg = 2^(-2/12)*fa;

fbf = 2^(1/12)*fa;

fc =2^(3/12)*fa;

fdf = 2^(4/12)*fa;

%notes with appropriate times

g = sin(2*pi*fg*Q_t);

bf = sin(2*pi*fbf*Q_t);

c_dq = sin(2*pi*fc*DQ_t);

c_h = sin(2*pi*fc*H_t);

df = sin(2*pi*fdf*E_t);

%song at regular tempo

song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; 

%plays

song sound(song, 1/delta); 

%write song to wavfile

wavwrite(song, 1/delta, 'Regular_Tempo.wav')

%PART 1B

bpm = 224; %beats per minute

bps = 60/bpm; %seconds per beat

H = 2*bps; % seconds required for half note

Q = 1*bps; % seconds required for quarter note

E = .5*bps; % seconds required for eighth note

DQ = 1.5*bps; % seconds required for dotted quarter note

%time

H_t = 0:delta:H;

Q_t = 0:delta:Q;

E_t = 0:delta:E;

DQ_t = 0:delta:DQ;

%notes with appropriate times

g = sin(4*pi*fg*Q_t);

bf = sin(4*pi*fbf*Q_t);

c_dq = sin(4*pi*fc*DQ_t);

c_h = sin(4*pi*fc*H_t);

df = sin(4*pi*fdf*E_t);

%song at faster tempo

song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; 

%plays song sound(song, 1/delta); 

%write song to wavfile

wavwrite(song, 1/delta, 'Faster_Tempo.wav')

%PART 1C

bpm = 112; %beats per minute

bps = 60/bpm; %seconds per beat

H = 2*bps; % seconds required for half note

Q = 1*bps; % seconds required for quarter note

E = .5*bps; % seconds required for eighth note

DQ = 1.5*bps; % seconds required for dotted quarter note

%time

H_t = 0:delta:H;

Q_t = 0:delta:Q;

E_t = 0:delta:E;

DQ_t = 0:delta:DQ;

%frequencies for notes

fa = 880; %Hz

fg = 2^(-2/12)*fa;

fbf = 2^(1/12)*fa;

fc =2^(3/12)*fa;

fdf = 2^(4/12)*fa;

%notes with appropriate times

g = sin(2*pi*fg*Q_t);

bf = sin(2*pi*fbf*Q_t);

c_dq = sin(2*pi*fc*DQ_t);

c_h = sin(2*pi*fc*H_t);

df = sin(2*pi*fdf*E_t);

%song at regular tempo

song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; 

%plays

song sound(song, 1/delta); 

%write song to wavfile

wavwrite(song, 1/delta, 'Higher_Octave.wav')


 %Part 2

%load Beatles clip and frequency

[beatles,fs] = wavread('Beatles.wav'); %plays clip sound(beatles, fs);

%The repeated message seems to be 'Number Nine' repeated over and over %again.

%reverses the sound matrix

reverse = flipud(beatles); 

%plays reversed clip

sound(reverse, fs) 

%The repeated message seems like it says 'Turn me on dead man'

Alumni Liaison

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

Dr. Paul Garrett