Audio file with results from parts A, B, and C
MATLAB .m file
%Ryan Scott %rfscott@purdue.edu %301 HW1 - Hail Purdue clear; clc; %define delta same as in class delta=1/20000; %define beats (in seconds) using 120bpm for the song %(a guess, seems close, maybe a little slow) e=.25; q=.5; dq=.75; h=1; dh=1.5; w=2; %define our notes using %http://www.phy.mtu.edu/~suits/notefreqs.html as a ref for note names A=220; B=246.94; C=261.63; Db=277.18; D=293.66; E=329.63; F=349.23; Gb=369.99; G=392; %notes we are going to play notes=[A,B,Db,D,E,Gb,Gb,G,G,G,D,E,F,Gb,Gb,Gb,E,D,E,Gb,Gb,E,B,Db,D,Db,B,E,... A,A,B,Db,D,E,Gb,Gb,Gb,G,G,D,E,Gb,B,Db,D,B,A,D,Gb,A,B,Gb,E,D,D]; %timings for above notes lengths=[h,q,q,dq,e,q,q,q,e,e,q,e,e,dh,h,q,q,dq,e,q,q,q,e,e,q,e,e,w,dq,e,... q,q,dq,e,q,e,e,q,q,q,q,w,dq,e,q,q,q,q,q,q,dq,e,dq,e,w,w]; %normal speed loop for lcv=1:length(notes) t=0:delta:lengths(lcv); wave=sin(2*pi*t*notes(lcv)); sound(wave,1/delta); end pause(2) %twice as fast this time for lcv=1:length(notes) t=0:delta:.5*lengths(lcv); %the *.5 is the scaling here to make faster wave=sin(2*pi*t*notes(lcv)); sound(wave,1/delta); end pause(2) %x(2t) changes the frequency for lcv=1:length(notes) t=0:delta:lengths(lcv); wave=sin(2*2*pi*t*notes(lcv)); %the second *2 is the scaling here sound(wave,1/delta); end