(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
% Professor Mimi Boutin
 
% Professor Mimi Boutin
  
% Part 1
+
% Part 1 <br>
clear
+
clear<br>
clc
+
clc<br>
delta = 0.00005;
+
delta = 0.00005;<br>
  
 
% A loop is made to separate Question 1 into 3 parts<br>
 
% A loop is made to separate Question 1 into 3 parts<br>
 +
 
for p = 1:3
 
for p = 1:3
 
     if p ==2
 
     if p ==2
Line 56: Line 57:
 
end
 
end
  
[[Media:Normal melody.wav]]<br>
+
[[Media:Normal melody.wav]] <br>
 
[[Media:Faster melody.wav]]<br>
 
[[Media:Faster melody.wav]]<br>
 
[[Media:Transformation x(2t).wav]]<br>
 
[[Media:Transformation x(2t).wav]]<br>
  
% Part 2
+
% Part 2<br>
clear
+
 
clc
+
clear<br>
% Use wavread to read and store the Beatles song
+
 
[song,Fs] = wavread('Beatles.wav');
+
clc<br>
song_reversed = flipud(song); % this will flip the song and play it in reverse  
+
% Use wavread to read and store the Beatles song<br>
sound(song_reversed,Fs);
+
[song,Fs] = wavread('Beatles.wav');<br>
 +
song_reversed = flipud(song); % this will flip the song and play it in reverse <br>
 +
sound(song_reversed,Fs);<br>
  
The song played in forward say "Number Nine".
+
The song played in forward say "Number Nine".<br>
When it is played in reversed the sound that comes out is "Turn me on dead man".
+
When it is played in reversed the sound that comes out is "Turn me on dead man".<br>

Latest revision as of 07:54, 19 January 2011

% Sharifah Fareena Aljunid % BME 301 Homework 1 % Professor Mimi Boutin

% Part 1
clear
clc
delta = 0.00005;

% A loop is made to separate Question 1 into 3 parts

for p = 1:3

   if p ==2
       bpm = 112*2; % indicating the tune will be twice as fast
   else
       bpm = 112; % normal beats per minute
   end
   
   % Calculation to determine the length of the  in seconds
   H = 0:delta:(2*60/bpm);
   Q = 0:delta:(1*60/bpm);
   E = 0:delta:(0.5*60/bpm);
   DQ = 0:delta:(1.5*60/bpm);
   
   % Part 3, rescaling the frequency of A4
   if p == 3
       fa = 880; % the frequency is double the original as y(t) = x(2t)
   else
       fa = 440; % original frequency of A4
   end
   
   % Calculation of the frequency of any note related to the frequency of A4
   fG = 2^(-2/12)*fa;
   fC = 2^(3/12)*fa;
   fBf = 2^(1/12)*fa;
   fDf = 2^(4/12)*fa;
   
   % Calculation of all note length using a sine wave
   GQ = sin(2*pi*fG*Q);
   BfQ = sin(2*pi*fBf*Q);
   CDQ = sin(2*pi*fC*DQ);
   DfE = sin(2*pi*fDf*E);
   CH = sin(2*pi*fC*H);
   
   % The tune of the song to be played
   z = [GQ, BfQ, CDQ, GQ, BfQ, DfE, CH, GQ, BfQ, CDQ, BfQ, GQ];
   sound(z,1/delta);
   
   % Adjust song according to what is asked for in Question 1
   if p == 1
       wavwrite(z,1/delta,32,'Normal melody')
   elseif p == 2
       wavwrite(z,1/delta,32,'Faster melody')
   else
       wavwrite(z,1/delta,32,'Transformation x(2t)')
   end

end

Media:Normal melody.wav
Media:Faster melody.wav
Media:Transformation x(2t).wav

% Part 2

clear

clc
% Use wavread to read and store the Beatles song
[song,Fs] = wavread('Beatles.wav');
song_reversed = flipud(song); % this will flip the song and play it in reverse
sound(song_reversed,Fs);

The song played in forward say "Number Nine".
When it is played in reversed the sound that comes out is "Turn me on dead man".

Alumni Liaison

BSEE 2004, current Ph.D. student researching signal and image processing.

Landis Huffman