Matlab Code

  %% Joshua Long
  %% ECE 301
  %% HW 1.1 Playing Music
  
  %% clear memory
  clear
  
  %% clear console
  clc
  
  delta = .00005;
  
  tempo = 60/140;
  
  %%Values for note lengths
  hn = 0:delta:2*tempo;
  qn = 0:delta:tempo;
  en = 0:delta:.5*tempo;
  dqn = 0:delta:1.5*tempo;
  
  %%Values for note lengths for Twice the tempo
  thn = 0:delta:.5*2*tempo;
  tqn = 0:delta:.5*tempo;
  ten = 0:delta:.5*.5*tempo;
  tdqn = 0:delta:.5*1.5*tempo;
  
  %%Values for the freq. of notes
  Eb = 311.13;
  F = 349.23;
  G = 392.00;
  Ab = 415.30;
  Bb = 466.16;
  C = 523.25;
  
  %%Regular Tempo
  y = [sin(2*pi*Eb*hn),sin(2*pi*F*qn),sin(2*pi*G*qn),sin(2*pi*Ab*dqn),sin(2*pi*Bb*en), sin(2*pi*C*qn)];
  %%Transformation of x(t) = y(2)
  x = [sin(2*pi*2*Eb*hn),sin(2*pi*2*F*qn),sin(2*pi*2*G*qn),sin(2*pi*2*Ab*dqn),sin(2*pi*2*Bb*en), sin(2*pi*2*C*qn)];
  %%Tempo Twice as Fast
  z = [sin(2*pi*Eb*thn),sin(2*pi*F*tqn),sin(2*pi*G*tqn),sin(2*pi*Ab*tdqn),sin(2*pi*Bb*ten), sin(2*pi*C*tqn)];
  
  sound(y,1/delta);
  sound(z,1/delta);
  sound(x,1/delta);
  
  %%Save a wav file:
  wavwrite([y,z,x],44100/2.2,32,'N:\Personal\ECE301\Hail_Purdue.wav');

 


Results

The audio file contains the regular Hail Purdue followed by the tune being played twice as fast followed by the y(t)=x(2t) transformation.

The first two have the same sounding notes but the 2nd is just half the time to play. However, the last one made the frequency twice as fast and made it half the tempo.

Alumni Liaison

Ph.D. 2007, working on developing cool imaging technologies for digital cameras, camera phones, and video surveillance cameras.

Buyue Zhang