(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 = ...) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | %ECE 301 HW 1 | + | %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 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | %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; % seconds required for half note <br> | ||
+ | |||
+ | Q = 1*bps; % seconds required for quarter note <br> | ||
+ | |||
+ | E = .5*bps; % seconds required for eighth note <br> | ||
+ | |||
+ | DQ = 1.5*bps; % 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; %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> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
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]; <br> | |
− | + | ||
− | + | ||
− | + | %plays <br> | |
− | + | ||
− | + | ||
− | + | ||
− | %time | + | song sound(song, 1/delta); <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') |
+ | |||
+ | [[Media:Regular_Tempo.wav]]<br> | ||
+ | |||
+ | %PART 1B<br> | ||
+ | |||
+ | bpm = 224; %beats per minute<br> | ||
+ | |||
+ | bps = 60/bpm; %seconds per beat | ||
+ | |||
+ | H = 2*bps; % seconds required for half note<br> | ||
+ | |||
+ | Q = 1*bps; % seconds required for quarter note <br> | ||
+ | |||
+ | E = .5*bps; % seconds required for eighth note<br> | ||
+ | |||
+ | DQ = 1.5*bps; % 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> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
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]; <br> | |
− | + | ||
− | + | ||
− | + | %plays song sound(song, 1/delta); <br> | |
− | + | ||
− | + | ||
− | + | ||
− | % | + | %write song to wavfile <br> |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | %frequencies for notes | + | wavwrite(song, 1/delta, 'Faster_Tempo.wav') |
− | fa = 880; %Hz | + | |
− | fg = 2^(-2/12)*fa; | + | [[Media:Faster_Tempo.wav]] <br> |
− | fbf = 2^(1/12)*fa; | + | |
− | fc =2^(3/12)*fa; | + | %PART 1C<br> |
− | fdf = 2^(4/12)*fa; | + | |
+ | bpm = 112; %beats per minute<br> | ||
+ | |||
+ | bps = 60/bpm; %seconds per beat | ||
+ | |||
+ | H = 2*bps; % seconds required for half note<br> | ||
+ | |||
+ | Q = 1*bps; % seconds required for quarter note <br> | ||
+ | |||
+ | E = .5*bps; % seconds required for eighth note <br> | ||
+ | |||
+ | DQ = 1.5*bps; % 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; %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> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
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 = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; <br> |
− | sound(song, 1/delta); | + | |
− | %write song to wavfile | + | %plays <br> |
− | wavwrite(song, 1/delta, 'Higher_Octave.wav') | + | |
+ | song sound(song, 1/delta); <br> | ||
+ | |||
+ | %write song to wavfile <br> | ||
+ | |||
+ | wavwrite(song, 1/delta, 'Higher_Octave.wav') | ||
+ | |||
+ | [[Media:Higher_Octave.wav]] | ||
+ | |||
+ | <br> %Part 2 | ||
+ | |||
+ | %load Beatles clip and frequency <br> | ||
+ | |||
+ | [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<br> | ||
− | + | reverse = flipud(beatles); <br> | |
− | + | %plays reversed clip <br> | |
− | + | ||
− | %plays clip | + | |
− | + | ||
− | + | 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' |
Latest revision as of 08:21, 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'