Matlab Code
%% Joshua Long %% ECE 301 %% HW 1.1 Playing Music %% clear memory clear %% clear console clc delta = .00005; tempo = 60/140; %%Values for note lengths hn = 0:delta:2*tempo; qn = 0:delta:tempo; en = 0:delta:.5*tempo; dqn = 0:delta:1.5*tempo; %%Values for note lengths for Twice the tempo thn = 0:delta:.5*2*tempo; tqn = 0:delta:.5*tempo; ten = 0:delta:.5*.5*tempo; tdqn = 0:delta:.5*1.5*tempo; %%Values for the freq. of notes Eb = 311.13; F = 349.23; G = 392.00; Ab = 415.30; Bb = 466.16; C = 523.25; %%Regular Tempo y = [sin(2*pi*Eb*hn),sin(2*pi*F*qn),sin(2*pi*G*qn),sin(2*pi*Ab*dqn),sin(2*pi*Bb*en), sin(2*pi*C*qn)]; %%Transformation of x(t) = y(2) x = [sin(2*pi*2*Eb*hn),sin(2*pi*2*F*qn),sin(2*pi*2*G*qn),sin(2*pi*2*Ab*dqn),sin(2*pi*2*Bb*en), sin(2*pi*2*C*qn)]; %%Tempo Twice as Fast z = [sin(2*pi*Eb*thn),sin(2*pi*F*tqn),sin(2*pi*G*tqn),sin(2*pi*Ab*tdqn),sin(2*pi*Bb*ten), sin(2*pi*C*tqn)]; sound(y,1/delta); sound(z,1/delta); sound(x,1/delta); %%Save a wav file: wavwrite([y,z,x],44100/2.2,32,'N:\Personal\ECE301\Hail_Purdue.wav');