Line 29: | Line 29: | ||
bps = 60/bpm; %seconds per beat | bps = 60/bpm; %seconds per beat | ||
− | H = 2*bps; % seconds required for half note <br> | + | H = 2*bps; % seconds required for half note <br> |
− | Q = 1*bps; % seconds required for quarter note <br> | + | Q = 1*bps; % seconds required for quarter note <br> |
− | E = .5*bps; % seconds required for eighth note <br> | + | E = .5*bps; % seconds required for eighth note <br> |
DQ = 1.5*bps; % seconds required for dotted quarter note | DQ = 1.5*bps; % seconds required for dotted quarter note | ||
− | %time <br> | + | %time <br> |
− | H_t = 0:delta:H; <br> | + | H_t = 0:delta:H; <br> |
− | Q_t = 0:delta:Q;<br> | + | Q_t = 0:delta:Q;<br> |
− | E_t = 0:delta:E; <br> | + | E_t = 0:delta:E; <br> |
DQ_t = 0:delta:DQ; | DQ_t = 0:delta:DQ; | ||
− | %frequencies for notes<br> | + | %frequencies for notes<br> |
− | fa = 440; %Hz <br> | + | fa = 440; %Hz <br> |
− | fg = 2^(-2/12)*fa; <br> | + | fg = 2^(-2/12)*fa; <br> |
− | fbf = 2^(1/12)*fa; <br> | + | fbf = 2^(1/12)*fa; <br> |
− | fc =2^(3/12)*fa;<br> | + | fc =2^(3/12)*fa;<br> |
fdf = 2^(4/12)*fa; | fdf = 2^(4/12)*fa; | ||
− | %notes with appropriate times <br> | + | %notes with appropriate times <br> |
− | g = sin(2*pi*fg*Q_t); <br> | + | g = sin(2*pi*fg*Q_t); <br> |
− | bf = sin(2*pi*fbf*Q_t); <br> | + | bf = sin(2*pi*fbf*Q_t); <br> |
− | c_dq = sin(2*pi*fc*DQ_t);<br> | + | c_dq = sin(2*pi*fc*DQ_t);<br> |
− | c_h = sin(2*pi*fc*H_t); <br> | + | c_h = sin(2*pi*fc*H_t); <br> |
df = sin(2*pi*fdf*E_t); | df = sin(2*pi*fdf*E_t); | ||
− | %song at regular tempo <br> | + | %song at regular tempo <br> |
− | song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; <br> | + | song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; <br> |
− | %plays <br> | + | %plays <br> |
− | song sound(song, 1/delta); <br> | + | song sound(song, 1/delta); <br> |
− | %write song to wavfile<br> | + | %write song to wavfile<br> |
wavwrite(song, 1/delta, 'Regular_Tempo.wav') | wavwrite(song, 1/delta, 'Regular_Tempo.wav') | ||
− | + | Media:Regular_Tempo.wav <br> | |
− | bpm = 224; %beats per minute<br> | + | %PART 1B<br> |
+ | |||
+ | bpm = 224; %beats per minute<br> | ||
bps = 60/bpm; %seconds per beat | bps = 60/bpm; %seconds per beat | ||
− | H = 2*bps; % seconds required for half note<br> | + | H = 2*bps; % seconds required for half note<br> |
− | Q = 1*bps; % seconds required for quarter note <br> | + | Q = 1*bps; % seconds required for quarter note <br> |
− | E = .5*bps; % seconds required for eighth note<br> | + | E = .5*bps; % seconds required for eighth note<br> |
DQ = 1.5*bps; % seconds required for dotted quarter note | DQ = 1.5*bps; % seconds required for dotted quarter note | ||
− | %time <br> | + | %time <br> |
− | H_t = 0:delta:H;<br> | + | H_t = 0:delta:H;<br> |
− | Q_t = 0:delta:Q; <br> | + | Q_t = 0:delta:Q; <br> |
− | E_t = 0:delta:E; <br> | + | E_t = 0:delta:E; <br> |
DQ_t = 0:delta:DQ; | DQ_t = 0:delta:DQ; | ||
− | %notes with appropriate times <br> | + | %notes with appropriate times <br> |
− | g = sin(4*pi*fg*Q_t);<br> | + | g = sin(4*pi*fg*Q_t);<br> |
− | bf = sin(4*pi*fbf*Q_t);<br> | + | bf = sin(4*pi*fbf*Q_t);<br> |
− | c_dq = sin(4*pi*fc*DQ_t); <br> | + | c_dq = sin(4*pi*fc*DQ_t); <br> |
− | c_h = sin(4*pi*fc*H_t);<br> | + | c_h = sin(4*pi*fc*H_t);<br> |
df = sin(4*pi*fdf*E_t); | df = sin(4*pi*fdf*E_t); | ||
− | %song at faster tempo<br> | + | %song at faster tempo<br> |
− | song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; <br> | + | song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; <br> |
− | %plays song sound(song, 1/delta); <br> | + | %plays song sound(song, 1/delta); <br> |
− | %write song to wavfile <br> | + | %write song to wavfile <br> |
wavwrite(song, 1/delta, 'Faster_Tempo.wav') | wavwrite(song, 1/delta, 'Faster_Tempo.wav') | ||
− | + | Media:Faster_Tempo.wav<br> | |
− | bpm = 112; %beats per minute<br> | + | %PART 1C<br> |
+ | |||
+ | bpm = 112; %beats per minute<br> | ||
bps = 60/bpm; %seconds per beat | bps = 60/bpm; %seconds per beat | ||
− | H = 2*bps; % seconds required for half note<br> | + | H = 2*bps; % seconds required for half note<br> |
− | Q = 1*bps; % seconds required for quarter note <br> | + | Q = 1*bps; % seconds required for quarter note <br> |
− | E = .5*bps; % seconds required for eighth note <br> | + | E = .5*bps; % seconds required for eighth note <br> |
DQ = 1.5*bps; % seconds required for dotted quarter note | DQ = 1.5*bps; % seconds required for dotted quarter note | ||
− | %time <br> | + | %time <br> |
− | H_t = 0:delta:H;<br> | + | H_t = 0:delta:H;<br> |
− | Q_t = 0:delta:Q;<br> | + | Q_t = 0:delta:Q;<br> |
− | E_t = 0:delta:E; <br> | + | E_t = 0:delta:E; <br> |
DQ_t = 0:delta:DQ; | DQ_t = 0:delta:DQ; | ||
− | %frequencies for notes<br> | + | %frequencies for notes<br> |
− | fa = 880; %Hz<br> | + | fa = 880; %Hz<br> |
− | fg = 2^(-2/12)*fa;<br> | + | fg = 2^(-2/12)*fa;<br> |
− | fbf = 2^(1/12)*fa; <br> | + | fbf = 2^(1/12)*fa; <br> |
− | fc =2^(3/12)*fa; <br> | + | fc =2^(3/12)*fa; <br> |
fdf = 2^(4/12)*fa; | fdf = 2^(4/12)*fa; | ||
− | %notes with appropriate times <br> | + | %notes with appropriate times <br> |
− | g = sin(2*pi*fg*Q_t);<br> | + | g = sin(2*pi*fg*Q_t);<br> |
− | bf = sin(2*pi*fbf*Q_t);<br> | + | bf = sin(2*pi*fbf*Q_t);<br> |
− | c_dq = sin(2*pi*fc*DQ_t);<br> | + | c_dq = sin(2*pi*fc*DQ_t);<br> |
− | c_h = sin(2*pi*fc*H_t);<br> | + | c_h = sin(2*pi*fc*H_t);<br> |
df = sin(2*pi*fdf*E_t); | df = sin(2*pi*fdf*E_t); | ||
− | %song at regular tempo <br> | + | %song at regular tempo <br> |
− | song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; <br> | + | song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; <br> |
− | %plays <br> | + | %plays <br> |
− | song sound(song, 1/delta); <br> | + | song sound(song, 1/delta); <br> |
− | %write song to wavfile <br> | + | %write song to wavfile <br> |
wavwrite(song, 1/delta, 'Higher_Octave.wav') | wavwrite(song, 1/delta, 'Higher_Octave.wav') | ||
+ | |||
+ | Media:Higher_Octave.wav | ||
<br> %Part 2 | <br> %Part 2 | ||
− | %load Beatles clip and frequency <br> | + | %load Beatles clip and frequency <br> |
[beatles,fs] = wavread('Beatles.wav'); %plays clip sound(beatles, fs); | [beatles,fs] = wavread('Beatles.wav'); %plays clip sound(beatles, fs); | ||
Line 197: | Line 203: | ||
%The repeated message seems to be 'Number Nine' repeated over and over %again. | %The repeated message seems to be 'Number Nine' repeated over and over %again. | ||
− | %reverses the sound matrix<br> | + | %reverses the sound matrix<br> |
− | reverse = flipud(beatles); <br> | + | reverse = flipud(beatles); <br> |
− | %plays reversed clip <br> | + | %plays reversed clip <br> |
− | sound(reverse, fs) <br> | + | sound(reverse, fs) <br> |
%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:55, 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')
Media: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')
Media: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')
Media: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'