(New page: %NUMBER 1 clc clear all fA = 440; %frequency of an A in Hz fG = 2 ^ (-2 / 12) * fA; %frequency of a G in Hz fBflat = 2 ^ (1 / 12) * fA; %frequency of a Bflat in Hz fC = 2 ^ (3 / 12) * fA...)
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
%NUMBER 1
+
%NUMBER 1  
  
clc
+
clc clear all  
clear all
+
  
fA = 440; %frequency of an A in Hz
+
fA = 440; %frequency of an A in Hz fG = 2 ^ (-2 / 12) * fA; %frequency of a G in Hz fBflat = 2 ^ (1 / 12) * fA; %frequency of a Bflat in Hz fC = 2 ^ (3 / 12) * fA; %frequency of a C in Hz fDflat = 2 ^ (4 / 12) * fA; %frequency of a Dflat in Hz  
fG = 2 ^ (-2 / 12) * fA; %frequency of a G in Hz
+
fBflat = 2 ^ (1 / 12) * fA; %frequency of a Bflat in Hz
+
fC = 2 ^ (3 / 12) * fA; %frequency of a C in Hz
+
fDflat = 2 ^ (4 / 12) * fA; %frequency of a Dflat in Hz
+
  
delta = 0.00005; %step size
+
delta = 0.00005; %step size  
  
%PART 1
+
%PART 1 tempo = 112 / 60;  
tempo = 112 / 60;  
+
  
half = 0 : delta : 2 / tempo; %half note
+
half = 0 : delta : 2 / tempo; %half note quart = 0 : delta : 1 / tempo; %quarter note eighth = 0 : delta : 1 / (2 * tempo); %eighth note dotquart = 0 : delta : 3 / (2 * tempo); %dotted quarter note  
quart = 0 : delta : 1 / tempo; %quarter note
+
eighth = 0 : delta : 1 / (2 * tempo); %eighth note
+
dotquart = 0 : delta : 3 / (2 * tempo); %dotted quarter note
+
  
qG = sin(2 * pi * fG .* quart);
+
qG = sin(2 * pi * fG .* quart); qBflat = sin(2 * pi * fBflat .* quart); dqC = sin(2 * pi * fC .* dotquart); eDflat = sin(2 * pi * fDflat .* eighth); hC = sin(2 * pi * fC .* half);  
qBflat = sin(2 * pi * fBflat .* quart);
+
dqC = sin(2 * pi * fC .* dotquart);
+
eDflat = sin(2 * pi * fDflat .* eighth);
+
hC = sin(2 * pi * fC .* half);
+
  
song = [qG, qBflat, dqC, qG, qBflat, eDflat, hC, qG, qBflat, dqC, qBflat, qG];
+
song = [qG, qBflat, dqC, qG, qBflat, eDflat, hC, qG, qBflat, dqC, qBflat, qG];  
  
sound(song, 1/delta)
+
sound(song, 1/delta)  
  
%PART 2
+
wavwrite(song, 1/delta, 'ECE301hw1part1');  
tempo = 2 * 112 / 60;  
+
  
half = 0 : delta : 2 / tempo; %half note
+
[[Media:ECE301hw1part1.wav]]
quart = 0 : delta : 1 / tempo; %quarter note
+
eighth = 0 : delta : 1 / (2 * tempo); %eighth note
+
dotquart = 0 : delta : 3 / (2 * tempo); %dotted quarter note
+
  
qG = sin(2 * pi * fG .* quart);
+
%PART 2 tempo = 2 * 112 / 60;  
qBflat = sin(2 * pi * fBflat .* quart);
+
dqC = sin(2 * pi * fC .* dotquart);
+
eDflat = sin(2 * pi * fDflat .* eighth);
+
hC = sin(2 * pi * fC .* half);
+
  
song = [qG, qBflat, dqC, qG, qBflat, eDflat, hC, qG, qBflat, dqC, qBflat, qG];
+
half = 0 : delta : 2 / tempo; %half note quart = 0 : delta : 1 / tempo; %quarter note eighth = 0 : delta : 1 / (2 * tempo); %eighth note dotquart = 0 : delta : 3 / (2 * tempo); %dotted quarter note
  
sound(song, 1/delta)
+
qG = sin(2 * pi * fG .* quart); qBflat = sin(2 * pi * fBflat .* quart); dqC = sin(2 * pi * fC .* dotquart); eDflat = sin(2 * pi * fDflat .* eighth); hC = sin(2 * pi * fC .* half);
  
%PART 3
+
song = [qG, qBflat, dqC, qG, qBflat, eDflat, hC, qG, qBflat, dqC, qBflat, qG];
 +
 
 +
sound(song, 1/delta)
 +
 
 +
wavwrite(song,1/delta, 'ECE301hw1part2');
 +
 
 +
[[Media:ECE301hw1part2.wav]]
 +
 
 +
 
 +
%PART 3  
  
 
tempo = 112 / 60;  
 
tempo = 112 / 60;  
  
half = 0 : delta : 2 / tempo; %half note
+
half = 0 : delta : 2 / tempo; %half note quart = 0 : delta : 1 / tempo; %quarter note eighth = 0 : delta : 1 / (2 * tempo); %eighth note dotquart = 0 : delta : 3 / (2 * tempo); %dotted quarter note  
quart = 0 : delta : 1 / tempo; %quarter note
+
 
eighth = 0 : delta : 1 / (2 * tempo); %eighth note
+
qG = sin(2 * 2 * pi * fG .* quart); qBflat = sin(2 * 2 * pi * fBflat .* quart); dqC = sin(2* 2 * pi * fC .* dotquart); eDflat = sin(2 * 2 * pi * fDflat .* eighth); hC = sin(2 * 2 * pi * fC .* half);
dotquart = 0 : delta : 3 / (2 * tempo); %dotted quarter note
+
 
 +
song = [qG, qBflat, dqC, qG, qBflat, eDflat, hC, qG, qBflat, dqC, qBflat, qG];
  
qG = sin(2 * 2 * pi * fG .* quart);
+
sound(song, 1/delta)  
qBflat = sin(2 * 2 * pi * fBflat .* quart);
+
dqC = sin(2* 2 * pi * fC .* dotquart);
+
eDflat = sin(2 * 2 * pi * fDflat .* eighth);
+
hC = sin(2 * 2 * pi * fC .* half);
+
  
song = [qG, qBflat, dqC, qG, qBflat, eDflat, hC, qG, qBflat, dqC, qBflat, qG];
+
wavwrite(song,1/delta, 'ECE301hw1part3');  
  
sound(song, 1/delta)
+
[[Media:ECE301hw1part3.wav]]
  
 +
<br> %NUMBER 2
  
 +
clc clear all
  
%NUMBER 2
+
[song,Fs] = wavread('Beatles.wav');
  
clc
+
rev = flipud(song);
clear all
+
  
[song,Fs] = wavread('Beatles.wav');
+
wavwrite(rev,'rev.wav');  
  
rev = flipud(song);
+
sound(rev,Fs)  
  
wavwrite(rev,'rev.wav');
+
[[Media:rev.wav]]
  
sound(rev,Fs)
+
% The phrase played forward sounded like "the number nine."
 +
% The reversed song supposedly contains something like "turn me on dead man," but I found it to be a stretch.

Latest revision as of 11:06, 19 January 2011

%NUMBER 1

clc clear all

fA = 440; %frequency of an A in Hz fG = 2 ^ (-2 / 12) * fA; %frequency of a G in Hz fBflat = 2 ^ (1 / 12) * fA; %frequency of a Bflat in Hz fC = 2 ^ (3 / 12) * fA; %frequency of a C in Hz fDflat = 2 ^ (4 / 12) * fA; %frequency of a Dflat in Hz

delta = 0.00005; %step size

%PART 1 tempo = 112 / 60;

half = 0 : delta : 2 / tempo; %half note quart = 0 : delta : 1 / tempo; %quarter note eighth = 0 : delta : 1 / (2 * tempo); %eighth note dotquart = 0 : delta : 3 / (2 * tempo); %dotted quarter note

qG = sin(2 * pi * fG .* quart); qBflat = sin(2 * pi * fBflat .* quart); dqC = sin(2 * pi * fC .* dotquart); eDflat = sin(2 * pi * fDflat .* eighth); hC = sin(2 * pi * fC .* half);

song = [qG, qBflat, dqC, qG, qBflat, eDflat, hC, qG, qBflat, dqC, qBflat, qG];

sound(song, 1/delta)

wavwrite(song, 1/delta, 'ECE301hw1part1');

Media:ECE301hw1part1.wav

%PART 2 tempo = 2 * 112 / 60;

half = 0 : delta : 2 / tempo; %half note quart = 0 : delta : 1 / tempo; %quarter note eighth = 0 : delta : 1 / (2 * tempo); %eighth note dotquart = 0 : delta : 3 / (2 * tempo); %dotted quarter note

qG = sin(2 * pi * fG .* quart); qBflat = sin(2 * pi * fBflat .* quart); dqC = sin(2 * pi * fC .* dotquart); eDflat = sin(2 * pi * fDflat .* eighth); hC = sin(2 * pi * fC .* half);

song = [qG, qBflat, dqC, qG, qBflat, eDflat, hC, qG, qBflat, dqC, qBflat, qG];

sound(song, 1/delta)

wavwrite(song,1/delta, 'ECE301hw1part2');

Media:ECE301hw1part2.wav


%PART 3

tempo = 112 / 60;

half = 0 : delta : 2 / tempo; %half note quart = 0 : delta : 1 / tempo; %quarter note eighth = 0 : delta : 1 / (2 * tempo); %eighth note dotquart = 0 : delta : 3 / (2 * tempo); %dotted quarter note

qG = sin(2 * 2 * pi * fG .* quart); qBflat = sin(2 * 2 * pi * fBflat .* quart); dqC = sin(2* 2 * pi * fC .* dotquart); eDflat = sin(2 * 2 * pi * fDflat .* eighth); hC = sin(2 * 2 * pi * fC .* half);

song = [qG, qBflat, dqC, qG, qBflat, eDflat, hC, qG, qBflat, dqC, qBflat, qG];

sound(song, 1/delta)

wavwrite(song,1/delta, 'ECE301hw1part3');

Media:ECE301hw1part3.wav


 %NUMBER 2

clc clear all

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

rev = flipud(song);

wavwrite(rev,'rev.wav');

sound(rev,Fs)

Media:rev.wav

% The phrase played forward sounded like "the number nine." % The reversed song supposedly contains something like "turn me on dead man," but I found it to be a stretch.

Alumni Liaison

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

Dr. Paul Garrett