SOUND FILE
MATLAB CODE
%ECE 301 %Carlos Leon %Prof. Mimi Boutin %Hw 1.1 - Playing Music %Constants UF = 4 * pi * 4/3 * 3/5 * 440; %Hz UE = 4 * pi * 5/4 * 3/5 * 440; %Hz UD = 4 * pi * 9/8 * 3/5 * 440; %Hz UC = 4 * pi * 3/5 * 440; %Hz B = 2 * pi * 15/8 * 3/5 * 440; %Hz A = 2 * pi * 440; %HZ G = 2 * pi * 3/5 * 3/2 * 440; %Hz F = 2 * pi * 4/3 * 3/5 * 440; %Hz E = 2 * pi * 5/4 * 3/5 * 440; %Hz D = 2 * pi * 9/8 * 3/5 * 440; %Hz C = 2 * pi * 3/5 * 440; %Hz delta = 0.00005; factor = 2; t = 0:delta:0.5*factor; %WN t2 = 0:delta:0.25*factor; % HN t3 = 0:delta:0.75*factor; % 3/2N t4 = 0:delta:0.125*factor; %1/4N t5 = 0:delta:0.375*factor; %3/4N %Calculations y = sin(G*t); y2 = sin(A*t2); y3 = sin(B*t2); y4 = sin(UC*t5); y5 = sin(UD*t4); y6 = sin(UE*t2); y7 = sin(UE*t2); y8 = sin(UF*t2); y9 = sin(UF*t2); y10 = sin(UC*t2); y11 = sin(UD*t2); y12 = sin(UE*t); y13 = sin(1*t); y14 = sin(UE*t); y15 = sin(UE*t2); y16 = sin(UD*t2); y17 = sin(UC*t5); y18 = sin(UD*t4); y19 = sin(UE*t2); y20 = sin(UE*t2); y21 = sin(UD*t2); y22 = sin(A*t4); y23 = sin(B*t4); y24 = sin(UC*t2); y25 = sin(B*t4); y26 = sin(A*t4); y27 = sin(UD*t); y28 = sin(UD*t); y29 = sin(UC*t); y30 = sin(UC*t); ypause = sin(1*t); %2 times faster factor = 1; t = 0:delta:0.5*factor; %WN t2 = 0:delta:0.25*factor; % HN t3 = 0:delta:0.75*factor; % 3/2N t4 = 0:delta:0.125*factor; %1/4N t5 = 0:delta:0.375*factor; % 3/4N fy = sin(G*t); fy2 = sin(A*t2); fy3 = sin(B*t2); fy4 = sin(UC*t5); fy5 = sin(UD*t4); fy6 = sin(UE*t2); fy7 = sin(UE*t2); fy8 = sin(UF*t2); fy9 = sin(UF*t2); fy10 = sin(UC*t2); fy11 = sin(UD*t2); fy12 = sin(UE*t); fy13 = sin(1*t); fy14 = sin(UE*t); fy15 = sin(UE*t2); fy16 = sin(UD*t2); fy17 = sin(UC*t5); fy18 = sin(UD*t4); fy19 = sin(UE*t2); fy20 = sin(UE*t2); fy21 = sin(UD*t2); fy22 = sin(A*t4); fy23 = sin(B*t4); fy24 = sin(UC*t2); fy25 = sin(B*t4); fy26 = sin(A*t4); fy27 = sin(UD*t); fy28 = sin(UD*t); fy29 = sin(UC*t); fy30 = sin(UC*t); % Rescaled factor = 2; t = 0:delta:0.5*factor; %WN t2 = 0:delta:0.25*factor; % HN t3 = 0:delta:0.75*factor; % 3/2N t4 = 0:delta:0.125*factor; %1/4N t5 = 0:delta:0.375*factor; % 3/4N hy = sin(2*G*t); hy2 = sin(2*A*t2); hy3 = sin(2*B*t2); hy4 = sin(2*UC*t5); hy5 = sin(2*UD*t4); hy6 = sin(2*UE*t2); hy7 = sin(2*UE*t2); hy8 = sin(2*UF*t2); hy9 = sin(2*UF*t2); hy10 = sin(2*UC*t2); hy11 = sin(2*UD*t2); hy12 = sin(2*UE*t); hy13 = sin(1*t); hy14 = sin(2*UE*t); hy15 = sin(2*UE*t2); hy16 = sin(2*UD*t2); hy17 = sin(2*UC*t5); hy18 = sin(2*UD*t4); hy19 = sin(2*UE*t2); hy20 = sin(2*UE*t2); hy21 = sin(2*UD*t2); hy22 = sin(2*A*t4); hy23 = sin(2*B*t4); hy24 = sin(2*UC*t2); hy25 = sin(2*B*t4); hy26 = sin(2*A*t4); hy27 = sin(2*UD*t); hy28 = sin(2*UD*t); hy29 = sin(2*UC*t); hy30 = sin(2*UC*t); yy = [y y2 y3 y4 y5 y6 y7 y8 y9 y10 y11 y12 y13 y14 y15 y16 y17 y18 y19 y20 y21 y22 y23 y24 y25 y26 y27 y28 y29 y30 ypause ypause fy fy2 fy3 fy4 fy5 fy6 fy7 fy8 fy9 fy10 fy11 fy12 fy13 fy14 fy15 fy16 fy17 fy18 fy19 fy20 fy21 fy22 fy23 fy24 fy25 fy26 fy27 fy28 fy29 fy30 ypause ypause hy hy2 hy3 hy4 hy5 hy6 hy7 hy8 hy9 hy10 hy11 hy12 hy13 hy14 hy15 hy16 hy17 hy18 hy19 hy20 hy21 hy22 hy23 hy24 hy25 hy26 hy27 hy28 hy29 hy30]; sound(yy, 1/delta); wavwrite(yy, 1/delta, 'soundfile.wav');