(New page: %Hetong Li %09/01/08 %ECE301 hw1.1 clear; clc; %initialze basic variables x=440*3/5;%basic frequency. delta=0.0005; dur=0.5; t=0:delta:dur; scale=1; %assign frequencies for each tone. fm...)
 
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
== Wav Files ==
 +
* a. [[Media: music-a_ECE301Fall2008mboutin.wav|part a]] (normal speed)
 +
* b. [[Media: music-b_ECE301Fall2008mboutin.wav|part b]] (fast speed)
 +
* c. [[Media: music-c_ECE301Fall2008mboutin.wav|part c]] (higher pitch)
 +
 +
== Matlab Code ==
 +
 +
<pre>
 
%Hetong Li
 
%Hetong Li
 
%09/01/08
 
%09/01/08
Line 5: Line 13:
 
clear;
 
clear;
 
clc;
 
clc;
%initialze basic variables
 
x=440*3/5;%basic frequency.
 
delta=0.0005;
 
dur=0.5;
 
t=0:delta:dur;
 
scale=1;
 
  
%assign frequencies for each tone.
+
% PART A
fmidC=x;
+
 
fD=9*x/8;
+
delta = 0.0005;
fE=5*x/4;
+
H=0:delta: 1;          %half
fF=4*x/3;
+
Q=0:delta:0.5;        %quacter
fG=3*x/2;
+
DQ_time=0:delta:0.75;  %dotted quacter
fA=5*x/3;
+
EN=0:delta:0.25;      %one eighth
fB=15*x/8;
+
 
fupC=2*x;
+
%Assign signals for each used note
 +
AH = sin(2*pi*220*H);
 +
BQ= sin(2*pi*493.88/2*Q);
 +
DBQ=sin(2*pi*277.18*Q);
 +
DDQ = sin(2*pi*293.66*DQ_time);
 +
DQ = sin(2*pi*293.66*Q);
 +
EEN =sin(2*pi*329.63*EN);
 +
GBQ=sin(2*pi*369.99*Q);
 +
GQ=sin(2*pi*392*Q);
 +
GEN=sin(2*pi*392*EN);
 +
FEN= sin(2*pi*349.23*EN);
 +
GBEN=sin(2*pi*369.99*EN);
 +
 
 +
notes= [AH BQ DBQ DDQ EEN GBQ GBQ GQ GEN GEN DQ EEN FEN GBEN];
 +
 
 +
sound (notes,1/delta);
 +
wavwrite(notes,1/delta,32,'music-a.wav');
 +
 
 +
% PART B
 +
 
 +
%half the duration
 +
%we will hear the some plays at twice speed as before
 +
 
 +
delta = 0.0005;
 +
H=0:delta: 0.5;
 +
Q=0:delta:0.25;
 +
DQ_time=0:delta:0.375;
 +
EN=0:delta:0.125;
 +
 
 +
AH = sin(2*pi*220*H);
 +
BQ= sin(2*pi*493.88/2*Q);
 +
DBQ=sin(2*pi*277.18*Q);
 +
DDQ = sin(2*pi*293.66*DQ_time);
 +
DQ = sin(2*pi*293.66*Q);
 +
EEN =sin(2*pi*329.63*EN);
 +
GBQ=sin(2*pi*369.99*Q);
 +
GQ=sin(2*pi*392*Q);
 +
GEN=sin(2*pi*392*EN);
 +
FEN= sin(2*pi*349.23*EN);
 +
GBEN=sin(2*pi*369.99*EN);
 +
 
 +
notes= [AH BQ DBQ DDQ EEN GBQ GBQ GQ GEN GEN DQ EEN FEN GBEN];
 +
 
 +
sound (notes,1/delta);
 +
wavwrite(notes,1/delta,32,'music-b.wav');
 +
 
 +
% PART C
 +
 
 +
%Change the duration back to part a
 +
delta = 0.0005;
 +
H=0:delta: 1;
 +
Q=0:delta:0.5;
 +
DQ_time=0:delta:0.75;
 +
EN=0:delta:0.25;
 +
 
 +
%as we replace t with 2t,so double the time in signal function
 +
%which also means double the frequency of each signal
 +
%we will hear a song with higher pitch
  
part = input('Please choose the part you want to play(a,b,c):','s');
+
AH = sin(2*pi*2*220*H);
 +
BQ= sin(2*pi*2*493.88/2*Q);
 +
DBQ=sin(2*pi*2*277.18*Q);
 +
DDQ = sin(2*pi*2*293.66*DQ_time);
 +
DQ = sin(2*pi*2*293.66*Q);
 +
EEN =sin(2*pi*2*329.63*EN);
 +
GBQ=sin(2*pi*2*369.99*Q);
 +
GQ=sin(2*pi*2*392*Q);
 +
GEN=sin(2*pi*2*392*EN);
 +
FEN= sin(2*pi*2*349.23*EN);
 +
GBEN=sin(2*pi*2*369.99*EN);
  
if(strcmp(part,'a'))
+
notes= [AH BQ DBQ DDQ EEN GBQ GBQ GQ GEN GEN DQ EEN FEN GBEN];
    dur=0.5;
+
elseif(strcmp(part,'b'))
+
    dur=0.25;
+
elseif(strcmp(part,'c'))
+
    scale=2;
+
else
+
    fprintf('Sorry,there is no corresponding part');
+
end
+
  
t=0:delta:dur;
 
%assign signals of each tone.
 
midC=sin(2*pi*fmidC*t*scale);
 
D=sin(2*pi*fD*t*scale);
 
E=sin(2*pi*fE*t*scale);
 
F=sin(2*pi*fF*t*scale);
 
G=sin(2*pi*fG*t*scale);
 
A=sin(2*pi*fA*t*scale);
 
B=sin(2*pi*fB*t*scale);
 
upC=sin(2*pi*fupC*t*scale);
 
  
y=[midC,midC,G,G,A,A,G,G,F,F,E,E,D,D,midC];
+
sound (notes,1/delta);
sound(y,1/delta);
+
wavwrite(notes,1/delta,32,'music-c.wav');

Latest revision as of 17:52, 3 September 2008

Wav Files

Matlab Code

%Hetong Li
%09/01/08
%ECE301 hw1.1

clear;
clc;

% PART A

delta = 0.0005;
H=0:delta: 1;          %half
Q=0:delta:0.5;         %quacter
DQ_time=0:delta:0.75;  %dotted quacter
EN=0:delta:0.25;       %one eighth

%Assign signals for each used note
AH = sin(2*pi*220*H);
BQ= sin(2*pi*493.88/2*Q);
DBQ=sin(2*pi*277.18*Q);
DDQ = sin(2*pi*293.66*DQ_time);
DQ = sin(2*pi*293.66*Q);
EEN =sin(2*pi*329.63*EN);
GBQ=sin(2*pi*369.99*Q);
GQ=sin(2*pi*392*Q);
GEN=sin(2*pi*392*EN);
FEN= sin(2*pi*349.23*EN);
GBEN=sin(2*pi*369.99*EN);

notes= [AH BQ DBQ DDQ EEN GBQ GBQ GQ GEN GEN DQ EEN FEN GBEN];

sound (notes,1/delta);
wavwrite(notes,1/delta,32,'music-a.wav');

% PART B

%half the duration
%we will hear the some plays at twice speed as before

delta = 0.0005;
H=0:delta: 0.5;
Q=0:delta:0.25;
DQ_time=0:delta:0.375;
EN=0:delta:0.125;

AH = sin(2*pi*220*H);
BQ= sin(2*pi*493.88/2*Q);
DBQ=sin(2*pi*277.18*Q);
DDQ = sin(2*pi*293.66*DQ_time);
DQ = sin(2*pi*293.66*Q);
EEN =sin(2*pi*329.63*EN);
GBQ=sin(2*pi*369.99*Q);
GQ=sin(2*pi*392*Q);
GEN=sin(2*pi*392*EN);
FEN= sin(2*pi*349.23*EN);
GBEN=sin(2*pi*369.99*EN);

notes= [AH BQ DBQ DDQ EEN GBQ GBQ GQ GEN GEN DQ EEN FEN GBEN];

sound (notes,1/delta);
wavwrite(notes,1/delta,32,'music-b.wav');

% PART C

%Change the duration back to part a
delta = 0.0005;
H=0:delta: 1;
Q=0:delta:0.5;
DQ_time=0:delta:0.75;
EN=0:delta:0.25;

%as we replace t with 2t,so double the time in signal function
%which also means double the frequency of each signal
%we will hear a song with higher pitch

AH = sin(2*pi*2*220*H);
BQ= sin(2*pi*2*493.88/2*Q);
DBQ=sin(2*pi*2*277.18*Q);
DDQ = sin(2*pi*2*293.66*DQ_time);
DQ = sin(2*pi*2*293.66*Q);
EEN =sin(2*pi*2*329.63*EN);
GBQ=sin(2*pi*2*369.99*Q);
GQ=sin(2*pi*2*392*Q);
GEN=sin(2*pi*2*392*EN);
FEN= sin(2*pi*2*349.23*EN);
GBEN=sin(2*pi*2*369.99*EN);

notes= [AH BQ DBQ DDQ EEN GBQ GBQ GQ GEN GEN DQ EEN FEN GBEN];


sound (notes,1/delta);
wavwrite(notes,1/delta,32,'music-c.wav');

Alumni Liaison

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

Buyue Zhang