Sound File

MATLAB Code

%Collin Phillips Ece 301 
%Sept. 4 2008
%Hw1 part 1
clear
clc
rest = 0;
Ab = 415.30;
Bb = 466.16;
B  = 493.88;
C  = 523.25;
Db = 554.37;
Eb = 311.13;
F  = 349.23;
G  = 392;

%define beats (can range from 40 bpm to 200 bpm) 
e =.25;
q =.5;
dq =.75;
h =1;
dh =1.5;
w =2;

deltat= 1/2000;

rhythm=[h,q,q,dq,e,q,q,q,e,e,q,e,e,w];

notes=[Eb,F,G,Ab,Bb,C,C,Db,Db,Db,Ab,Bb,B,C];

%a. normal play
for lcv =1:length(notes)
	t =0:deltat:rhythm(lcv);
	wave =sin(2*pi*t*notes(lcv));
	sound(wave,1/deltat);
end

pause(3)

%b. 2x play
for lcv =1:length(notes)
	t =0:deltat:1/2*rhythm(lcv); 
	wave =sin(2*pi*t*notes(lcv));
	sound(wave,1/deltat);
end

pause(3)

%c. y(t)=x(2t)
for lcv =1:length(notes)
	t =0:deltat:rhythm(lcv);
	wave =sin(4*pi*t*notes(lcv)); 
	sound(wave,1/deltat);
end

Alumni Liaison

Have a piece of advice for Purdue students? Share it through Rhea!

Alumni Liaison