%------------- Begin Lab #2b ----- %********************** % Colin D. Joye * % Lab #2b * % ECE 3220 - 001 * % Due Tue. 9/26/00 * %********************** % Objectives and Conclusions: % The objective of this practicum was to better unserstand % sampling and to be able to contruct sums of sampled % sinusoids in order to create musical tones. This part of % the lab programs a musical score into a Matlab. % This version of "Jesu Joy of Man's Desiring" incorporates % measures 1-13 of Virgil Fox's version of Bach's organ score. % The "note.m" function includes slight added harmonics % at octaves (2*f, 3*f, 4*f ...) in order to add briliance % to the tones. fs = 11025; dur_1 = 0.15; dur_2= 2*dur_1; dur_3= 3*dur_1; % 4.a) Defining notes R = note(0,dur_1); % 1/3 rest G1 = note(11,dur_3); E2_3 = note(20,dur_3); G2 = note(23,dur_1); G2_2 = note(23,dur_2); G2_3 = note(23,dur_3); A2 = note(25,dur_1); A2_2 = note(25,dur_2); A2_3 = note(25,dur_3); B2 = note(27,dur_1); B2_2 = note(27,dur_2); B2_3 = note(27,dur_3); C3 = note(28,dur_1); C3_2 = note(28,dur_2); C3_3 = note(28,dur_3); C3s= note(29,dur_1); C3s_2= note(29,dur_2); C3s_3= note(29,dur_3); D3 = note(30,dur_1); D3_2 = note(30,dur_2); D3_3 = note(30,dur_3); E3 = note(32,dur_1); E3_2 = note(32,dur_2); E3_3 = note(32,dur_3); F3s= note(34,dur_1); F3s_2= note(34,dur_2); F3s_3= note(34,dur_3); G3 = note(35,dur_1); G3_2 = note(35,dur_2); G3_3 = note(35,dur_3); A3 = note(37,dur_1); A3_2 = note(37,dur_2); A3_3 = note(37,dur_3); B3 = note(39,dur_1); B3_2 = note(39,dur_2); B3_3 = note(39,dur_3); C4 = note(40,dur_1); C4_2 = note(40,dur_2); C4_3 = note(40,dur_3); C4s= note(41,dur_1); C4s_2= note(41,dur_2); C4s_3= note(41,dur_3); D4 = note(42,dur_1); D4_2 = note(42,dur_2); D4_3 = note(42,dur_3); E4 = note(44,dur_1); E4_2 = note(44,dur_2); E4_3 = note(44,dur_3); F4s= note(46,dur_1); F4s_2= note(46,dur_2); F4s_3= note(46,dur_3); G4 = note(47,dur_1); G4_2 = note(47,dur_2); G4_3 = note(47,dur_3); A4 = note(49,dur_1); A4_2 = note(49,dur_2); A4_3 = note(49,dur_3); B4 = note(51,dur_1); B4_2 = note(51,dur_2); B4_3 = note(51,dur_3); C5 = note(52,dur_1); C5_2 = note(52,dur_2); C5_3 = note(52,dur_3); C5s= note(53,dur_1); C5s_2= note(53,dur_2); D5 = note(54,dur_1); D5_2 = note(54,dur_2); E5 = note(56,dur_1); E5_2 = note(56,dur_2); F5s= note(58,dur_1); F5s_2= note(58,dur_2); G5 = note(59,dur_1); G5_2 = note(59,dur_2); A5 = note(61,dur_1); A5_2 = note(61,dur_2); B5 = note(63,dur_1); B5_2 = note(63,dur_2); C6 = note(64,dur_1); C6_2 = note(64,dur_2); % 5.a) A=[ R G4 A4 B4 D5 C5 C5 E5 D5, D5 G5 F5s G5 D5 B4 G4 A4 B4, C5 D5 E5 D5 C5 B4 A4 B4 G4; R R R G4_2 F4s G4_2 A4, B4_2 A4 B4_2 G4 E4_2 D4, E4_2 F4s G4_2 D4 E4_3 ; R R R D4_3 E4_3 , G4_3 E4_3 B3_3 , A3_2 C4 D4_3 C4_3 ; G2_3 G3_3 E3_3 , B2_3 E2_3 E2_3 , A2_3 B2_3 C3_3 ]; B=[ F4s G4 A4 D4 F4s A4 C5 B4 A4, B4 G4 A4 B4 D5 C5 C5 E5 D5, D5 G5 F5s G5 D5 B4 G4 A4 B4; C4_3 D4_2 G4 F4s_2 D4, D4_2 F4s G4_2 F4s G4_2 A4, B4_2 A4 B4_2 G4 E4_2 G4; A3_3 A3_3 A3_2 F3s,G3_3 G3_3 E4_3 , G4_3 E4_3 B3_3 ; D3_3 F3s_3 D3_3 , G2_3 E2_3 C3_3 , B2_3 E3_3 D3_3 ]; C=[ E4 D5 C5 B4 A4 G4 D4 G4 F4s, G4 B4 D5 G5 D5 B4 G4 B4 D4, G4_3 B3_3 C4_3 , D4_3 D4_3 D4_3, C4_3 C4_3 B3_3 ; E4_2 F4s G4_2 E4 D4_3 , D4_2 G4 B4_2 G4 R R R , B3_3 G3_3 G3_3 , A3_3 A3_3 B3_3, B3_3 A3_3 G3_3 ; A3_3 E4_2 B3 A3_2 C4 , B3_3 D3_3 R R R , G3_3 R R R R R R, F3s_3 G3_3 F3s_3, E3_3 D3_3 D3_3 ; C3_3 C3s_3 D3_3 , G2_3 G3_3 G3_3 , G3_3 F3s_3 E3_3 , F3s_3 E3_3 D3_3, E3_3 F3s_3 G3_3 ]; D=[ R D4 E4 F4s A4 G4 A4 C5 B4, C5 A4 F4s D4 F4s A4 C5 B4 A4, B4 G4 A4 B4 D5 C5 C5 E5 D5, D5 G5 F5s G5 D5 B4 G4 A4 B4; A3_3 A3_3 A3_3 , F4s_2 C4 D4 D4_2 D4_3 , D4_2 F4s G4_2 F4s G4_2 A4, B4_2 A4 B4_2 G4 E4_2 G4; F3s_3 F3s_3 F3s_3 , F3s R R R R R R R R , G3_3 G3_3 E4_3 , G4_3 E4_3 B3_3 ; D3_3 D3_3 D3_3 , D3_3 D3_3 D3_3 , G2_3 E2_3 C3_3 , B2_3 E3_3 D3_3 ]; E=[ E4 D5 C5 B4 A4 G4 D4 G4 F4s, G4 B4 D5 G5 D5 B4 G4 D4 D3, G4_3 G4_3 G4_3, G4_2 R ; E4_2 F4s G4_2 E4 D4_3 , D4_2 G4 B4_2 G4 D4_2 R , B3_3 B3_3 B3_3, B3_2 R ; A3_3 E4_2 B3 A3_2 C4 , B3_3 D3_3 B3_2 R , D3_3 D3_3 D3_3, D3_2 R ; C3_3 C3s_3 D3_3 , G2_3 G3_3 G3_3 , G3_3+G1 G2_3+G1 G2_3+G1, G2_3+G1 ]; A=sum(A,1)/8; B=sum(B,1)/8; C=sum(C,1)/8; D=sum(D,1)/8; E=sum(E,1)/8; sound ([A B C D E] , 8000); % % 5.b) figure(1) % Spectrogram of song specgram(A,[],8000); title('Plot in 5.b, Spectrogram of song'); % The spectrogram shows the relative frequency content of the vectors and the relative time at which they occur.