(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
delta = .00005;
+
delta = .00005;  
  
% Beat<br>bpm = 112; %beat per minute<br>beat_interval = 60/bpm;  
+
% Beat<br>bpm = 112;&nbsp;%beat per minute<br>beat_interval = 60/bpm;  
  
% Notes<br>quarter = 0:delta:beat_interval;<br>eighth = 0:delta:(beat_interval/2);<br>haft = 0:delta:(beat_interval*2);<br>dot_qrtr = 0:delta:(beat_interval*1.5);
+
% Notes<br>quarter = 0:delta:beat_interval;<br>eighth = 0:delta:(beat_interval/2);<br>haft = 0:delta:(beat_interval*2);<br>dot_qrtr = 0:delta:(beat_interval*1.5);  
  
%Frequencies of Notes<br>G = (2^(-2/12))*440;<br>Bf = (2^(1/12))*440;<br>C = (2^(3/12))*440;<br>Df = (2^(4/12))*440;
+
%Frequencies of Notes<br>G = (2^(-2/12))*440;<br>Bf = (2^(1/12))*440;<br>C = (2^(3/12))*440;<br>Df = (2^(4/12))*440;  
  
%Note Sounds<br>quarter_G = sin(2*pi*G*quarter);<br>quarter_Bf = sin(2*pi*Bf*quarter);<br>dot_qrtr_C = sin(2*pi*C*dot_qrtr);<br>eighth_Df = sin(2*pi*Df*eighth);<br>haft_C = sin(2*pi*C*haft);<br>haft_G = sin(2*pi*G*haft);
+
%Note Sounds<br>quarter_G = sin(2*pi*G*quarter);<br>quarter_Bf = sin(2*pi*Bf*quarter);<br>dot_qrtr_C = sin(2*pi*C*dot_qrtr);<br>eighth_Df = sin(2*pi*Df*eighth);<br>haft_C = sin(2*pi*C*haft);<br>haft_G = sin(2*pi*G*haft);  
  
%Note Array<br>note_array = [quarter_G, quarter_Bf, dot_qrtr_C, quarter_G, quarter_Bf, eighth_Df, haft_C, quarter_G, quarter_Bf, dot_qrtr_C, quarter_Bf, quarter_G];
+
%Note Array<br>note_array = [quarter_G, quarter_Bf, dot_qrtr_C, quarter_G, quarter_Bf, eighth_Df, haft_C, quarter_G, quarter_Bf, dot_qrtr_C, quarter_Bf, quarter_G];  
  
%Song on Regular Speed<br>sound(note_array, 1/delta);<br>wavwrite(note_array, 1/delta, '301_hw1_1A');
+
%Song on Regular Speed<br>sound(note_array, 1/delta);<br>wavwrite(note_array, 1/delta, '301_hw1_1A');  
  
%Prob 1b -- Double Speed = half the beat interval<br>beat_interval2 = (beat_interval / 2);
+
%Prob 1b -- Double Speed = half the beat interval<br>beat_interval2 = (beat_interval / 2);  
  
% Notes 2x Speed<br>quarter2 = 0:delta:beat_interval2;<br>eighth2 = 0:delta:(beat_interval2 / 2);<br>haft2 = 0:delta:(beat_interval2 * 2);<br>dot_qrtr2 = 0:delta:(beat_interval2 * 1.5);
+
% Notes 2x Speed<br>quarter2 = 0:delta:beat_interval2;<br>eighth2 = 0:delta:(beat_interval2 / 2);<br>haft2 = 0:delta:(beat_interval2 * 2);<br>dot_qrtr2 = 0:delta:(beat_interval2 * 1.5);  
  
%Note Sounds 2x Speed<br>quarter_G2 = sin(2*pi*G*quarter2);<br>quarter_Bf2 = sin(2*pi*Bf*quarter2);<br>dot_qrtr_C2 = sin(2*pi*C*dot_qrtr2);<br>eighth_Df2 = sin(2*pi*Df*eighth2);<br>haft_C2 = sin(2*pi*C*haft2);<br>haft_G2 = sin(2*pi*G*haft2);
+
%Note Sounds 2x Speed<br>quarter_G2 = sin(2*pi*G*quarter2);<br>quarter_Bf2 = sin(2*pi*Bf*quarter2);<br>dot_qrtr_C2 = sin(2*pi*C*dot_qrtr2);<br>eighth_Df2 = sin(2*pi*Df*eighth2);<br>haft_C2 = sin(2*pi*C*haft2);<br>haft_G2 = sin(2*pi*G*haft2);  
  
%Note Array 2x Speed<br>note_array2 = [quarter_G2 quarter_Bf2 dot_qrtr_C2 quarter_G2 quarter_Bf2 eighth_Df2 haft_C2 quarter_G2 quarter_Bf2 dot_qrtr_C2 quarter_Bf2 quarter_G2];
+
%Note Array 2x Speed<br>note_array2 = [quarter_G2 quarter_Bf2 dot_qrtr_C2 quarter_G2 quarter_Bf2 eighth_Df2 haft_C2 quarter_G2 quarter_Bf2 dot_qrtr_C2 quarter_Bf2 quarter_G2];  
  
%Song on 2x Speed<br>sound(note_array2, 1/delta);<br>wavwrite(note_array2, 1/delta, '301_hw1_1B');
+
%Song on 2x Speed<br>sound(note_array2, 1/delta);<br>wavwrite(note_array2, 1/delta, '301_hw1_1B');  
  
%Prob 1c -- Twice the pitch
+
%Prob 1c -- Twice the pitch  
  
%Note Sounds 2x Pitch<br>quarter_G3 = sin(2*pi*G*quarter);<br>quarter_Bf3 = sin(2*pi*Bf*quarter);<br>dot_qrtr_C3 = sin(2*pi*C*dot_qrtr);<br>eighth_Df3 = sin(2*pi*Df*eighth);<br>haft_C3 = sin(2*pi*C*haft);<br>haft_G3 = sin(2*pi*G*haft);
+
%Note Sounds 2x Pitch<br>quarter_G3 = sin(2*pi*G*quarter);<br>quarter_Bf3 = sin(2*pi*Bf*quarter);<br>dot_qrtr_C3 = sin(2*pi*C*dot_qrtr);<br>eighth_Df3 = sin(2*pi*Df*eighth);<br>haft_C3 = sin(2*pi*C*haft);<br>haft_G3 = sin(2*pi*G*haft);  
  
%Note Array 2x Pitch<br>note_array3 = [quarter_G3 quarter_Bf3 dot_qrtr_C3 quarter_G3 quarter_Bf3 eighth_Df3 haft_C3 quarter_G3 quarter_Bf3 dot_qrtr_C3 quarter_Bf3 quarter_G3];
+
%Note Array 2x Pitch<br>note_array3 = [quarter_G3 quarter_Bf3 dot_qrtr_C3 quarter_G3 quarter_Bf3 eighth_Df3 haft_C3 quarter_G3 quarter_Bf3 dot_qrtr_C3 quarter_Bf3 quarter_G3];  
  
%Song on 2x Pitch<br>sound(note_array3, 1/ delta);<br>wavwrite(note_array3, 1/delta, '301_hw1_1C');
+
%Song on 2x Pitch<br>sound(note_array3, 1/ delta);<br>wavwrite(note_array3, 1/delta, '301_hw1_1C');  
  
%Problem 2<br>%Read and play the original song<br>[y, Fs] = wavread('Beatles.wav');<br>sound(y, Fs);
+
%Problem 2<br>%Read and play the original song<br>[y, Fs] = wavread('Beatles.wav');<br>sound(y, Fs);  
  
%Flip the song and save this version<br>flip = flipud(y);<br>sound(flip, Fs);<br>wavwrite(flip, Fs, 'Beatles_flip');
+
%Flip the song and save this version<br>flip = flipud(y);<br>sound(flip, Fs);<br>wavwrite(flip, Fs, 'Beatles_flip');  
  
% 1. Number 9 is repeated.<br>% 2. It sounds mostly like gibberish but if I had to guess it ends in dead man.<br>
+
% 1. Number 9 is repeated.<br>% 2. It sounds mostly like gibberish but if I had to guess it ends in dead man.<br>[[Media:301_hw1_1A.wav]]
 +
 
 +
[[Media:301_hw1_1B.wav]]
 +
 
 +
[[Media:301_hw1_1C.wav]]

Latest revision as of 10:56, 19 January 2011

delta = .00005;

% Beat
bpm = 112; %beat per minute
beat_interval = 60/bpm;

% Notes
quarter = 0:delta:beat_interval;
eighth = 0:delta:(beat_interval/2);
haft = 0:delta:(beat_interval*2);
dot_qrtr = 0:delta:(beat_interval*1.5);

%Frequencies of Notes
G = (2^(-2/12))*440;
Bf = (2^(1/12))*440;
C = (2^(3/12))*440;
Df = (2^(4/12))*440;

%Note Sounds
quarter_G = sin(2*pi*G*quarter);
quarter_Bf = sin(2*pi*Bf*quarter);
dot_qrtr_C = sin(2*pi*C*dot_qrtr);
eighth_Df = sin(2*pi*Df*eighth);
haft_C = sin(2*pi*C*haft);
haft_G = sin(2*pi*G*haft);

%Note Array
note_array = [quarter_G, quarter_Bf, dot_qrtr_C, quarter_G, quarter_Bf, eighth_Df, haft_C, quarter_G, quarter_Bf, dot_qrtr_C, quarter_Bf, quarter_G];

%Song on Regular Speed
sound(note_array, 1/delta);
wavwrite(note_array, 1/delta, '301_hw1_1A');

%Prob 1b -- Double Speed = half the beat interval
beat_interval2 = (beat_interval / 2);

% Notes 2x Speed
quarter2 = 0:delta:beat_interval2;
eighth2 = 0:delta:(beat_interval2 / 2);
haft2 = 0:delta:(beat_interval2 * 2);
dot_qrtr2 = 0:delta:(beat_interval2 * 1.5);

%Note Sounds 2x Speed
quarter_G2 = sin(2*pi*G*quarter2);
quarter_Bf2 = sin(2*pi*Bf*quarter2);
dot_qrtr_C2 = sin(2*pi*C*dot_qrtr2);
eighth_Df2 = sin(2*pi*Df*eighth2);
haft_C2 = sin(2*pi*C*haft2);
haft_G2 = sin(2*pi*G*haft2);

%Note Array 2x Speed
note_array2 = [quarter_G2 quarter_Bf2 dot_qrtr_C2 quarter_G2 quarter_Bf2 eighth_Df2 haft_C2 quarter_G2 quarter_Bf2 dot_qrtr_C2 quarter_Bf2 quarter_G2];

%Song on 2x Speed
sound(note_array2, 1/delta);
wavwrite(note_array2, 1/delta, '301_hw1_1B');

%Prob 1c -- Twice the pitch

%Note Sounds 2x Pitch
quarter_G3 = sin(2*pi*G*quarter);
quarter_Bf3 = sin(2*pi*Bf*quarter);
dot_qrtr_C3 = sin(2*pi*C*dot_qrtr);
eighth_Df3 = sin(2*pi*Df*eighth);
haft_C3 = sin(2*pi*C*haft);
haft_G3 = sin(2*pi*G*haft);

%Note Array 2x Pitch
note_array3 = [quarter_G3 quarter_Bf3 dot_qrtr_C3 quarter_G3 quarter_Bf3 eighth_Df3 haft_C3 quarter_G3 quarter_Bf3 dot_qrtr_C3 quarter_Bf3 quarter_G3];

%Song on 2x Pitch
sound(note_array3, 1/ delta);
wavwrite(note_array3, 1/delta, '301_hw1_1C');

%Problem 2
%Read and play the original song
[y, Fs] = wavread('Beatles.wav');
sound(y, Fs);

%Flip the song and save this version
flip = flipud(y);
sound(flip, Fs);
wavwrite(flip, Fs, 'Beatles_flip');

% 1. Number 9 is repeated.
% 2. It sounds mostly like gibberish but if I had to guess it ends in dead man.
Media:301_hw1_1A.wav

Media:301_hw1_1B.wav

Media:301_hw1_1C.wav

Alumni Liaison

Ph.D. on Applied Mathematics in Aug 2007. Involved on applications of image super-resolution to electron microscopy

Francisco Blanco-Silva