(New page: DJ David Hartmann %ECE 301, Prof. Mimi Boutin %HW 1 %September 5, 2008 delta = 0.00005; tied = [0:delta:1.2]; %Setting duration of notes half = [0:delta:0.8]; dottedquarter = [0:delta...)
 
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
=[[Homework_1_ECE301Fall2008mboutin|HW1]], [[ECE301]], Prof. [[user:mboutin|Boutin]]=
 +
In this homework assignment, we were asked to write a Matlab code to play the "Hail Purdue" song with different speeds and pitch. Here are my results:
 +
*[[Media:HailPurdueReg_ECE301Fall2008mboutin.wav]]
 +
*[[Media:HailPurdueFast_ECE301Fall2008mboutin.wav]]
 +
*[[Media:HailPurdueTrans_ECE301Fall2008mboutin.wav]]
 +
 +
== MATLAB CODE ==
 +
 
DJ David Hartmann
 
DJ David Hartmann
  
Line 6: Line 14:
  
 
%September 5, 2008
 
%September 5, 2008
 +
 +
  
 
delta = 0.00005;
 
delta = 0.00005;
  
 
tied = [0:delta:1.2]; %Setting duration of notes
 
tied = [0:delta:1.2]; %Setting duration of notes
 +
 
half = [0:delta:0.8];
 
half = [0:delta:0.8];
 +
 
dottedquarter = [0:delta:0.6];
 
dottedquarter = [0:delta:0.6];
 +
 
quarter = [0:delta:0.4];
 
quarter = [0:delta:0.4];
 +
 
eighth = [0:delta:0.2];
 
eighth = [0:delta:0.2];
 +
 
      
 
      
 
half_e = sin(2*pi*330*half); %Setting sine waves that represent each note/lengths
 
half_e = sin(2*pi*330*half); %Setting sine waves that represent each note/lengths
 +
 
quarter_f = sin(2*pi*352*quarter);
 
quarter_f = sin(2*pi*352*quarter);
 +
 
quarter_g = sin(2*pi*396*quarter);
 
quarter_g = sin(2*pi*396*quarter);
 +
 
dottedquarter_a = sin(2*pi*440*dottedquarter);
 
dottedquarter_a = sin(2*pi*440*dottedquarter);
 +
 
quarter_a = sin(2*pi*440*quarter);
 
quarter_a = sin(2*pi*440*quarter);
 +
 
eighth_b = sin(2*pi*495*eighth);
 
eighth_b = sin(2*pi*495*eighth);
 +
 
quarter_c = sin(2*pi*528*quarter);
 
quarter_c = sin(2*pi*528*quarter);
 +
 
tied_c = sin(2*pi*528*tied);
 
tied_c = sin(2*pi*528*tied);
 +
 
eighth_d = sin(2*pi*594*eighth);
 
eighth_d = sin(2*pi*594*eighth);
 +
 
quarter_d = sin(2*pi*594*quarter);
 
quarter_d = sin(2*pi*594*quarter);
 +
 +
  
 
%Vector containing appropriate notes/lengths
 
%Vector containing appropriate notes/lengths
 +
 
HP = [half_e, quarter_f, quarter_g, dottedquarter_a, eighth_b, quarter_c,quarter_c, quarter_d, eighth_d, eighth_d, quarter_a, eighth_b, eighth_b, tied_c];
 
HP = [half_e, quarter_f, quarter_g, dottedquarter_a, eighth_b, quarter_c,quarter_c, quarter_d, eighth_d, eighth_d, quarter_a, eighth_b, eighth_b, tied_c];
 +
 
%Get ready to Boiler Up to the tune of Hail Purdue Matlab style!
 
%Get ready to Boiler Up to the tune of Hail Purdue Matlab style!
 +
 
sound(HP, 1/delta)
 
sound(HP, 1/delta)
 +
  
 
%_______________PART B_________________FASTER
 
%_______________PART B_________________FASTER
  
 
tied = [0:delta:0.6]; %Setting duration of notes
 
tied = [0:delta:0.6]; %Setting duration of notes
 +
 
half = [0:delta:0.4];
 
half = [0:delta:0.4];
 +
 
dottedquarter = [0:delta:0.3];
 
dottedquarter = [0:delta:0.3];
 +
 
quarter = [0:delta:0.2];
 
quarter = [0:delta:0.2];
 +
 
eighth = [0:delta:0.1];
 
eighth = [0:delta:0.1];
 +
 
      
 
      
 
half_e = sin(2*pi*330*half); %Setting sine waves that represent each note/lengths
 
half_e = sin(2*pi*330*half); %Setting sine waves that represent each note/lengths
 +
 
quarter_f = sin(2*pi*352*quarter);
 
quarter_f = sin(2*pi*352*quarter);
 +
 
quarter_g = sin(2*pi*396*quarter);
 
quarter_g = sin(2*pi*396*quarter);
 +
 
dottedquarter_a = sin(2*pi*440*dottedquarter);
 
dottedquarter_a = sin(2*pi*440*dottedquarter);
 +
 
quarter_a = sin(2*pi*440*quarter);
 
quarter_a = sin(2*pi*440*quarter);
 +
 
eighth_b = sin(2*pi*495*eighth);
 
eighth_b = sin(2*pi*495*eighth);
 +
 
quarter_c = sin(2*pi*528*quarter);
 
quarter_c = sin(2*pi*528*quarter);
 +
 
tied_c = sin(2*pi*528*tied);
 
tied_c = sin(2*pi*528*tied);
 +
 
eighth_d = sin(2*pi*594*eighth);
 
eighth_d = sin(2*pi*594*eighth);
 +
 
quarter_d = sin(2*pi*594*quarter);
 
quarter_d = sin(2*pi*594*quarter);
  
 
%Vector containing appropriate notes/lengths
 
%Vector containing appropriate notes/lengths
HP = [half_e, quarter_f, quarter_g, dottedquarter_a, eighth_b, quarter_c,quarter_c, quarter_d, eighth_d, eighth_d, quarter_a, eighth_b, eighth_b, tied_c];
+
 
 +
HPF = [half_e, quarter_f, quarter_g, dottedquarter_a, eighth_b, quarter_c,quarter_c, quarter_d, eighth_d, eighth_d, quarter_a, eighth_b, eighth_b, tied_c];
 +
 
 
%Get ready to Boiler Up to the tune of Hail Purdue Matlab style at twice the speed!
 
%Get ready to Boiler Up to the tune of Hail Purdue Matlab style at twice the speed!
sound(HP, 1/delta)
 
  
 +
sound(HPF, 1/delta)
  
%______________PART C________________SLOWER
 
  
tied = [0:delta:2.4]; %Setting duration of notes
+
 
half = [0:delta:1.6];
+
%______________PART C________________HIGHER
dottedquarter = [0:delta:1.2];
+
 
quarter = [0:delta:0.8];
+
tied = [0:delta:1.2]; %Setting duration of notes
eighth = [0:delta:0.4];
+
 
 +
half = [0:delta:1.0];
 +
 
 +
dottedquarter = [0:delta:0.6];
 +
 
 +
quarter = [0:delta:0.4];
 +
 
 +
eighth = [0:delta:0.2];
 +
 
 
      
 
      
half_e = sin(2*pi*330*half); %Setting sine waves that represent each note/lengths
+
half_e = sin(4*pi*330*half); %Setting sine waves that represent each note/lengths
quarter_f = sin(2*pi*352*quarter);
+
 
quarter_g = sin(2*pi*396*quarter);
+
quarter_f = sin(4*pi*352*quarter);
dottedquarter_a = sin(2*pi*440*dottedquarter);
+
 
quarter_a = sin(2*pi*440*quarter);
+
quarter_g = sin(4*pi*396*quarter);
eighth_b = sin(2*pi*495*eighth);
+
 
quarter_c = sin(2*pi*528*quarter);
+
dottedquarter_a = sin(4*pi*440*dottedquarter);
tied_c = sin(2*pi*528*tied);
+
 
eighth_d = sin(2*pi*594*eighth);
+
quarter_a = sin(4*pi*440*quarter);
 +
 
 +
eighth_b = sin(4*pi*495*eighth);
 +
 
 +
quarter_c = sin(4*pi*528*quarter);
 +
 
 +
tied_c = sin(4*pi*528*tied);
 +
 
 +
eighth_d = sin(4*pi*594*eighth);
 +
 
 
quarter_d = sin(2*pi*594*quarter);
 
quarter_d = sin(2*pi*594*quarter);
 +
  
 
%Vector containing appropriate notes/lengths
 
%Vector containing appropriate notes/lengths
HP = [half_e, quarter_f, quarter_g, dottedquarter_a, eighth_b, quarter_c,quarter_c, quarter_d, eighth_d, eighth_d, quarter_a, eighth_b, eighth_b, tied_c];
+
 
%Get ready to Boiler Up to the tune of Hail Purdue Matlab style at half the speed!
+
HPS = [half_e, quarter_f, quarter_g, dottedquarter_a, eighth_b, quarter_c,quarter_c, quarter_d, eighth_d, eighth_d, quarter_a, eighth_b, eighth_b, tied_c];
sound(HP, 1/delta)
+
 
 +
%Get ready to Boiler Up to the tune of Hail Purdue Matlab style at the next octave!
 +
 
 +
sound(HPS, 1/delta)
 +
 
 +
 
 +
== Results ==
 +
[[Media:HailPurdueReg_ECE301Fall2008mboutin.wav]]
 +
 
 +
[[Media:HailPurdueFast_ECE301Fall2008mboutin.wav]]
 +
 
 +
[[Media:HailPurdueTrans_ECE301Fall2008mboutin.wav]]

Latest revision as of 09:36, 27 August 2010

HW1, ECE301, Prof. Boutin

In this homework assignment, we were asked to write a Matlab code to play the "Hail Purdue" song with different speeds and pitch. Here are my results:

MATLAB CODE

DJ David Hartmann

%ECE 301, Prof. Mimi Boutin

%HW 1

%September 5, 2008


delta = 0.00005;

tied = [0:delta:1.2]; %Setting duration of notes

half = [0:delta:0.8];

dottedquarter = [0:delta:0.6];

quarter = [0:delta:0.4];

eighth = [0:delta:0.2];


half_e = sin(2*pi*330*half); %Setting sine waves that represent each note/lengths

quarter_f = sin(2*pi*352*quarter);

quarter_g = sin(2*pi*396*quarter);

dottedquarter_a = sin(2*pi*440*dottedquarter);

quarter_a = sin(2*pi*440*quarter);

eighth_b = sin(2*pi*495*eighth);

quarter_c = sin(2*pi*528*quarter);

tied_c = sin(2*pi*528*tied);

eighth_d = sin(2*pi*594*eighth);

quarter_d = sin(2*pi*594*quarter);


%Vector containing appropriate notes/lengths

HP = [half_e, quarter_f, quarter_g, dottedquarter_a, eighth_b, quarter_c,quarter_c, quarter_d, eighth_d, eighth_d, quarter_a, eighth_b, eighth_b, tied_c];

%Get ready to Boiler Up to the tune of Hail Purdue Matlab style!

sound(HP, 1/delta)


%_______________PART B_________________FASTER

tied = [0:delta:0.6]; %Setting duration of notes

half = [0:delta:0.4];

dottedquarter = [0:delta:0.3];

quarter = [0:delta:0.2];

eighth = [0:delta:0.1];


half_e = sin(2*pi*330*half); %Setting sine waves that represent each note/lengths

quarter_f = sin(2*pi*352*quarter);

quarter_g = sin(2*pi*396*quarter);

dottedquarter_a = sin(2*pi*440*dottedquarter);

quarter_a = sin(2*pi*440*quarter);

eighth_b = sin(2*pi*495*eighth);

quarter_c = sin(2*pi*528*quarter);

tied_c = sin(2*pi*528*tied);

eighth_d = sin(2*pi*594*eighth);

quarter_d = sin(2*pi*594*quarter);

%Vector containing appropriate notes/lengths

HPF = [half_e, quarter_f, quarter_g, dottedquarter_a, eighth_b, quarter_c,quarter_c, quarter_d, eighth_d, eighth_d, quarter_a, eighth_b, eighth_b, tied_c];

%Get ready to Boiler Up to the tune of Hail Purdue Matlab style at twice the speed!

sound(HPF, 1/delta)


%______________PART C________________HIGHER

tied = [0:delta:1.2]; %Setting duration of notes

half = [0:delta:1.0];

dottedquarter = [0:delta:0.6];

quarter = [0:delta:0.4];

eighth = [0:delta:0.2];


half_e = sin(4*pi*330*half); %Setting sine waves that represent each note/lengths

quarter_f = sin(4*pi*352*quarter);

quarter_g = sin(4*pi*396*quarter);

dottedquarter_a = sin(4*pi*440*dottedquarter);

quarter_a = sin(4*pi*440*quarter);

eighth_b = sin(4*pi*495*eighth);

quarter_c = sin(4*pi*528*quarter);

tied_c = sin(4*pi*528*tied);

eighth_d = sin(4*pi*594*eighth);

quarter_d = sin(2*pi*594*quarter);


%Vector containing appropriate notes/lengths

HPS = [half_e, quarter_f, quarter_g, dottedquarter_a, eighth_b, quarter_c,quarter_c, quarter_d, eighth_d, eighth_d, quarter_a, eighth_b, eighth_b, tied_c];

%Get ready to Boiler Up to the tune of Hail Purdue Matlab style at the next octave!

sound(HPS, 1/delta)


Results

Media:HailPurdueReg_ECE301Fall2008mboutin.wav

Media:HailPurdueFast_ECE301Fall2008mboutin.wav

Media:HailPurdueTrans_ECE301Fall2008mboutin.wav

Alumni Liaison

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

Landis Huffman