(New page: % 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 ...)
 
Line 57: Line 57:
  
 
[[Media:Normal melody.wav]]
 
[[Media:Normal melody.wav]]
 +
[[Media:Faster melody.wav]]

Revision as of 08:40, 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

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood